Patch from Janito Ferreira Filho (bug #5706): limit the Inode ID to the maximum number of Inodes. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36358 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2010-04-19 19:04:40 +00:00
parent 71609f7e46
commit 17aad616d2
3 changed files with 5 additions and 1 deletions

View File

@ -278,6 +278,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
fBlockSize = 1UL << fSuperBlock.BlockShift();
fFirstDataBlock = fSuperBlock.FirstDataBlock();
fNumInodes = fSuperBlock.NumInodes();
fNumGroups = (fSuperBlock.NumBlocks() - fFirstDataBlock - 1)
/ fSuperBlock.BlocksPerGroup() + 1;
fGroupsPerBlock = fBlockSize / sizeof(ext2_block_group);

View File

@ -38,6 +38,8 @@ public:
fs_volume* FSVolume() const { return fFSVolume; }
const char* Name() const;
uint32 NumInodes() const
{ return fNumInodes; }
off_t NumBlocks() const
{ return fSuperBlock.NumBlocks(); }
off_t FreeBlocks() const
@ -74,6 +76,7 @@ private:
uint32 fBlockSize;
uint32 fBlockShift;
uint32 fFirstDataBlock;
uint32 fNumInodes;
uint32 fNumGroups;
uint32 fGroupsPerBlock;
ext2_block_group** fGroupBlocks;

View File

@ -167,7 +167,7 @@ ext2_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type,
{
Volume* volume = (Volume*)_volume->private_volume;
if (id < 2 || id > volume->NumBlocks()) {
if (id < 2 || id > volume->NumInodes()) {
dprintf("ext2: inode at %Ld requested!\n", id);
return B_ERROR;
}