Lines Matching refs:fs

45 	(struct ext2_block_group *bg, const struct ext_filesystem *fs)  in ext4fs_bg_free_inodes_inc()  argument
48 if (fs->gdsize == 64) in ext4fs_bg_free_inodes_inc()
53 if (fs->gdsize == 64) in ext4fs_bg_free_inodes_inc()
58 (struct ext2_block_group *bg, const struct ext_filesystem *fs) in ext4fs_bg_free_blocks_inc() argument
61 if (fs->gdsize == 64) in ext4fs_bg_free_blocks_inc()
66 if (fs->gdsize == 64) in ext4fs_bg_free_blocks_inc()
74 struct ext_filesystem *fs = get_fs(); in ext4fs_update() local
79 (struct ext2_sblock *)fs->sb, (uint32_t)SUPERBLOCK_SIZE); in ext4fs_update()
82 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_update()
83 bgd = ext4fs_get_group_descriptor(fs, i); in ext4fs_update()
85 uint64_t b_bitmap_blk = ext4fs_bg_get_block_id(bgd, fs); in ext4fs_update()
86 put_ext4(b_bitmap_blk * fs->blksz, in ext4fs_update()
87 fs->blk_bmaps[i], fs->blksz); in ext4fs_update()
91 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_update()
92 bgd = ext4fs_get_group_descriptor(fs, i); in ext4fs_update()
93 uint64_t i_bitmap_blk = ext4fs_bg_get_inode_id(bgd, fs); in ext4fs_update()
94 put_ext4(i_bitmap_blk * fs->blksz, in ext4fs_update()
95 fs->inode_bmaps[i], fs->blksz); in ext4fs_update()
99 put_ext4((uint64_t)((uint64_t)fs->gdtable_blkno * (uint64_t)fs->blksz), in ext4fs_update()
100 (struct ext2_block_group *)fs->gdtable, in ext4fs_update()
101 (fs->blksz * fs->no_blk_pergdt)); in ext4fs_update()
112 struct ext_filesystem *fs = get_fs(); in ext4fs_get_bgdtable() local
113 int gdsize_total = ROUND(fs->no_blkgrp * fs->gdsize, fs->blksz); in ext4fs_get_bgdtable()
114 fs->no_blk_pergdt = gdsize_total / fs->blksz; in ext4fs_get_bgdtable()
117 fs->gdtable = zalloc(gdsize_total); in ext4fs_get_bgdtable()
118 if (!fs->gdtable) in ext4fs_get_bgdtable()
121 status = ext4fs_devread((lbaint_t)fs->gdtable_blkno * fs->sect_perblk, in ext4fs_get_bgdtable()
122 0, fs->blksz * fs->no_blk_pergdt, fs->gdtable); in ext4fs_get_bgdtable()
126 if (ext4fs_log_gdt(fs->gdtable)) { in ext4fs_get_bgdtable()
133 free(fs->gdtable); in ext4fs_get_bgdtable()
134 fs->gdtable = NULL; in ext4fs_get_bgdtable()
148 struct ext_filesystem *fs = get_fs(); in delete_single_indirect_block() local
149 char *journal_buffer = zalloc(fs->blksz); in delete_single_indirect_block()
160 if (fs->blksz == 1024) { in delete_single_indirect_block()
165 ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], bg_idx); in delete_single_indirect_block()
167 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in delete_single_indirect_block()
168 ext4fs_bg_free_blocks_inc(bgd, fs); in delete_single_indirect_block()
169 ext4fs_sb_free_blocks_inc(fs->sb); in delete_single_indirect_block()
172 uint64_t b_bitmap_blk = ext4fs_bg_get_block_id(bgd, fs); in delete_single_indirect_block()
174 b_bitmap_blk * fs->sect_perblk, in delete_single_indirect_block()
175 0, fs->blksz, journal_buffer); in delete_single_indirect_block()
199 struct ext_filesystem *fs = get_fs(); in delete_double_indirect_block() local
200 char *journal_buffer = zalloc(fs->blksz); in delete_double_indirect_block()
207 di_buffer = zalloc(fs->blksz); in delete_double_indirect_block()
214 status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, in delete_double_indirect_block()
215 fs->blksz, (char *)di_buffer); in delete_double_indirect_block()
216 for (i = 0; i < fs->blksz / sizeof(int); i++) { in delete_double_indirect_block()
222 if (fs->blksz == 1024) { in delete_double_indirect_block()
228 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in delete_double_indirect_block()
230 fs->blk_bmaps[bg_idx], bg_idx); in delete_double_indirect_block()
232 ext4fs_bg_free_blocks_inc(bgd, fs); in delete_double_indirect_block()
233 ext4fs_sb_free_blocks_inc(fs->sb); in delete_double_indirect_block()
237 ext4fs_bg_get_block_id(bgd, fs); in delete_double_indirect_block()
239 * fs->sect_perblk, 0, in delete_double_indirect_block()
240 fs->blksz, in delete_double_indirect_block()
255 if (fs->blksz == 1024) { in delete_double_indirect_block()
261 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in delete_double_indirect_block()
262 ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], bg_idx); in delete_double_indirect_block()
263 ext4fs_bg_free_blocks_inc(bgd, fs); in delete_double_indirect_block()
264 ext4fs_sb_free_blocks_inc(fs->sb); in delete_double_indirect_block()
267 uint64_t b_bitmap_blk = ext4fs_bg_get_block_id(bgd, fs); in delete_double_indirect_block()
268 status = ext4fs_devread(b_bitmap_blk * fs->sect_perblk, in delete_double_indirect_block()
269 0, fs->blksz, journal_buffer); in delete_double_indirect_block()
298 struct ext_filesystem *fs = get_fs(); in delete_triple_indirect_block() local
299 char *journal_buffer = zalloc(fs->blksz); in delete_triple_indirect_block()
306 tigp_buffer = zalloc(fs->blksz); in delete_triple_indirect_block()
313 status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, in delete_triple_indirect_block()
314 fs->blksz, (char *)tigp_buffer); in delete_triple_indirect_block()
315 for (i = 0; i < fs->blksz / sizeof(int); i++) { in delete_triple_indirect_block()
320 tip_buffer = zalloc(fs->blksz); in delete_triple_indirect_block()
325 fs->sect_perblk, 0, fs->blksz, in delete_triple_indirect_block()
327 for (j = 0; j < fs->blksz / sizeof(int); j++) { in delete_triple_indirect_block()
331 if (fs->blksz == 1024) { in delete_triple_indirect_block()
338 fs->blk_bmaps[bg_idx], in delete_triple_indirect_block()
343 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in delete_triple_indirect_block()
344 ext4fs_bg_free_blocks_inc(bgd, fs); in delete_triple_indirect_block()
345 ext4fs_sb_free_blocks_inc(fs->sb); in delete_triple_indirect_block()
349 ext4fs_bg_get_block_id(bgd, fs); in delete_triple_indirect_block()
353 fs->sect_perblk, 0, in delete_triple_indirect_block()
354 fs->blksz, in delete_triple_indirect_block()
373 if (fs->blksz == 1024) { in delete_triple_indirect_block()
379 fs->blk_bmaps[bg_idx], bg_idx); in delete_triple_indirect_block()
383 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in delete_triple_indirect_block()
384 ext4fs_bg_free_blocks_inc(bgd, fs); in delete_triple_indirect_block()
385 ext4fs_sb_free_blocks_inc(fs->sb); in delete_triple_indirect_block()
389 ext4fs_bg_get_block_id(bgd, fs); in delete_triple_indirect_block()
390 memset(journal_buffer, '\0', fs->blksz); in delete_triple_indirect_block()
392 fs->sect_perblk, 0, in delete_triple_indirect_block()
393 fs->blksz, in delete_triple_indirect_block()
408 if (fs->blksz == 1024) { in delete_triple_indirect_block()
413 ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], bg_idx); in delete_triple_indirect_block()
415 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in delete_triple_indirect_block()
416 ext4fs_bg_free_blocks_inc(bgd, fs); in delete_triple_indirect_block()
417 ext4fs_sb_free_blocks_inc(fs->sb); in delete_triple_indirect_block()
420 uint64_t b_bitmap_blk = ext4fs_bg_get_block_id(bgd, fs); in delete_triple_indirect_block()
421 status = ext4fs_devread(b_bitmap_blk * fs->sect_perblk, in delete_triple_indirect_block()
422 0, fs->blksz, journal_buffer); in delete_triple_indirect_block()
459 struct ext_filesystem *fs = get_fs(); in ext4fs_delete_file() local
460 char *journal_buffer = zalloc(fs->blksz); in ext4fs_delete_file()
468 no_blocks = le32_to_cpu(inode.size) / fs->blksz; in ext4fs_delete_file()
469 if (le32_to_cpu(inode.size) % fs->blksz) in ext4fs_delete_file()
501 if (fs->blksz == 1024) { in ext4fs_delete_file()
506 ext4fs_reset_block_bmap(blknr, fs->blk_bmaps[bg_idx], in ext4fs_delete_file()
511 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in ext4fs_delete_file()
512 ext4fs_bg_free_blocks_inc(bgd, fs); in ext4fs_delete_file()
513 ext4fs_sb_free_blocks_inc(fs->sb); in ext4fs_delete_file()
516 uint64_t b_bitmap_blk = ext4fs_bg_get_block_id(bgd, fs); in ext4fs_delete_file()
517 status = ext4fs_devread(b_bitmap_blk * fs->sect_perblk, in ext4fs_delete_file()
518 0, fs->blksz, in ext4fs_delete_file()
530 inodes_per_block = fs->blksz / fs->inodesz; in ext4fs_delete_file()
536 bgd = ext4fs_get_group_descriptor(fs, ibmap_idx); in ext4fs_delete_file()
537 blkno = ext4fs_bg_get_inode_table_id(bgd, fs) + in ext4fs_delete_file()
541 blkoff = ((inodeno) % inodes_per_block) * fs->inodesz; in ext4fs_delete_file()
544 read_buffer = zalloc(fs->blksz); in ext4fs_delete_file()
548 status = ext4fs_devread((lbaint_t)blkno * fs->sect_perblk, in ext4fs_delete_file()
549 0, fs->blksz, read_buffer); in ext4fs_delete_file()
558 memset(inode_buffer, '\0', fs->inodesz); in ext4fs_delete_file()
566 ext4fs_reset_inode_bmap(inodeno, fs->inode_bmaps[ibmap_idx], ibmap_idx); in ext4fs_delete_file()
567 ext4fs_bg_free_inodes_inc(bgd, fs); in ext4fs_delete_file()
568 ext4fs_sb_free_inodes_inc(fs->sb); in ext4fs_delete_file()
570 memset(journal_buffer, '\0', fs->blksz); in ext4fs_delete_file()
571 status = ext4fs_devread(ext4fs_bg_get_inode_id(bgd, fs) * in ext4fs_delete_file()
572 fs->sect_perblk, 0, fs->blksz, journal_buffer); in ext4fs_delete_file()
575 if (ext4fs_log_journal(journal_buffer, ext4fs_bg_get_inode_id(bgd, fs))) in ext4fs_delete_file()
603 struct ext_filesystem *fs = get_fs(); in ext4fs_init() local
606 fs->blksz = EXT2_BLOCK_SIZE(ext4fs_root); in ext4fs_init()
607 fs->sect_perblk = fs->blksz >> fs->dev_desc->log2blksz; in ext4fs_init()
610 fs->sb = zalloc(SUPERBLOCK_SIZE); in ext4fs_init()
611 if (!fs->sb) in ext4fs_init()
613 if (!ext4_read_superblock((char *)fs->sb)) in ext4fs_init()
621 fs->no_blkgrp = (uint32_t)ext4fs_div_roundup( in ext4fs_init()
627 fs->gdtable_blkno = ((EXT2_MIN_BLOCK_SIZE == fs->blksz) + 1); in ext4fs_init()
634 fs->blk_bmaps = zalloc(fs->no_blkgrp * sizeof(char *)); in ext4fs_init()
635 if (!fs->blk_bmaps) in ext4fs_init()
637 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_init()
638 fs->blk_bmaps[i] = zalloc(fs->blksz); in ext4fs_init()
639 if (!fs->blk_bmaps[i]) in ext4fs_init()
643 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_init()
645 ext4fs_get_group_descriptor(fs, i); in ext4fs_init()
646 status = ext4fs_devread(ext4fs_bg_get_block_id(bgd, fs) * in ext4fs_init()
647 fs->sect_perblk, 0, in ext4fs_init()
648 fs->blksz, (char *)fs->blk_bmaps[i]); in ext4fs_init()
654 fs->inode_bmaps = zalloc(fs->no_blkgrp * sizeof(unsigned char *)); in ext4fs_init()
655 if (!fs->inode_bmaps) in ext4fs_init()
657 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_init()
658 fs->inode_bmaps[i] = zalloc(fs->blksz); in ext4fs_init()
659 if (!fs->inode_bmaps[i]) in ext4fs_init()
663 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_init()
665 ext4fs_get_group_descriptor(fs, i); in ext4fs_init()
666 status = ext4fs_devread(ext4fs_bg_get_inode_id(bgd, fs) * in ext4fs_init()
667 fs->sect_perblk, in ext4fs_init()
668 0, fs->blksz, in ext4fs_init()
669 (char *)fs->inode_bmaps[i]); in ext4fs_init()
680 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_init()
682 ext4fs_get_group_descriptor(fs, i); in ext4fs_init()
684 ext4fs_bg_get_free_blocks(bgd, fs); in ext4fs_init()
686 if (real_free_blocks != ext4fs_sb_get_free_blocks(fs->sb)) in ext4fs_init()
687 ext4fs_sb_set_free_blocks(fs->sb, real_free_blocks); in ext4fs_init()
702 struct ext_filesystem *fs = get_fs(); in ext4fs_deinit() local
706 char *temp_buff = zalloc(fs->blksz); in ext4fs_deinit()
712 ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz, in ext4fs_deinit()
716 put_ext4((uint64_t) ((uint64_t)blknr * (uint64_t)fs->blksz), in ext4fs_deinit()
717 (struct journal_superblock_t *)temp_buff, fs->blksz); in ext4fs_deinit()
723 ext4_read_superblock((char *)fs->sb); in ext4fs_deinit()
724 new_feature_incompat = le32_to_cpu(fs->sb->feature_incompat); in ext4fs_deinit()
726 fs->sb->feature_incompat = cpu_to_le32(new_feature_incompat); in ext4fs_deinit()
728 (struct ext2_sblock *)fs->sb, (uint32_t)SUPERBLOCK_SIZE); in ext4fs_deinit()
729 free(fs->sb); in ext4fs_deinit()
730 fs->sb = NULL; in ext4fs_deinit()
732 if (fs->blk_bmaps) { in ext4fs_deinit()
733 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_deinit()
734 free(fs->blk_bmaps[i]); in ext4fs_deinit()
735 fs->blk_bmaps[i] = NULL; in ext4fs_deinit()
737 free(fs->blk_bmaps); in ext4fs_deinit()
738 fs->blk_bmaps = NULL; in ext4fs_deinit()
741 if (fs->inode_bmaps) { in ext4fs_deinit()
742 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_deinit()
743 free(fs->inode_bmaps[i]); in ext4fs_deinit()
744 fs->inode_bmaps[i] = NULL; in ext4fs_deinit()
746 free(fs->inode_bmaps); in ext4fs_deinit()
747 fs->inode_bmaps = NULL; in ext4fs_deinit()
751 free(fs->gdtable); in ext4fs_deinit()
752 fs->gdtable = NULL; in ext4fs_deinit()
757 fs->first_pass_ibmap = 0; in ext4fs_deinit()
758 fs->first_pass_bbmap = 0; in ext4fs_deinit()
759 fs->curr_inode_no = 0; in ext4fs_deinit()
760 fs->curr_blkno = 0; in ext4fs_deinit()
773 struct ext_filesystem *fs = get_fs(); in ext4fs_write_file() local
774 int log2blksz = fs->dev_desc->log2blksz; in ext4fs_write_file()
786 blockcnt = ((len + pos) + fs->blksz - 1) / fs->blksz; in ext4fs_write_file()
788 for (i = pos / fs->blksz; i < blockcnt; i++) { in ext4fs_write_file()
790 int blockend = fs->blksz; in ext4fs_write_file()
833 buf += fs->blksz - skipfirst; in ext4fs_write_file()
867 struct ext_filesystem *fs = get_fs(); in ext4fs_write() local
875 g_parent_inode = zalloc(fs->inodesz); in ext4fs_write()
884 if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) { in ext4fs_write()
889 inodes_per_block = fs->blksz / fs->inodesz; in ext4fs_write()
904 fs->first_pass_bbmap = 0; in ext4fs_write()
905 fs->curr_blkno = 0; in ext4fs_write()
907 fs->first_pass_ibmap = 0; in ext4fs_write()
908 fs->curr_inode_no = 0; in ext4fs_write()
922 blks_reqd_for_file = lldiv(bytes_reqd_for_file, fs->blksz); in ext4fs_write()
923 if (do_div(bytes_reqd_for_file, fs->blksz) != 0) { in ext4fs_write()
929 if (le32_to_cpu(fs->sb->free_blocks) < blks_reqd_for_file) { in ext4fs_write()
938 inode_buffer = zalloc(fs->inodesz); in ext4fs_write()
963 file_inode->blockcnt = cpu_to_le32((blks_reqd_for_file * fs->blksz) >> in ext4fs_write()
966 temp_ptr = zalloc(fs->blksz); in ext4fs_write()
971 bgd = ext4fs_get_group_descriptor(fs, ibmap_idx); in ext4fs_write()
972 itable_blkno = ext4fs_bg_get_inode_table_id(bgd, fs) + in ext4fs_write()
975 blkoff = (inodeno % inodes_per_block) * fs->inodesz; in ext4fs_write()
976 ext4fs_devread((lbaint_t)itable_blkno * fs->sect_perblk, 0, fs->blksz, in ext4fs_write()
981 memcpy(temp_ptr + blkoff, inode_buffer, fs->inodesz); in ext4fs_write()
992 bgd = ext4fs_get_group_descriptor(fs, ibmap_idx); in ext4fs_write()
993 parent_itable_blkno = ext4fs_bg_get_inode_table_id(bgd, fs) + in ext4fs_write()
996 blkoff = (parent_inodeno % inodes_per_block) * fs->inodesz; in ext4fs_write()
998 memset(temp_ptr, '\0', fs->blksz); in ext4fs_write()
999 ext4fs_devread((lbaint_t)parent_itable_blkno * fs->sect_perblk, in ext4fs_write()
1000 0, fs->blksz, temp_ptr); in ext4fs_write()
1004 memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz); in ext4fs_write()
1012 memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz); in ext4fs_write()
1020 fs->first_pass_bbmap = 0; in ext4fs_write()
1021 fs->curr_blkno = 0; in ext4fs_write()
1022 fs->first_pass_ibmap = 0; in ext4fs_write()
1023 fs->curr_inode_no = 0; in ext4fs_write()