Home | History | Annotate | Download | only in ext2fs

Lines Matching refs:fs

32 STATIC __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
37 desc = &fs->group_desc[group];
39 if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
51 crc = ext2fs_crc16(~0, fs->super->s_uuid,
52 sizeof(fs->super->s_uuid));
58 if (offset < fs->super->s_desc_size) {
60 fs->super->s_desc_size - offset);
67 int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group)
69 if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
71 (fs->group_desc[group].bg_checksum !=
72 ext2fs_group_desc_csum(fs, group)))
78 void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group)
80 if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
82 fs->group_desc[group].bg_checksum =
83 ext2fs_group_desc_csum(fs, group);
103 errcode_t ext2fs_set_gdt_csum(ext2_filsys fs)
105 struct ext2_super_block *sb = fs->super;
106 struct ext2_group_desc *bg = fs->group_desc;
110 if (!fs->inode_map)
113 if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
117 for (i = 0; i < fs->group_desc_count; i++, bg++) {
128 find_last_inode_ingrp(fs->inode_map,
132 ext2fs_group_desc_csum_set(fs, i);
141 ext2fs_mark_super_dirty(fs);
148 void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
152 struct ext2_group_desc *desc = &fs->group_desc[group];
153 struct ext2_super_block *sb = fs->super;
156 struct ext2_group_desc swabdesc = fs->group_desc[group];
167 crc1 = ext2fs_crc16(~0, sb->s_uuid, sizeof(fs->super->s_uuid));
173 ext2fs_group_desc_csum(fs, group));
183 ext2_filsys fs;
190 retval = ext2fs_initialize("test fs", 0, &param,
191 test_io_manager, &fs);
197 memcpy(fs->super->s_uuid, sb_uuid, 16);
198 fs->super->s_feature_ro_compat = EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
200 for (i=0; i < fs->group_desc_count; i++) {
201 fs->group_desc[i].bg_block_bitmap = 124;
202 fs->group_desc[i].bg_inode_bitmap = 125;
203 fs->group_desc[i].bg_inode_table = 126;
204 fs->group_desc[i].bg_free_blocks_count = 31119;
205 fs->group_desc[i].bg_free_inodes_count = 15701;
206 fs->group_desc[i].bg_used_dirs_count = 2;
207 fs->group_desc[i].bg_flags = 0;
210 csum1 = ext2fs_group_desc_csum(fs, 0);
211 print_csum("csum0000", fs, 0);
217 csum2 = ext2fs_group_desc_csum(fs, 1);
218 print_csum("csum0001", fs, 1);
223 csum2 = ext2fs_group_desc_csum(fs, 2);
224 print_csum("csumffff", fs, 2);
229 fs->group_desc[0].bg_checksum = csum1;
230 csum2 = ext2fs_group_desc_csum(fs, 0);
231 print_csum("csum_set", fs, 0);
236 if (!ext2fs_group_desc_csum_verify(fs, 0)) {
240 memset(fs->super->s_uuid, 0x30, sizeof(fs->super->s_uuid));
241 print_csum("new_uuid", fs, 0);
242 if (ext2fs_group_desc_csum_verify(fs, 0) != 0) {
246 csum1 = fs->group_desc[0].bg_checksum = ext2fs_group_desc_csum(fs, 0);
247 print_csum("csum_new", fs, 0);
248 fs->group_desc[0].bg_free_blocks_count = 1;
249 csum2 = ext2fs_group_desc_csum(fs, 0);
250 print_csum("csum_blk", fs, 0);