Lines Matching refs:fs
62 errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags) in ext2fs_image_inode_write() argument
71 buf = malloc(fs->blocksize * BUF_BLOCKS); in ext2fs_image_inode_write()
75 for (group = 0; group < fs->group_desc_count; group++) { in ext2fs_image_inode_write()
76 blk = ext2fs_inode_table_loc(fs, (unsigned)group); in ext2fs_image_inode_write()
81 left = fs->inode_blocks_per_group; in ext2fs_image_inode_write()
86 retval = io_channel_read_blk64(fs->io, blk, c, buf); in ext2fs_image_inode_write()
96 if (check_zero_block(cp, fs->blocksize)) { in ext2fs_image_inode_write()
100 cp += fs->blocksize; in ext2fs_image_inode_write()
101 r = ext2fs_llseek(fd, fs->blocksize, in ext2fs_image_inode_write()
111 if (check_zero_block(cp + d*fs->blocksize, fs->blocksize)) in ext2fs_image_inode_write()
115 actual = write(fd, cp, fs->blocksize * d); in ext2fs_image_inode_write()
120 if (actual != (ssize_t) (fs->blocksize * d)) { in ext2fs_image_inode_write()
126 cp += fs->blocksize * d; in ext2fs_image_inode_write()
141 errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, in ext2fs_image_inode_read() argument
150 buf = malloc(fs->blocksize * BUF_BLOCKS); in ext2fs_image_inode_read()
154 for (group = 0; group < fs->group_desc_count; group++) { in ext2fs_image_inode_read()
155 blk = ext2fs_inode_table_loc(fs, (unsigned)group); in ext2fs_image_inode_read()
160 left = fs->inode_blocks_per_group; in ext2fs_image_inode_read()
165 actual = read(fd, buf, fs->blocksize * c); in ext2fs_image_inode_read()
170 if (actual != (ssize_t) (fs->blocksize * c)) { in ext2fs_image_inode_read()
174 retval = io_channel_write_blk64(fs->io, blk, c, buf); in ext2fs_image_inode_read()
182 retval = ext2fs_flush_icache(fs); in ext2fs_image_inode_read()
192 errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, in ext2fs_image_super_write() argument
204 buf = malloc(fs->blocksize); in ext2fs_image_super_write()
211 memset(buf, 0, fs->blocksize); in ext2fs_image_super_write()
217 ext2fs_swap_super(fs->super); in ext2fs_image_super_write()
218 memcpy(buf, fs->super, SUPERBLOCK_SIZE); in ext2fs_image_super_write()
219 ext2fs_swap_super(fs->super); in ext2fs_image_super_write()
221 memcpy(buf, fs->super, SUPERBLOCK_SIZE); in ext2fs_image_super_write()
223 actual = write(fd, buf, fs->blocksize); in ext2fs_image_super_write()
228 if (actual != (ssize_t) fs->blocksize) { in ext2fs_image_super_write()
237 cp = (char *) fs->group_desc; in ext2fs_image_super_write()
244 groups_per_block = EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_image_super_write()
246 for (j=0; j < groups_per_block*fs->desc_blocks; j++) { in ext2fs_image_super_write()
247 gdp = ext2fs_group_desc(fs, fs->group_desc, j); in ext2fs_image_super_write()
248 ext2fs_swap_group_desc2(fs, gdp); in ext2fs_image_super_write()
252 actual = write(fd, cp, fs->blocksize * fs->desc_blocks); in ext2fs_image_super_write()
256 groups_per_block = EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_image_super_write()
258 for (j=0; j < groups_per_block*fs->desc_blocks; j++) { in ext2fs_image_super_write()
259 gdp = ext2fs_group_desc(fs, fs->group_desc, j); in ext2fs_image_super_write()
260 ext2fs_swap_group_desc2(fs, gdp); in ext2fs_image_super_write()
268 if (actual != (ssize_t) (fs->blocksize * fs->desc_blocks)) { in ext2fs_image_super_write()
283 errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, in ext2fs_image_super_read() argument
290 size = fs->blocksize * (fs->group_desc_count + 1); in ext2fs_image_super_read()
311 memcpy(fs->super, buf, SUPERBLOCK_SIZE); in ext2fs_image_super_read()
313 memcpy(fs->group_desc, buf + fs->blocksize, in ext2fs_image_super_read()
314 fs->blocksize * fs->group_desc_count); in ext2fs_image_super_read()
326 errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags) in ext2fs_image_bitmap_write() argument
336 if (!fs->inode_map) { in ext2fs_image_bitmap_write()
337 retval = ext2fs_read_inode_bitmap(fs); in ext2fs_image_bitmap_write()
341 bmap = fs->inode_map; in ext2fs_image_bitmap_write()
343 cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count; in ext2fs_image_bitmap_write()
344 size = (EXT2_INODES_PER_GROUP(fs->super) / 8); in ext2fs_image_bitmap_write()
346 if (!fs->block_map) { in ext2fs_image_bitmap_write()
347 retval = ext2fs_read_block_bitmap(fs); in ext2fs_image_bitmap_write()
351 bmap = fs->block_map; in ext2fs_image_bitmap_write()
352 itr = fs->super->s_first_data_block; in ext2fs_image_bitmap_write()
353 cnt = EXT2_GROUPS_TO_CLUSTERS(fs->super, fs->group_desc_count); in ext2fs_image_bitmap_write()
354 size = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8; in ext2fs_image_bitmap_write()
356 total_size = size * fs->group_desc_count; in ext2fs_image_bitmap_write()
378 size = total_size % fs->blocksize; in ext2fs_image_bitmap_write()
381 size = fs->blocksize - size; in ext2fs_image_bitmap_write()
401 errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags) in ext2fs_image_bitmap_read() argument
411 if (!fs->inode_map) { in ext2fs_image_bitmap_read()
412 retval = ext2fs_read_inode_bitmap(fs); in ext2fs_image_bitmap_read()
416 bmap = fs->inode_map; in ext2fs_image_bitmap_read()
418 cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count; in ext2fs_image_bitmap_read()
419 size = (EXT2_INODES_PER_GROUP(fs->super) / 8); in ext2fs_image_bitmap_read()
421 if (!fs->block_map) { in ext2fs_image_bitmap_read()
422 retval = ext2fs_read_block_bitmap(fs); in ext2fs_image_bitmap_read()
426 bmap = fs->block_map; in ext2fs_image_bitmap_read()
427 itr = fs->super->s_first_data_block; in ext2fs_image_bitmap_read()
428 cnt = EXT2_GROUPS_TO_BLOCKS(fs->super, fs->group_desc_count); in ext2fs_image_bitmap_read()
429 size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8; in ext2fs_image_bitmap_read()