2 * This testing program checks the offset of the ext2_filsys structure
4 * Copyright (C) 2007 by Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
18 struct struct_ext2_filsys fs;
21 #define offsetof(type, member) __builtin_offsetof (type, member)
23 #define check_field(x) cur_offset = do_field(#x, sizeof(fs.x), \
24 offsetof(struct struct_ext2_filsys, x), \
27 static int do_field(const char *field, size_t size, int offset, int cur_offset)
29 if (offset != cur_offset) {
30 printf("\t(padding %d bytes?)\n", offset - cur_offset);
32 printf("%8d %-30s %3u\n", offset, field, (unsigned) size);
36 int main(int argc, char **argv)
41 printf("%8s %-30s %3s\n", "offset", "field", "size");
45 check_field(device_name);
47 check_field(blocksize);
48 check_field(fragsize);
49 check_field(group_desc_count);
50 check_field(desc_blocks);
51 check_field(group_desc);
52 check_field(inode_blocks_per_group);
53 check_field(inode_map);
54 check_field(block_map);
55 check_field(get_blocks);
56 check_field(check_directory);
57 check_field(write_bitmaps);
58 check_field(read_inode);
59 check_field(write_inode);
60 check_field(badblocks);
63 check_field(orig_super);
64 check_field(image_header);
67 check_field(cluster_ratio_bits);
68 check_field(reserved);
69 check_field(priv_data);
71 check_field(image_io);
72 check_field(get_alloc_block);
73 check_field(block_alloc_stats);
77 check_field(mmp_last_written);
78 printf("Ending offset is %d\n\n", cur_offset);