Whamcloud - gitweb
libext2fs: don't use O_DIRECT for files on tmpfs
[tools/e2fsprogs.git] / lib / ext2fs / tst_fs_struct.c
1 /*
2  * This testing program checks the offset of the ext2_filsys structure
3  *
4  * Copyright (C) 2007 by Theodore Ts'o.
5  *
6  * %Begin-Header%
7  * This file may be redistributed under the terms of the GNU Library
8  * General Public License, version 2.
9  * %End-Header%
10  */
11
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <stdlib.h>
15
16 #include "ext2fs.h"
17
18 struct struct_ext2_filsys fs;
19
20 #ifndef offsetof
21 #define offsetof(type, member)  __builtin_offsetof (type, member)
22 #endif
23 #define check_field(x) cur_offset = do_field(#x, sizeof(fs.x),          \
24                                         offsetof(struct struct_ext2_filsys, x), \
25                                         cur_offset)
26
27 static int do_field(const char *field, size_t size, int offset, int cur_offset)
28 {
29         if (offset != cur_offset) {
30                 printf("\t(padding %d bytes?)\n", offset - cur_offset);
31         }
32         printf("%8d %-30s %3u\n", offset, field, (unsigned) size);
33         return offset + size;
34 }
35
36 int main(int argc, char **argv)
37 {
38 #if (__GNUC__ >= 4)
39         int cur_offset = 0;
40
41         printf("%8s %-30s %3s\n", "offset", "field", "size");
42         check_field(magic);
43         check_field(io);
44         check_field(flags);
45         check_field(device_name);
46         check_field(super);
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);
61         check_field(dblist);
62         check_field(stride);
63         check_field(orig_super);
64         check_field(image_header);
65         check_field(umask);
66         check_field(now);
67         check_field(cluster_ratio_bits);
68         check_field(reserved);
69         check_field(priv_data);
70         check_field(icache);
71         check_field(image_io);
72         check_field(get_alloc_block);
73         check_field(block_alloc_stats);
74         check_field(mmp_buf);
75         check_field(mmp_cmp);
76         check_field(mmp_fd);
77         check_field(mmp_last_written);
78         printf("Ending offset is %d\n\n", cur_offset);
79 #endif
80         exit(0);
81 }