2 * alloc_sb.c --- Allocate the superblock and block group descriptors for a
3 * newly initialized filesystem. Used by mke2fs when initializing a filesystem
5 * Copyright (C) 1994, 1995, 1996, 2003 Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
24 #include <sys/types.h>
30 int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
32 ext2fs_block_bitmap bmap)
34 blk_t super_blk, old_desc_blk, new_desc_blk;
35 int j, old_desc_blocks, num_blocks;
37 num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk,
38 &old_desc_blk, &new_desc_blk, 0);
40 if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
41 old_desc_blocks = fs->super->s_first_meta_bg;
44 fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
46 if (super_blk || (group == 0))
47 ext2fs_mark_block_bitmap(bmap, super_blk);
50 for (j=0; j < old_desc_blocks; j++)
51 ext2fs_mark_block_bitmap(bmap, old_desc_blk + j);
54 ext2fs_mark_block_bitmap(bmap, new_desc_blk);