Lines Matching full:fs

13  * based on code from grub2 fs/ext2.c and fs/fshelp.c by
51 (const struct ext_filesystem *fs, uint32_t bg_idx) in ext4fs_get_group_descriptor() argument
53 return (struct ext2_block_group *)(fs->gdtable + (bg_idx * fs->gdsize)); in ext4fs_get_group_descriptor()
72 (struct ext2_block_group *bg, const struct ext_filesystem *fs) in ext4fs_bg_free_inodes_dec() argument
75 if (fs->gdsize == 64) in ext4fs_bg_free_inodes_dec()
80 if (fs->gdsize == 64) in ext4fs_bg_free_inodes_dec()
85 (struct ext2_block_group *bg, const struct ext_filesystem *fs) in ext4fs_bg_free_blocks_dec() argument
88 if (fs->gdsize == 64) in ext4fs_bg_free_blocks_dec()
93 if (fs->gdsize == 64) in ext4fs_bg_free_blocks_dec()
98 (struct ext2_block_group *bg, const struct ext_filesystem *fs) in ext4fs_bg_itable_unused_dec() argument
101 if (fs->gdsize == 64) in ext4fs_bg_itable_unused_dec()
106 if (fs->gdsize == 64) in ext4fs_bg_itable_unused_dec()
124 const struct ext_filesystem *fs) in ext4fs_bg_get_free_blocks() argument
127 if (fs->gdsize == 64) in ext4fs_bg_get_free_blocks()
134 const struct ext_filesystem *fs) in ext4fs_bg_get_free_inodes() argument
137 if (fs->gdsize == 64) in ext4fs_bg_get_free_inodes()
155 const struct ext_filesystem *fs) in ext4fs_bg_get_block_id() argument
158 if (fs->gdsize == 64) in ext4fs_bg_get_block_id()
165 const struct ext_filesystem *fs) in ext4fs_bg_get_inode_id() argument
168 if (fs->gdsize == 64) in ext4fs_bg_get_inode_id()
176 const struct ext_filesystem *fs) in ext4fs_bg_get_inode_table_id() argument
179 if (fs->gdsize == 64) in ext4fs_bg_get_inode_table_id()
200 struct ext_filesystem *fs = get_fs(); in put_ext4() local
201 int log2blksz = fs->dev_desc->log2blksz; in put_ext4()
202 ALLOC_CACHE_ALIGN_BUFFER(unsigned char, sec_buf, fs->dev_desc->blksz); in put_ext4()
206 remainder = off & (uint64_t)(fs->dev_desc->blksz - 1); in put_ext4()
208 if (fs->dev_desc == NULL) in put_ext4()
212 (part_offset + fs->total_sect)) { in put_ext4()
214 printf("total_sector is %" PRIu64 "\n", fs->total_sect); in put_ext4()
220 blk_dread(fs->dev_desc, startblock, 1, sec_buf); in put_ext4()
223 blk_dwrite(fs->dev_desc, startblock, 1, sec_buf); in put_ext4()
226 blk_dwrite(fs->dev_desc, startblock, size >> log2blksz, in put_ext4()
229 blk_dread(fs->dev_desc, startblock, 1, sec_buf); in put_ext4()
232 blk_dwrite(fs->dev_desc, startblock, 1, in put_ext4()
240 struct ext_filesystem *fs = get_fs(); in _get_new_inode_no() local
255 for (j = 0; j < fs->blksz; j++) { in _get_new_inode_no()
281 struct ext_filesystem *fs = get_fs(); in _get_new_blk_no() local
286 if (count == (fs->blksz * 8)) in _get_new_blk_no()
290 if (fs->blksz == 1024) in _get_new_blk_no()
421 struct ext_filesystem *fs = get_fs(); in ext4fs_checksum_update() local
425 desc = ext4fs_get_group_descriptor(fs, i); in ext4fs_checksum_update()
426 if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) { in ext4fs_checksum_update()
429 crc = ext2fs_crc16(~0, fs->sb->unique_id, in ext4fs_checksum_update()
430 sizeof(fs->sb->unique_id)); in ext4fs_checksum_update()
435 if (offset < fs->gdsize) { in ext4fs_checksum_update()
437 fs->gdsize - offset); in ext4fs_checksum_update()
486 struct ext_filesystem *fs = get_fs(); in ext4fs_update_parent_dentry() local
495 zero_buffer = zalloc(fs->blksz); in ext4fs_update_parent_dentry()
500 root_first_block_buffer = zalloc(fs->blksz); in ext4fs_update_parent_dentry()
520 * fs->sect_perblk, in ext4fs_update_parent_dentry()
521 0, fs->blksz, root_first_block_buffer); in ext4fs_update_parent_dentry()
535 if (fs->blksz - totalbytes == le16_to_cpu(dir->direntlen)) { in ext4fs_update_parent_dentry()
564 put_ext4((uint64_t)new_blk_no * fs->blksz, zero_buffer, fs->blksz); in ext4fs_update_parent_dentry()
570 new_size += fs->blksz; in ext4fs_update_parent_dentry()
574 new_blockcnt += fs->sect_perblk; in ext4fs_update_parent_dentry()
609 dir->direntlen = cpu_to_le16(fs->blksz - totalbytes); in ext4fs_update_parent_dentry()
638 struct ext_filesystem *fs = get_fs(); in search_dir() local
645 block_buffer = zalloc(fs->blksz); in search_dir()
656 status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, in search_dir()
657 0, fs->blksz, (char *)block_buffer); in search_dir()
683 } while (offset < fs->blksz); in search_dir()
872 struct ext_filesystem *fs = get_fs(); in unlink_filename() local
876 block_buffer = zalloc(fs->blksz); in unlink_filename()
881 status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, in unlink_filename()
882 fs->blksz, block_buffer); in unlink_filename()
909 } while (offset < fs->blksz); in unlink_filename()
967 struct ext_filesystem *fs = get_fs(); in ext4fs_get_new_blk_no() local
968 char *journal_buffer = zalloc(fs->blksz); in ext4fs_get_new_blk_no()
969 char *zero_buffer = zalloc(fs->blksz); in ext4fs_get_new_blk_no()
973 if (fs->first_pass_bbmap == 0) { in ext4fs_get_new_blk_no()
974 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_get_new_blk_no()
976 bgd = ext4fs_get_group_descriptor(fs, i); in ext4fs_get_new_blk_no()
977 if (ext4fs_bg_get_free_blocks(bgd, fs)) { in ext4fs_get_new_blk_no()
980 ext4fs_bg_get_block_id(bgd, fs); in ext4fs_get_new_blk_no()
982 memcpy(fs->blk_bmaps[i], zero_buffer, in ext4fs_get_new_blk_no()
983 fs->blksz); in ext4fs_get_new_blk_no()
984 put_ext4(b_bitmap_blk * fs->blksz, in ext4fs_get_new_blk_no()
985 fs->blk_bmaps[i], fs->blksz); in ext4fs_get_new_blk_no()
989 fs->curr_blkno = in ext4fs_get_new_blk_no()
990 _get_new_blk_no(fs->blk_bmaps[i]); in ext4fs_get_new_blk_no()
991 if (fs->curr_blkno == -1) in ext4fs_get_new_blk_no()
994 fs->curr_blkno = fs->curr_blkno + in ext4fs_get_new_blk_no()
995 (i * fs->blksz * 8); in ext4fs_get_new_blk_no()
996 fs->first_pass_bbmap++; in ext4fs_get_new_blk_no()
997 ext4fs_bg_free_blocks_dec(bgd, fs); in ext4fs_get_new_blk_no()
998 ext4fs_sb_free_blocks_dec(fs->sb); in ext4fs_get_new_blk_no()
1000 fs->sect_perblk, in ext4fs_get_new_blk_no()
1001 0, fs->blksz, in ext4fs_get_new_blk_no()
1016 fs->curr_blkno++; in ext4fs_get_new_blk_no()
1019 bg_idx = fs->curr_blkno / blk_per_grp; in ext4fs_get_new_blk_no()
1020 if (fs->blksz == 1024) { in ext4fs_get_new_blk_no()
1021 remainder = fs->curr_blkno % blk_per_grp; in ext4fs_get_new_blk_no()
1030 if (bg_idx >= fs->no_blkgrp) in ext4fs_get_new_blk_no()
1034 bgd = ext4fs_get_group_descriptor(fs, bg_idx); in ext4fs_get_new_blk_no()
1035 if (ext4fs_bg_get_free_blocks(bgd, fs) == 0) { in ext4fs_get_new_blk_no()
1037 fs->curr_blkno = (bg_idx + 1) * blk_per_grp; in ext4fs_get_new_blk_no()
1038 if (fs->blksz == 1024) in ext4fs_get_new_blk_no()
1039 fs->curr_blkno += 1; in ext4fs_get_new_blk_no()
1044 uint64_t b_bitmap_blk = ext4fs_bg_get_block_id(bgd, fs); in ext4fs_get_new_blk_no()
1046 memcpy(fs->blk_bmaps[bg_idx], zero_buffer, fs->blksz); in ext4fs_get_new_blk_no()
1047 put_ext4(b_bitmap_blk * fs->blksz, in ext4fs_get_new_blk_no()
1048 zero_buffer, fs->blksz); in ext4fs_get_new_blk_no()
1053 if (ext4fs_set_block_bmap(fs->curr_blkno, fs->blk_bmaps[bg_idx], in ext4fs_get_new_blk_no()
1056 fs->curr_blkno, bg_idx); in ext4fs_get_new_blk_no()
1057 fs->curr_blkno++; in ext4fs_get_new_blk_no()
1063 status = ext4fs_devread(b_bitmap_blk * fs->sect_perblk, in ext4fs_get_new_blk_no()
1064 0, fs->blksz, journal_buffer); in ext4fs_get_new_blk_no()
1072 ext4fs_bg_free_blocks_dec(bgd, fs); in ext4fs_get_new_blk_no()
1073 ext4fs_sb_free_blocks_dec(fs->sb); in ext4fs_get_new_blk_no()
1080 return fs->curr_blkno; in ext4fs_get_new_blk_no()
1095 struct ext_filesystem *fs = get_fs(); in ext4fs_get_new_inode_no() local
1096 char *journal_buffer = zalloc(fs->blksz); in ext4fs_get_new_inode_no()
1097 char *zero_buffer = zalloc(fs->blksz); in ext4fs_get_new_inode_no()
1100 int has_gdt_chksum = le32_to_cpu(fs->sb->feature_ro_compat) & in ext4fs_get_new_inode_no()
1103 if (fs->first_pass_ibmap == 0) { in ext4fs_get_new_inode_no()
1104 for (i = 0; i < fs->no_blkgrp; i++) { in ext4fs_get_new_inode_no()
1107 bgd = ext4fs_get_group_descriptor(fs, i); in ext4fs_get_new_inode_no()
1108 free_inodes = ext4fs_bg_get_free_inodes(bgd, fs); in ext4fs_get_new_inode_no()
1112 ext4fs_bg_get_inode_id(bgd, fs); in ext4fs_get_new_inode_no()
1116 put_ext4(i_bitmap_blk * fs->blksz, in ext4fs_get_new_inode_no()
1117 zero_buffer, fs->blksz); in ext4fs_get_new_inode_no()
1120 memcpy(fs->inode_bmaps[i], in ext4fs_get_new_inode_no()
1121 zero_buffer, fs->blksz); in ext4fs_get_new_inode_no()
1123 fs->curr_inode_no = in ext4fs_get_new_inode_no()
1124 _get_new_inode_no(fs->inode_bmaps[i]); in ext4fs_get_new_inode_no()
1125 if (fs->curr_inode_no == -1) in ext4fs_get_new_inode_no()
1128 fs->curr_inode_no = fs->curr_inode_no + in ext4fs_get_new_inode_no()
1130 fs->first_pass_ibmap++; in ext4fs_get_new_inode_no()
1131 ext4fs_bg_free_inodes_dec(bgd, fs); in ext4fs_get_new_inode_no()
1133 ext4fs_bg_itable_unused_dec(bgd, fs); in ext4fs_get_new_inode_no()
1134 ext4fs_sb_free_inodes_dec(fs->sb); in ext4fs_get_new_inode_no()
1136 fs->sect_perblk, in ext4fs_get_new_inode_no()
1137 0, fs->blksz, in ext4fs_get_new_inode_no()
1151 fs->curr_inode_no++; in ext4fs_get_new_inode_no()
1153 ibmap_idx = fs->curr_inode_no / inodes_per_grp; in ext4fs_get_new_inode_no()
1155 ext4fs_get_group_descriptor(fs, ibmap_idx); in ext4fs_get_new_inode_no()
1157 uint64_t i_bitmap_blk = ext4fs_bg_get_inode_id(bgd, fs); in ext4fs_get_new_inode_no()
1160 put_ext4(i_bitmap_blk * fs->blksz, in ext4fs_get_new_inode_no()
1161 zero_buffer, fs->blksz); in ext4fs_get_new_inode_no()
1164 memcpy(fs->inode_bmaps[ibmap_idx], zero_buffer, in ext4fs_get_new_inode_no()
1165 fs->blksz); in ext4fs_get_new_inode_no()
1168 if (ext4fs_set_inode_bmap(fs->curr_inode_no, in ext4fs_get_new_inode_no()
1169 fs->inode_bmaps[ibmap_idx], in ext4fs_get_new_inode_no()
1172 fs->curr_inode_no, ibmap_idx); in ext4fs_get_new_inode_no()
1178 status = ext4fs_devread(i_bitmap_blk * fs->sect_perblk, in ext4fs_get_new_inode_no()
1179 0, fs->blksz, journal_buffer); in ext4fs_get_new_inode_no()
1187 ext4fs_bg_free_inodes_dec(bgd, fs); in ext4fs_get_new_inode_no()
1190 ext4fs_sb_free_inodes_dec(fs->sb); in ext4fs_get_new_inode_no()
1198 return fs->curr_inode_no; in ext4fs_get_new_inode_no()
1219 struct ext_filesystem *fs = get_fs(); in alloc_single_indirect_block() local
1222 si_buffer = zalloc(fs->blksz); in alloc_single_indirect_block()
1236 status = ext4fs_devread((lbaint_t)si_blockno * fs->sect_perblk, in alloc_single_indirect_block()
1237 0, fs->blksz, (char *)si_buffer); in alloc_single_indirect_block()
1238 memset(si_buffer, '\0', fs->blksz); in alloc_single_indirect_block()
1242 for (i = 0; i < (fs->blksz / sizeof(int)); i++) { in alloc_single_indirect_block()
1259 put_ext4(((uint64_t) ((uint64_t)si_blockno * (uint64_t)fs->blksz)), in alloc_single_indirect_block()
1260 si_start_addr, fs->blksz); in alloc_single_indirect_block()
1282 struct ext_filesystem *fs = get_fs(); in alloc_double_indirect_block() local
1291 di_parent_buffer = zalloc(fs->blksz); in alloc_double_indirect_block()
1301 fs->sect_perblk, 0, in alloc_double_indirect_block()
1302 fs->blksz, (char *)di_parent_buffer); in alloc_double_indirect_block()
1308 memset(di_parent_buffer, '\0', fs->blksz); in alloc_double_indirect_block()
1314 for (i = 0; i < (fs->blksz / sizeof(int)); i++) { in alloc_double_indirect_block()
1320 di_child_buff = zalloc(fs->blksz); in alloc_double_indirect_block()
1332 fs->sect_perblk, 0, in alloc_double_indirect_block()
1333 fs->blksz, in alloc_double_indirect_block()
1340 memset(di_child_buff, '\0', fs->blksz); in alloc_double_indirect_block()
1342 for (j = 0; j < (fs->blksz / sizeof(int)); j++) { in alloc_double_indirect_block()
1358 put_ext4(((uint64_t) ((uint64_t)di_blockno_child * (uint64_t)fs->blksz)), in alloc_double_indirect_block()
1359 di_child_buff_start, fs->blksz); in alloc_double_indirect_block()
1366 put_ext4(((uint64_t) ((uint64_t)di_blockno_parent * (uint64_t)fs->blksz)), in alloc_double_indirect_block()
1367 di_block_start_addr, fs->blksz); in alloc_double_indirect_block()
1392 struct ext_filesystem *fs = get_fs(); in alloc_triple_indirect_block() local
1400 ti_gp_buff = zalloc(fs->blksz); in alloc_triple_indirect_block()
1410 for (i = 0; i < (fs->blksz / sizeof(int)); i++) { in alloc_triple_indirect_block()
1416 ti_parent_buff = zalloc(fs->blksz); in alloc_triple_indirect_block()
1428 for (j = 0; j < (fs->blksz / sizeof(int)); j++) { in alloc_triple_indirect_block()
1434 ti_child_buff = zalloc(fs->blksz); in alloc_triple_indirect_block()
1446 for (k = 0; k < (fs->blksz / sizeof(int)); in alloc_triple_indirect_block()
1466 (uint64_t)fs->blksz)), in alloc_triple_indirect_block()
1467 ti_cbuff_start_addr, fs->blksz); in alloc_triple_indirect_block()
1474 put_ext4(((uint64_t) ((uint64_t)ti_parent_blockno * (uint64_t)fs->blksz)), in alloc_triple_indirect_block()
1475 ti_pbuff_start_addr, fs->blksz); in alloc_triple_indirect_block()
1482 put_ext4(((uint64_t) ((uint64_t)ti_gp_blockno * (uint64_t)fs->blksz)), in alloc_triple_indirect_block()
1483 ti_gp_buff_start_addr, fs->blksz); in alloc_triple_indirect_block()
1591 struct ext_filesystem *fs = get_fs(); in ext4fs_read_inode() local
1604 inodes_per_block = EXT2_BLOCK_SIZE(data) / fs->inodesz; in ext4fs_read_inode()
1605 blkno = ext4fs_bg_get_inode_table_id(&blkgrp, fs) + in ext4fs_read_inode()
1607 blkoff = (ino % inodes_per_block) * fs->inodesz; in ext4fs_read_inode()
2333 struct ext_filesystem *fs = get_fs(); in ext4fs_mount() local
2350 fs->inodesz = 128; in ext4fs_mount()
2351 fs->gdsize = 32; in ext4fs_mount()
2358 fs->inodesz = le16_to_cpu(data->sblock.inode_size); in ext4fs_mount()
2359 fs->gdsize = le32_to_cpu(data->sblock.feature_incompat) & in ext4fs_mount()
2366 fs->inodesz, fs->gdsize); in ext4fs_mount()