Lines Matching refs:fs
31 static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map, in check_block_uninit() argument
38 if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super, in check_block_uninit()
40 !(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT))) in check_block_uninit()
43 blk = ext2fs_group_first_block2(fs, group); in check_block_uninit()
45 ext2fs_super_and_bgd_loc2(fs, group, &super_blk, in check_block_uninit()
48 if (fs->super->s_feature_incompat & in check_block_uninit()
50 old_desc_blocks = fs->super->s_first_meta_bg; in check_block_uninit()
52 old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; in check_block_uninit()
54 for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) in check_block_uninit()
57 blk = ext2fs_group_first_block2(fs, group); in check_block_uninit()
58 for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) { in check_block_uninit()
64 (blk == ext2fs_block_bitmap_loc(fs, group)) || in check_block_uninit()
65 (blk == ext2fs_inode_bitmap_loc(fs, group)) || in check_block_uninit()
66 (blk >= ext2fs_inode_table_loc(fs, group) && in check_block_uninit()
67 (blk < ext2fs_inode_table_loc(fs, group) in check_block_uninit()
68 + fs->inode_blocks_per_group))) in check_block_uninit()
71 ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT); in check_block_uninit()
72 ext2fs_group_desc_csum_set(fs, group); in check_block_uninit()
73 ext2fs_mark_super_dirty(fs); in check_block_uninit()
74 ext2fs_mark_bb_dirty(fs); in check_block_uninit()
80 static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map, in check_inode_uninit() argument
85 if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super, in check_inode_uninit()
87 !(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT))) in check_inode_uninit()
90 ino = (group * fs->super->s_inodes_per_group) + 1; in check_inode_uninit()
91 for (i=0; i < fs->super->s_inodes_per_group; i++, ino++) in check_inode_uninit()
94 ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT); in check_inode_uninit()
95 ext2fs_group_desc_csum_set(fs, group); in check_inode_uninit()
96 ext2fs_mark_ib_dirty(fs); in check_inode_uninit()
97 ext2fs_mark_super_dirty(fs); in check_inode_uninit()
98 check_block_uninit(fs, fs->block_map, group); in check_inode_uninit()
107 errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, in ext2fs_new_inode() argument
116 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_new_inode()
119 map = fs->inode_map; in ext2fs_new_inode()
124 group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super); in ext2fs_new_inode()
125 start_inode = (group * EXT2_INODES_PER_GROUP(fs->super)) + 1; in ext2fs_new_inode()
127 if (start_inode < EXT2_FIRST_INODE(fs->super)) in ext2fs_new_inode()
128 start_inode = EXT2_FIRST_INODE(fs->super); in ext2fs_new_inode()
129 if (start_inode > fs->super->s_inodes_count) in ext2fs_new_inode()
133 ino_in_group = (i - 1) % EXT2_INODES_PER_GROUP(fs->super); in ext2fs_new_inode()
134 group = (i - 1) / EXT2_INODES_PER_GROUP(fs->super); in ext2fs_new_inode()
136 check_inode_uninit(fs, map, group); in ext2fs_new_inode()
137 upto = i + (EXT2_INODES_PER_GROUP(fs->super) - ino_in_group); in ext2fs_new_inode()
140 if (upto > fs->super->s_inodes_count) in ext2fs_new_inode()
141 upto = fs->super->s_inodes_count; in ext2fs_new_inode()
152 if (i > fs->super->s_inodes_count) in ext2fs_new_inode()
153 i = EXT2_FIRST_INODE(fs->super); in ext2fs_new_inode()
166 errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal, in ext2fs_new_block2() argument
172 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_new_block2()
175 map = fs->block_map; in ext2fs_new_block2()
178 if (!goal || (goal >= ext2fs_blocks_count(fs->super))) in ext2fs_new_block2()
179 goal = fs->super->s_first_data_block; in ext2fs_new_block2()
183 goal &= ~EXT2FS_CLUSTER_MASK(fs); in ext2fs_new_block2()
184 check_block_uninit(fs, map, in ext2fs_new_block2()
185 (i - fs->super->s_first_data_block) / in ext2fs_new_block2()
186 EXT2_BLOCKS_PER_GROUP(fs->super)); in ext2fs_new_block2()
188 if (((i - fs->super->s_first_data_block) % in ext2fs_new_block2()
189 EXT2_BLOCKS_PER_GROUP(fs->super)) == 0) in ext2fs_new_block2()
190 check_block_uninit(fs, map, in ext2fs_new_block2()
191 (i - fs->super->s_first_data_block) / in ext2fs_new_block2()
192 EXT2_BLOCKS_PER_GROUP(fs->super)); in ext2fs_new_block2()
199 if (i >= ext2fs_blocks_count(fs->super)) in ext2fs_new_block2()
200 i = fs->super->s_first_data_block; in ext2fs_new_block2()
205 errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, in ext2fs_new_block() argument
210 retval = ext2fs_new_block2(fs, goal, map, &val); in ext2fs_new_block()
220 errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal, in ext2fs_alloc_block2() argument
228 retval = ext2fs_get_mem(fs->blocksize, &buf); in ext2fs_alloc_block2()
233 memset(block_buf, 0, fs->blocksize); in ext2fs_alloc_block2()
235 if (fs->get_alloc_block) { in ext2fs_alloc_block2()
236 retval = (fs->get_alloc_block)(fs, goal, &block); in ext2fs_alloc_block2()
240 if (!fs->block_map) { in ext2fs_alloc_block2()
241 retval = ext2fs_read_block_bitmap(fs); in ext2fs_alloc_block2()
246 retval = ext2fs_new_block2(fs, goal, 0, &block); in ext2fs_alloc_block2()
251 retval = io_channel_write_blk64(fs->io, block, 1, block_buf); in ext2fs_alloc_block2()
255 ext2fs_block_alloc_stats2(fs, block, +1); in ext2fs_alloc_block2()
264 errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, in ext2fs_alloc_block() argument
269 retval = ext2fs_alloc_block2(fs, goal, block_buf, &val); in ext2fs_alloc_block()
275 errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish, in ext2fs_get_free_blocks2() argument
281 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_get_free_blocks2()
284 map = fs->block_map; in ext2fs_get_free_blocks2()
288 b = fs->super->s_first_data_block; in ext2fs_get_free_blocks2()
297 if (b+num-1 > ext2fs_blocks_count(fs->super)) in ext2fs_get_free_blocks2()
298 b = fs->super->s_first_data_block; in ext2fs_get_free_blocks2()
308 errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish, in ext2fs_get_free_blocks() argument
313 retval = ext2fs_get_free_blocks2(fs, start, finish, num, map, &val); in ext2fs_get_free_blocks()
319 void ext2fs_set_alloc_block_callback(ext2_filsys fs, in ext2fs_set_alloc_block_callback() argument
320 errcode_t (*func)(ext2_filsys fs, in ext2fs_set_alloc_block_callback() argument
323 errcode_t (**old)(ext2_filsys fs, in ext2fs_set_alloc_block_callback() argument
327 if (!fs || fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS) in ext2fs_set_alloc_block_callback()
331 *old = fs->get_alloc_block; in ext2fs_set_alloc_block_callback()
333 fs->get_alloc_block = func; in ext2fs_set_alloc_block_callback()