]>
git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - lib/ext2fs/alloc_tables.c
2 * alloc_tables.c --- Allocate tables for a newly initialized
3 * filesystem. Used by mke2fs when initializing a filesystem
5 * Copyright (C) 1996 Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
20 #include <sys/types.h>
25 #include <linux/ext2_fs.h>
29 errcode_t
ext2fs_allocate_tables(ext2_filsys fs
)
32 blk_t group_blk
, last_blk
, new_blk
, blk
;
35 group_blk
= fs
->super
->s_first_data_block
;
36 for (i
= 0; i
< fs
->group_desc_count
; i
++) {
37 last_blk
= group_blk
+ fs
->super
->s_blocks_per_group
;
40 * Allocate the block bitmap
42 retval
= ext2fs_get_free_blocks(fs
, group_blk
, last_blk
,
43 1, fs
->block_map
, &new_blk
);
46 ext2fs_mark_block_bitmap(fs
->block_map
, new_blk
);
47 fs
->group_desc
[i
].bg_block_bitmap
= new_blk
;
50 * ... and the inode bitmap
52 retval
= ext2fs_get_free_blocks(fs
, group_blk
, last_blk
,
53 1, fs
->block_map
, &new_blk
);
56 ext2fs_mark_block_bitmap(fs
->block_map
, new_blk
);
57 fs
->group_desc
[i
].bg_inode_bitmap
= new_blk
;
60 * Finally, allocate the inode table
62 retval
= ext2fs_get_free_blocks(fs
, group_blk
, last_blk
,
63 fs
->inode_blocks_per_group
,
64 fs
->block_map
, &new_blk
);
67 for (j
=0, blk
= new_blk
;
68 j
< fs
->inode_blocks_per_group
;
70 ext2fs_mark_block_bitmap(fs
->block_map
, blk
);
71 fs
->group_desc
[i
].bg_inode_table
= new_blk
;
74 * Increment the start of the block group
76 group_blk
+= fs
->super
->s_blocks_per_group
;