ext2: fix panic mounting ext2-overwritten-with-BFS volumes
I have two partitions which used to be ext2, but have long since been reinitialized as BFS. However, the ext2 superblock is still here, and the ext2 filesystem will detect it. It crashes later on trying to access an Inode at block -1, so just add a check for that to avoid the crash. Change-Id: Ie2ed6a969ea3ffd343dedfe45a15dfc37af05804 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1800 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
1f52c921e2
commit
b684f01835
@ -207,7 +207,10 @@ ext2_super_block::IsValid()
|
||||
|| BlocksPerGroup() != (1UL << BlockShift()) * 8
|
||||
|| InodeSize() > (1UL << BlockShift())
|
||||
|| RevisionLevel() > EXT2_MAX_REVISION
|
||||
|| ReservedGDTBlocks() > (1UL << BlockShift()) / 4) {
|
||||
|| ReservedGDTBlocks() > (1UL << BlockShift()) / 4
|
||||
|| NumInodes() == 0
|
||||
|| InodeSize() == 0
|
||||
|| FreeInodes() > NumInodes()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -536,6 +539,8 @@ Volume::GetInodeBlock(ino_t id, off_t& block)
|
||||
|
||||
block = group->InodeTable(Has64bitFeature())
|
||||
+ ((id - 1) % fSuperBlock.InodesPerGroup()) / fInodesPerBlock;
|
||||
if (block < 0)
|
||||
return B_BAD_DATA;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user