Home | History | Annotate | Download | only in ext2fs

Lines Matching refs:fs

31 static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
38 if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
40 !(fs->group_desc[group].bg_flags & EXT2_BG_BLOCK_UNINIT))
43 blk = (group * fs->super->s_blocks_per_group) +
44 fs->super->s_first_data_block;
46 ext2fs_super_and_bgd_loc(fs, group, &super_blk,
49 if (fs->super->s_feature_incompat &
51 old_desc_blocks = fs->super->s_first_meta_bg;
53 old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
55 for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) {
61 (blk == fs->group_desc[group].bg_block_bitmap) ||
62 (blk == fs->group_desc[group].bg_inode_bitmap) ||
63 (blk >= fs->group_desc[group].bg_inode_table &&
64 (blk < fs->group_desc[group].bg_inode_table
65 + fs->inode_blocks_per_group)))
70 fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
71 ext2fs_group_desc_csum_set(fs, group);
77 static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
82 if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
84 !(fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT))
87 ino = (group * fs->super->s_inodes_per_group) + 1;
88 for (i=0; i < fs->super->s_inodes_per_group; i++, ino++)
91 fs->group_desc[group].bg_flags &= ~EXT2_BG_INODE_UNINIT;
92 check_block_uninit(fs, fs->block_map, group);
101 errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir,
109 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
112 map = fs->inode_map;
117 dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super);
119 start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->super)) + 1;
120 if (start_inode < EXT2_FIRST_INODE(fs->super))
121 start_inode = EXT2_FIRST_INODE(fs->super);
122 if (start_inode > fs->super->s_inodes_count)
127 if (((i - 1) % EXT2_INODES_PER_GROUP(fs->super)) == 0)
128 check_inode_uninit(fs, map, (i - 1) /
129 EXT2_INODES_PER_GROUP(fs->super));
134 if (i > fs->super->s_inodes_count)
135 i = EXT2_FIRST_INODE(fs->super);
148 errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
153 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
156 map = fs->block_map;
159 if (!goal || (goal >= fs->super->s_blocks_count))
160 goal = fs->super->s_first_data_block;
162 check_block_uninit(fs, map,
163 (i - fs->super->s_first_data_block) /
164 EXT2_BLOCKS_PER_GROUP(fs->super));
166 if (((i - fs->super->s_first_data_block) %
167 EXT2_BLOCKS_PER_GROUP(fs->super)) == 0)
168 check_block_uninit(fs, map,
169 (i - fs->super->s_first_data_block) /
170 EXT2_BLOCKS_PER_GROUP(fs->super));
177 if (i >= fs->super->s_blocks_count)
178 i = fs->super->s_first_data_block;
187 errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
195 retval = ext2fs_get_mem(fs->blocksize, &buf);
200 memset(block_buf, 0, fs->blocksize);
202 if (fs->get_alloc_block) {
205 retval = (fs->get_alloc_block)(fs, (blk64_t) goal, &new);
210 if (!fs->block_map) {
211 retval = ext2fs_read_block_bitmap(fs);
216 retval = ext2fs_new_block(fs, goal, 0, &block);
221 retval = io_channel_write_blk(fs->io, block, 1, block_buf);
225 ext2fs_block_alloc_stats(fs, block, +1);
234 errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish,
239 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
242 map = fs->block_map;
246 b = fs->super->s_first_data_block;
252 if (b+num-1 > fs->super->s_blocks_count)
253 b = fs->super->s_first_data_block;
263 void ext2fs_set_alloc_block_callback(ext2_filsys fs,
264 errcode_t (*func)(ext2_filsys fs,
267 errcode_t (**old)(ext2_filsys fs,
271 if (!fs || fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS)
275 *old = fs->get_alloc_block;
277 fs->get_alloc_block = func;