Home | History | Annotate | Download | only in ext2fs

Lines Matching defs:fs

32 __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
34 struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc,
36 size_t size = EXT2_DESC_SIZE(fs->super);
40 if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
53 ext2fs_swap_group_desc2(fs,
59 crc = ext2fs_crc16(~0, fs->super->s_uuid,
60 sizeof(fs->super->s_uuid));
85 int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group)
87 if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
89 (ext2fs_bg_checksum(fs, group) !=
90 ext2fs_group_desc_csum(fs, group)))
96 void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group)
98 if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
104 ext2fs_bg_checksum_set(fs, group, ext2fs_group_desc_csum(fs, group));
124 errcode_t ext2fs_set_gdt_csum(ext2_filsys fs)
126 struct ext2_super_block *sb = fs->super;
130 if (!fs->inode_map)
133 if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
137 for (i = 0; i < fs->group_desc_count; i++) {
138 __u32 old_csum = ext2fs_bg_checksum(fs, i);
139 __u32 old_unused = ext2fs_bg_itable_unused(fs, i);
140 __u32 old_flags = ext2fs_bg_flags(fs, i);
141 __u32 old_free_inodes_count = ext2fs_bg_free_inodes_count(fs, i);
144 ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
145 ext2fs_bg_itable_unused_set(fs, i, sb->s_inodes_per_group);
149 find_last_inode_ingrp(fs->inode_map,
152 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
153 ext2fs_bg_itable_unused_set(fs, i, unused);
156 ext2fs_group_desc_csum_set(fs, i);
157 if (old_flags != ext2fs_bg_flags(fs, i))
159 if (old_unused != ext2fs_bg_itable_unused(fs, i))
161 if (old_csum != ext2fs_bg_checksum(fs, i))
165 ext2fs_mark_super_dirty(fs);
172 void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
176 struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc,
178 size_t size = EXT2_DESC_SIZE(fs->super);
179 struct ext2_super_block *sb = fs->super;
193 ext2fs_swap_group_desc2(fs, (struct ext2_group_desc *) &swabdesc);
201 crc1 = ext2fs_crc16(~0, sb->s_uuid, sizeof(fs->super->s_uuid));
216 ext2fs_group_desc_csum(fs, group));
226 ext2_filsys fs;
238 retval = ext2fs_initialize("test fs", EXT2_FLAG_64BITS, &param,
239 test_io_manager, &fs);
245 memcpy(fs->super->s_uuid, sb_uuid, 16);
246 fs->super->s_feature_ro_compat = EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
248 for (i=0; i < fs->group_desc_count; i++) {
249 ext2fs_block_bitmap_loc_set(fs, i, 124);
250 ext2fs_inode_bitmap_loc_set(fs, i, 125);
251 ext2fs_inode_table_loc_set(fs, i, 126);
252 ext2fs_bg_free_blocks_count_set(fs, i, 31119);
253 ext2fs_bg_free_inodes_count_set(fs, i, 15701);
254 ext2fs_bg_used_dirs_count_set(fs, i, 2);
255 ext2fs_bg_flags_zap(fs, i);
258 csum1 = ext2fs_group_desc_csum(fs, 0);
259 print_csum("csum0000", fs, 0);
265 csum2 = ext2fs_group_desc_csum(fs, 1);
266 print_csum("csum0001", fs, 1);
271 csum2 = ext2fs_group_desc_csum(fs, 2);
272 print_csum("csumffff", fs, 2);
277 ext2fs_bg_checksum_set(fs, 0, csum1);
278 csum2 = ext2fs_group_desc_csum(fs, 0);
279 print_csum("csum_set", fs, 0);
284 if (!ext2fs_group_desc_csum_verify(fs, 0)) {
288 memset(fs->super->s_uuid, 0x30, sizeof(fs->super->s_uuid));
289 print_csum("new_uuid", fs, 0);
290 if (ext2fs_group_desc_csum_verify(fs, 0) != 0) {
294 csum1 = ext2fs_group_desc_csum(fs, 0);
295 ext2fs_bg_checksum_set(fs, 0, csum1);
296 print_csum("csum_new", fs, 0);
297 ext2fs_bg_free_blocks_count_set(fs, 0, 1);
298 csum2 = ext2fs_group_desc_csum(fs, 0);
299 print_csum("csum_blk", fs, 0);