diff options
author | Theodore Ts'o <tytso@mit.edu> | 2002-10-31 11:45:06 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2002-10-31 11:45:06 -0500 |
commit | 9ed06a1eb90efbc3290c1b5a56e0e09d243f95da (patch) | |
tree | d054d1a9bb0b9eedc0c0ab662c496434ee749e79 /lib/ext2fs | |
parent | 58f06ae4909f2e24fcacb9c04f8be971305a26f5 (diff) | |
download | e2fsprogs-9ed06a1eb90efbc3290c1b5a56e0e09d243f95da.tar.gz |
openfs.c (ext2fs_open): Fix bug which caused us to pass the
wrong group_block to ext2fs_descriptor_block_loc if we're
using the backup superblock/block group descriptors.
(ext2fs_descriptor_block_loc): If we're using the backup
superblock descriptors, use the backup descriptor block in
the next block group.
Diffstat (limited to 'lib/ext2fs')
-rw-r--r-- | lib/ext2fs/ChangeLog | 9 | ||||
-rw-r--r-- | lib/ext2fs/openfs.c | 20 |
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 57e1d859..5f7d43b6 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,12 @@ +2002-10-31 Theodore Ts'o <tytso@mit.edu> + + * openfs.c (ext2fs_open): Fix bug which caused us to pass the + wrong group_block to ext2fs_descriptor_block_loc if we're + using the backup superblock/block group descriptors. + (ext2fs_descriptor_block_loc): If we're using the backup + superblock descriptors, use the backup descriptor block in + the next block group. + 2002-10-30 Theodore Ts'o <tytso@mit.edu> * alloc_tables.c (ext2fs_allocate_group_table): Allocate the inode diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 4dcae987..eb5a7dc0 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -33,6 +33,7 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i) { int bg; int has_super = 0; + int ret_blk; if (!(fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) || (i < fs->super->s_first_meta_bg)) @@ -41,8 +42,21 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i) bg = (fs->blocksize / sizeof (struct ext2_group_desc)) * i; if (ext2fs_bg_has_super(fs, bg)) has_super = 1; - return (fs->super->s_first_data_block + has_super + - (bg * fs->super->s_blocks_per_group)); + ret_blk = (fs->super->s_first_data_block + has_super + + (bg * fs->super->s_blocks_per_group)); + /* + * If group_block is not the normal value, we're trying to use + * the backup group descriptors and superblock --- so use the + * alternate location of the second block group in the + * metablock group. Ideally we should be testing each bg + * descriptor block individually for correctness, but we don't + * have the infrastructure in place to do that. + */ + if (group_block != fs->super->s_first_data_block && + ((ret_blk + fs->super->s_blocks_per_group) < + fs->super->s_blocks_count)) + ret_blk += fs->super->s_blocks_per_group; + return ret_blk; } /* @@ -120,7 +134,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, goto cleanup; } io_channel_set_blksize(fs->io, block_size); - group_block = superblock + 1; + group_block = superblock; fs->orig_super = 0; } else { io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET); |