• Home
  • Raw
  • Download

Lines Matching +full:- +full:fs

2  * rw_bitmaps.c --- routines to read and write the  inode and block bitmaps.
6 * %Begin-Header%
9 * %End-Header%
31 static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) in write_bitmaps() argument
41 blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); in write_bitmaps()
44 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in write_bitmaps()
46 if (!(fs->flags & EXT2_FLAG_RW)) in write_bitmaps()
49 csum_flag = ext2fs_has_group_desc_csum(fs); in write_bitmaps()
53 block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; in write_bitmaps()
54 retval = io_channel_alloc_buf(fs->io, 0, &block_buf); in write_bitmaps()
57 memset(block_buf, 0xff, fs->blocksize); in write_bitmaps()
61 ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8); in write_bitmaps()
62 retval = io_channel_alloc_buf(fs->io, 0, &inode_buf); in write_bitmaps()
65 memset(inode_buf, 0xff, fs->blocksize); in write_bitmaps()
68 for (i = 0; i < fs->group_desc_count; i++) { in write_bitmaps()
72 if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) in write_bitmaps()
76 retval = ext2fs_get_block_bitmap_range2(fs->block_map, in write_bitmaps()
81 if (i == fs->group_desc_count - 1) { in write_bitmaps()
83 nbits = EXT2FS_NUM_B2C(fs, in write_bitmaps()
84 ((ext2fs_blocks_count(fs->super) in write_bitmaps()
85 - (__u64) fs->super->s_first_data_block) in write_bitmaps()
86 % (__u64) EXT2_BLOCKS_PER_GROUP(fs->super))); in write_bitmaps()
88 for (j = nbits; j < fs->blocksize * 8; j++) in write_bitmaps()
92 retval = ext2fs_block_bitmap_csum_set(fs, i, block_buf, in write_bitmaps()
96 ext2fs_group_desc_csum_set(fs, i); in write_bitmaps()
97 fs->flags |= EXT2_FLAG_DIRTY; in write_bitmaps()
99 blk = ext2fs_block_bitmap_loc(fs, i); in write_bitmaps()
101 retval = io_channel_write_blk64(fs->io, blk, 1, in write_bitmaps()
115 if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) in write_bitmaps()
119 retval = ext2fs_get_inode_bitmap_range2(fs->inode_map, in write_bitmaps()
124 retval = ext2fs_inode_bitmap_csum_set(fs, i, inode_buf, in write_bitmaps()
128 ext2fs_group_desc_csum_set(fs, i); in write_bitmaps()
129 fs->flags |= EXT2_FLAG_DIRTY; in write_bitmaps()
131 blk = ext2fs_inode_bitmap_loc(fs, i); in write_bitmaps()
133 retval = io_channel_write_blk64(fs->io, blk, 1, in write_bitmaps()
145 fs->flags &= ~EXT2_FLAG_BB_DIRTY; in write_bitmaps()
149 fs->flags &= ~EXT2_FLAG_IB_DIRTY; in write_bitmaps()
161 static errcode_t mark_uninit_bg_group_blocks(ext2_filsys fs) in mark_uninit_bg_group_blocks() argument
165 ext2fs_block_bitmap bmap = fs->block_map; in mark_uninit_bg_group_blocks()
167 for (i = 0; i < fs->group_desc_count; i++) { in mark_uninit_bg_group_blocks()
168 if (!ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) in mark_uninit_bg_group_blocks()
171 ext2fs_reserve_super_and_bgd(fs, i, bmap); in mark_uninit_bg_group_blocks()
176 blk = ext2fs_inode_table_loc(fs, i); in mark_uninit_bg_group_blocks()
179 fs->inode_blocks_per_group); in mark_uninit_bg_group_blocks()
184 blk = ext2fs_block_bitmap_loc(fs, i); in mark_uninit_bg_group_blocks()
191 blk = ext2fs_inode_bitmap_loc(fs, i); in mark_uninit_bg_group_blocks()
198 static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) in read_bitmaps() argument
204 int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; in read_bitmaps()
205 int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8; in read_bitmaps()
209 blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block); in read_bitmaps()
214 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in read_bitmaps()
216 if ((block_nbytes > (int) fs->blocksize) || in read_bitmaps()
217 (inode_nbytes > (int) fs->blocksize)) in read_bitmaps()
220 fs->write_bitmaps = ext2fs_write_bitmaps; in read_bitmaps()
222 csum_flag = ext2fs_has_group_desc_csum(fs); in read_bitmaps()
224 retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); in read_bitmaps()
228 if (fs->block_map) in read_bitmaps()
229 ext2fs_free_block_bitmap(fs->block_map); in read_bitmaps()
231 strcat(buf, fs->device_name); in read_bitmaps()
232 retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); in read_bitmaps()
235 retval = io_channel_alloc_buf(fs->io, 0, &block_bitmap); in read_bitmaps()
241 if (fs->inode_map) in read_bitmaps()
242 ext2fs_free_inode_bitmap(fs->inode_map); in read_bitmaps()
244 strcat(buf, fs->device_name); in read_bitmaps()
245 retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); in read_bitmaps()
248 retval = io_channel_alloc_buf(fs->io, 0, &inode_bitmap); in read_bitmaps()
255 if (fs->flags & EXT2_FLAG_IMAGE_FILE) { in read_bitmaps()
256 blk = (ext2fs_le32_to_cpu(fs->image_header->offset_inodemap) / fs->blocksize); in read_bitmaps()
257 ino_cnt = fs->super->s_inodes_count; in read_bitmaps()
259 retval = io_channel_read_blk64(fs->image_io, blk++, in read_bitmaps()
263 cnt = fs->blocksize << 3; in read_bitmaps()
266 retval = ext2fs_set_inode_bitmap_range2(fs->inode_map, in read_bitmaps()
271 ino_cnt -= cnt; in read_bitmaps()
273 blk = (ext2fs_le32_to_cpu(fs->image_header->offset_blockmap) / in read_bitmaps()
274 fs->blocksize); in read_bitmaps()
275 blk_cnt = EXT2_GROUPS_TO_CLUSTERS(fs->super, in read_bitmaps()
276 fs->group_desc_count); in read_bitmaps()
278 retval = io_channel_read_blk64(fs->image_io, blk++, in read_bitmaps()
282 cnt = fs->blocksize << 3; in read_bitmaps()
285 retval = ext2fs_set_block_bitmap_range2(fs->block_map, in read_bitmaps()
290 blk_cnt -= cnt; in read_bitmaps()
295 for (i = 0; i < fs->group_desc_count; i++) { in read_bitmaps()
297 blk = ext2fs_block_bitmap_loc(fs, i); in read_bitmaps()
299 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) && in read_bitmaps()
300 ext2fs_group_desc_csum_verify(fs, i)) in read_bitmaps()
303 retval = io_channel_read_blk64(fs->io, blk, in read_bitmaps()
310 if (!(fs->flags & in read_bitmaps()
312 !ext2fs_block_bitmap_csum_verify(fs, i, in read_bitmaps()
321 retval = ext2fs_set_block_bitmap_range2(fs->block_map, in read_bitmaps()
328 blk = ext2fs_inode_bitmap_loc(fs, i); in read_bitmaps()
330 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) && in read_bitmaps()
331 ext2fs_group_desc_csum_verify(fs, i)) in read_bitmaps()
334 retval = io_channel_read_blk64(fs->io, blk, in read_bitmaps()
342 if (!(fs->flags & in read_bitmaps()
344 !ext2fs_inode_bitmap_csum_verify(fs, i, in read_bitmaps()
353 retval = ext2fs_set_inode_bitmap_range2(fs->inode_map, in read_bitmaps()
363 retval = mark_uninit_bg_group_blocks(fs); in read_bitmaps()
377 ext2fs_free_mem(&fs->block_map); in read_bitmaps()
378 fs->block_map = 0; in read_bitmaps()
381 ext2fs_free_mem(&fs->inode_map); in read_bitmaps()
382 fs->inode_map = 0; in read_bitmaps()
393 errcode_t ext2fs_read_inode_bitmap(ext2_filsys fs) in ext2fs_read_inode_bitmap() argument
395 return read_bitmaps(fs, 1, 0); in ext2fs_read_inode_bitmap()
398 errcode_t ext2fs_read_block_bitmap(ext2_filsys fs) in ext2fs_read_block_bitmap() argument
400 return read_bitmaps(fs, 0, 1); in ext2fs_read_block_bitmap()
403 errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs) in ext2fs_write_inode_bitmap() argument
405 return write_bitmaps(fs, 1, 0); in ext2fs_write_inode_bitmap()
408 errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) in ext2fs_write_block_bitmap() argument
410 return write_bitmaps(fs, 0, 1); in ext2fs_write_block_bitmap()
413 errcode_t ext2fs_read_bitmaps(ext2_filsys fs) in ext2fs_read_bitmaps() argument
415 if (fs->inode_map && fs->block_map) in ext2fs_read_bitmaps()
418 return read_bitmaps(fs, !fs->inode_map, !fs->block_map); in ext2fs_read_bitmaps()
421 errcode_t ext2fs_write_bitmaps(ext2_filsys fs) in ext2fs_write_bitmaps() argument
423 int do_inode = fs->inode_map && ext2fs_test_ib_dirty(fs); in ext2fs_write_bitmaps()
424 int do_block = fs->block_map && ext2fs_test_bb_dirty(fs); in ext2fs_write_bitmaps()
429 return write_bitmaps(fs, do_inode, do_block); in ext2fs_write_bitmaps()