X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lib%2Fext2fs%2Falloc_sb.c;h=0d1c0000c388ccd46b4dfbaeaec5fd9692aa8c1a;hb=d182831a15dfa4d36979be10fdfd4ec06bdd65b9;hp=d9080b66adb33830abeb21dd7617531df6bf2f98;hpb=8f82ef9860339039b54a324be137fbc09b762358;p=tools%2Fe2fsprogs.git diff --git a/lib/ext2fs/alloc_sb.c b/lib/ext2fs/alloc_sb.c index d9080b6..0d1c000 100644 --- a/lib/ext2fs/alloc_sb.c +++ b/lib/ext2fs/alloc_sb.c @@ -5,11 +5,12 @@ * Copyright (C) 1994, 1995, 1996, 2003 Theodore Ts'o. * * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. + * This file may be redistributed under the terms of the GNU Library + * General Public License, version 2. * %End-Header% */ +#include "config.h" #include #include #if HAVE_UNISTD_H @@ -59,27 +60,22 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs, if (super_blk || (group == 0)) ext2fs_mark_block_bitmap2(bmap, super_blk); + if ((group == 0) && (fs->blocksize == 1024) && + EXT2FS_CLUSTER_RATIO(fs) > 1) + ext2fs_mark_block_bitmap2(bmap, 0); if (old_desc_blk) { if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap) - fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT; + ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT); for (j=0; j < old_desc_blocks; j++) - if (old_desc_blk + j < fs->super->s_blocks_count) + if (old_desc_blk + j < ext2fs_blocks_count(fs->super)) ext2fs_mark_block_bitmap2(bmap, old_desc_blk + j); } if (new_desc_blk) ext2fs_mark_block_bitmap2(bmap, new_desc_blk); - if (group == fs->group_desc_count-1) { - num_blocks = (fs->super->s_blocks_count - - fs->super->s_first_data_block) % - fs->super->s_blocks_per_group; - if (!num_blocks) - num_blocks = fs->super->s_blocks_per_group; - } else - num_blocks = fs->super->s_blocks_per_group; - + num_blocks = ext2fs_group_blocks_count(fs, group); num_blocks -= 2 + fs->inode_blocks_per_group + used_blks; return num_blocks ;