Whamcloud - gitweb
b=14836
[fs/lustre-release.git] / lustre / utils / wirecheck.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #include <stdio.h>
38 #include <sys/types.h>
39 #include <sys/wait.h>
40 #include <liblustre.h>
41 #include <lustre_lib.h>
42 #include <lustre/lustre_idl.h>
43 #include <lustre_disk.h>
44
45 #define BLANK_LINE()                                            \
46 do {                                                            \
47         printf("\n");                                           \
48 } while(0)
49
50 #define COMMENT(c)                                              \
51 do {                                                            \
52         printf("        /* "c" */\n");                          \
53 } while(0)
54
55 #define STRINGIFY(a) #a
56
57
58 #define CHECK_CDEFINE(a)                                        \
59         printf("        CLASSERT("#a" == "STRINGIFY(a) ");\n")
60
61 #define CHECK_CVALUE(a)                                         \
62         printf("        CLASSERT("#a" == %lld);\n", (long long)a)
63
64 #define CHECK_DEFINE(a)                                         \
65 do {                                                            \
66         printf("        LASSERTF("#a" == "STRINGIFY(a)          \
67                ",\" found %%lld\\n\",\n                 "       \
68                "(long long)"#a");\n");   \
69 } while(0)
70
71 #define CHECK_VALUE(a)                                          \
72 do {                                                            \
73         printf("        LASSERTF("#a                            \
74                " == %lld, \" found %%lld\\n\",\n                 "\
75                "(long long)"#a");\n", (long long)a);            \
76 } while(0)
77
78 #define CHECK_VALUE_64(a)                                       \
79 do {                                                            \
80         printf("        LASSERTF("#a                            \
81                " == %lldULL, \" found %%lld\\n\",\n                 "\
82                "(long long)"#a");\n", (long long)a);            \
83 } while(0)
84
85 #define CHECK_MEMBER_OFFSET(s,m)                                \
86 do {                                                            \
87         CHECK_VALUE((int)offsetof(struct s, m));                \
88 } while(0)
89
90 #define CHECK_MEMBER_OFFSET_TYPEDEF(s,m)                        \
91 do {                                                            \
92         CHECK_VALUE((int)offsetof(s, m));                       \
93 } while(0)
94
95 #define CHECK_MEMBER_SIZEOF(s,m)                                \
96 do {                                                            \
97         CHECK_VALUE((int)sizeof(((struct s *)0)->m));           \
98 } while(0)
99
100 #define CHECK_MEMBER_SIZEOF_TYPEDEF(s,m)                        \
101 do {                                                            \
102         CHECK_VALUE((int)sizeof(((s *)0)->m));                  \
103 } while(0)
104
105 #define CHECK_MEMBER(s,m)                                       \
106 do {                                                            \
107         CHECK_MEMBER_OFFSET(s, m);                              \
108         CHECK_MEMBER_SIZEOF(s, m);                              \
109 } while(0)
110
111 #define CHECK_MEMBER_TYPEDEF(s,m)                               \
112 do {                                                            \
113         CHECK_MEMBER_OFFSET_TYPEDEF(s, m);                      \
114         CHECK_MEMBER_SIZEOF_TYPEDEF(s, m);                      \
115 } while(0)
116
117 #define CHECK_STRUCT(s)                                         \
118 do {                                                            \
119         COMMENT("Checks for struct "#s);                        \
120                 CHECK_VALUE((int)sizeof(struct s));             \
121 } while(0)
122
123 #define CHECK_STRUCT_TYPEDEF(s)                                 \
124 do {                                                            \
125         COMMENT("Checks for type "#s);                          \
126                 CHECK_VALUE((int)sizeof(s));                    \
127 } while(0)
128
129 static void
130 check_lustre_handle(void)
131 {
132         BLANK_LINE();
133         CHECK_STRUCT(lustre_handle);
134         CHECK_MEMBER(lustre_handle, cookie);
135 }
136
137 void
138 check_lustre_msg_v2(void)
139 {
140         BLANK_LINE();
141         CHECK_STRUCT(lustre_msg_v2);
142         CHECK_MEMBER(lustre_msg_v2, lm_bufcount);
143         CHECK_MEMBER(lustre_msg_v2, lm_secflvr);
144         CHECK_MEMBER(lustre_msg_v2, lm_magic);
145         CHECK_MEMBER(lustre_msg_v2, lm_repsize);
146         CHECK_MEMBER(lustre_msg_v2, lm_cksum);
147         CHECK_MEMBER(lustre_msg_v2, lm_flags);
148         CHECK_MEMBER(lustre_msg_v2, lm_padding_2);
149         CHECK_MEMBER(lustre_msg_v2, lm_padding_3);
150         CHECK_MEMBER(lustre_msg_v2, lm_buflens[0]);
151 }
152
153 void
154 check_ptlrpc_body(void)
155 {
156         BLANK_LINE();
157         CHECK_STRUCT(ptlrpc_body);
158         CHECK_MEMBER(ptlrpc_body, pb_handle);
159         CHECK_MEMBER(ptlrpc_body, pb_type);
160         CHECK_MEMBER(ptlrpc_body, pb_version);
161         CHECK_MEMBER(ptlrpc_body, pb_opc);
162         CHECK_MEMBER(ptlrpc_body, pb_status);
163         CHECK_MEMBER(ptlrpc_body, pb_last_xid);
164         CHECK_MEMBER(ptlrpc_body, pb_last_seen);
165         CHECK_MEMBER(ptlrpc_body, pb_last_committed);
166         CHECK_MEMBER(ptlrpc_body, pb_transno);
167         CHECK_MEMBER(ptlrpc_body, pb_flags);
168         CHECK_MEMBER(ptlrpc_body, pb_op_flags);
169         CHECK_MEMBER(ptlrpc_body, pb_conn_cnt);
170         CHECK_MEMBER(ptlrpc_body, pb_timeout);
171         CHECK_MEMBER(ptlrpc_body, pb_service_time);
172         CHECK_MEMBER(ptlrpc_body, pb_slv);
173         CHECK_MEMBER(ptlrpc_body, pb_limit);
174 }
175
176 static void check_obd_connect_data(void)
177 {
178         BLANK_LINE();
179         CHECK_STRUCT(obd_connect_data);
180         CHECK_MEMBER(obd_connect_data, ocd_connect_flags);
181         CHECK_MEMBER(obd_connect_data, ocd_version);
182         CHECK_MEMBER(obd_connect_data, ocd_grant);
183         CHECK_MEMBER(obd_connect_data, ocd_index);
184         CHECK_MEMBER(obd_connect_data, ocd_brw_size);
185         CHECK_MEMBER(obd_connect_data, ocd_ibits_known);
186         CHECK_MEMBER(obd_connect_data, ocd_nllu);
187         CHECK_MEMBER(obd_connect_data, ocd_nllg);
188         CHECK_MEMBER(obd_connect_data, ocd_transno);
189         CHECK_MEMBER(obd_connect_data, ocd_group);
190         CHECK_MEMBER(obd_connect_data, ocd_cksum_types);
191         CHECK_MEMBER(obd_connect_data, padding1);
192         CHECK_MEMBER(obd_connect_data, padding2);
193
194         CHECK_CDEFINE(OBD_CONNECT_RDONLY);
195         CHECK_CDEFINE(OBD_CONNECT_INDEX);
196         CHECK_CDEFINE(OBD_CONNECT_GRANT);
197         CHECK_CDEFINE(OBD_CONNECT_SRVLOCK);
198         CHECK_CDEFINE(OBD_CONNECT_VERSION);
199         CHECK_CDEFINE(OBD_CONNECT_REQPORTAL);
200         CHECK_CDEFINE(OBD_CONNECT_ACL);
201         CHECK_CDEFINE(OBD_CONNECT_XATTR);
202         CHECK_CDEFINE(OBD_CONNECT_REAL);
203         CHECK_CDEFINE(OBD_CONNECT_CKSUM);
204         CHECK_CDEFINE(OBD_CONNECT_TRUNCLOCK);
205         CHECK_CDEFINE(OBD_CONNECT_IBITS);
206         CHECK_CDEFINE(OBD_CONNECT_JOIN);
207         CHECK_CDEFINE(OBD_CONNECT_ATTRFID);
208         CHECK_CDEFINE(OBD_CONNECT_NODEVOH);
209         CHECK_CDEFINE(OBD_CONNECT_LCL_CLIENT);
210         CHECK_CDEFINE(OBD_CONNECT_RMT_CLIENT);
211         CHECK_CDEFINE(OBD_CONNECT_BRW_SIZE);
212         CHECK_CDEFINE(OBD_CONNECT_QUOTA64);
213         CHECK_CDEFINE(OBD_CONNECT_MDS_CAPA);
214         CHECK_CDEFINE(OBD_CONNECT_OSS_CAPA);
215         CHECK_CDEFINE(OBD_CONNECT_MDS_MDS);
216         CHECK_CDEFINE(OBD_CONNECT_SOM);
217         CHECK_CDEFINE(OBD_CONNECT_AT);
218         CHECK_CDEFINE(OBD_CONNECT_CANCELSET);
219         CHECK_CDEFINE(OBD_CONNECT_LRU_RESIZE);
220 }
221
222 static void
223 check_obdo(void)
224 {
225         BLANK_LINE();
226         CHECK_STRUCT(obdo);
227         CHECK_MEMBER(obdo, o_valid);
228         CHECK_MEMBER(obdo, o_id);
229         CHECK_MEMBER(obdo, o_gr);
230         CHECK_MEMBER(obdo, o_fid);
231         CHECK_MEMBER(obdo, o_size);
232         CHECK_MEMBER(obdo, o_mtime);
233         CHECK_MEMBER(obdo, o_atime);
234         CHECK_MEMBER(obdo, o_ctime);
235         CHECK_MEMBER(obdo, o_blocks);
236         CHECK_MEMBER(obdo, o_grant);
237         CHECK_MEMBER(obdo, o_blksize);
238         CHECK_MEMBER(obdo, o_mode);
239         CHECK_MEMBER(obdo, o_uid);
240         CHECK_MEMBER(obdo, o_gid);
241         CHECK_MEMBER(obdo, o_flags);
242         CHECK_MEMBER(obdo, o_nlink);
243         CHECK_MEMBER(obdo, o_generation);
244         CHECK_MEMBER(obdo, o_misc);
245         CHECK_MEMBER(obdo, o_easize);
246         CHECK_MEMBER(obdo, o_mds);
247         CHECK_MEMBER(obdo, o_stripe_idx);
248         CHECK_MEMBER(obdo, o_padding_1);
249         CHECK_MEMBER(obdo, o_handle);
250         CHECK_MEMBER(obdo, o_lcookie);
251         CHECK_MEMBER(obdo, o_padding_2);
252         CHECK_MEMBER(obdo, o_padding_3);
253         CHECK_MEMBER(obdo, o_padding_4);
254         CHECK_MEMBER(obdo, o_padding_5);
255         CHECK_MEMBER(obdo, o_padding_6);       
256
257         CHECK_CDEFINE(OBD_MD_FLID);
258         CHECK_CDEFINE(OBD_MD_FLATIME);
259         CHECK_CDEFINE(OBD_MD_FLMTIME);
260         CHECK_CDEFINE(OBD_MD_FLCTIME);
261         CHECK_CDEFINE(OBD_MD_FLSIZE);
262         CHECK_CDEFINE(OBD_MD_FLBLOCKS);
263         CHECK_CDEFINE(OBD_MD_FLBLKSZ);
264         CHECK_CDEFINE(OBD_MD_FLMODE);
265         CHECK_CDEFINE(OBD_MD_FLTYPE);
266         CHECK_CDEFINE(OBD_MD_FLUID);
267         CHECK_CDEFINE(OBD_MD_FLGID);
268         CHECK_CDEFINE(OBD_MD_FLFLAGS);
269         CHECK_CDEFINE(OBD_MD_FLNLINK);
270         CHECK_CDEFINE(OBD_MD_FLGENER);
271         CHECK_CDEFINE(OBD_MD_FLRDEV);
272         CHECK_CDEFINE(OBD_MD_FLEASIZE);
273         CHECK_CDEFINE(OBD_MD_LINKNAME);
274         CHECK_CDEFINE(OBD_MD_FLHANDLE);
275         CHECK_CDEFINE(OBD_MD_FLCKSUM);
276         CHECK_CDEFINE(OBD_MD_FLQOS);
277         CHECK_CDEFINE(OBD_MD_FLCOOKIE);
278         CHECK_CDEFINE(OBD_MD_FLGROUP);
279         CHECK_CDEFINE(OBD_MD_FLFID);
280         CHECK_CDEFINE(OBD_MD_FLEPOCH);
281         CHECK_CDEFINE(OBD_MD_FLGRANT);
282         CHECK_CDEFINE(OBD_MD_FLDIREA);
283         CHECK_CDEFINE(OBD_MD_FLUSRQUOTA);
284         CHECK_CDEFINE(OBD_MD_FLGRPQUOTA);
285         CHECK_CDEFINE(OBD_MD_FLMODEASIZE);
286         CHECK_CDEFINE(OBD_MD_MDS);
287         CHECK_CDEFINE(OBD_MD_REINT);
288         CHECK_CDEFINE(OBD_MD_FLXATTR);
289         CHECK_CDEFINE(OBD_MD_FLXATTRLS);
290         CHECK_CDEFINE(OBD_MD_FLXATTRRM);
291         CHECK_CDEFINE(OBD_MD_FLACL);
292
293         CHECK_CDEFINE(OBD_FL_INLINEDATA);
294         CHECK_CDEFINE(OBD_FL_OBDMDEXISTS);
295         CHECK_CDEFINE(OBD_FL_DELORPHAN);
296         CHECK_CDEFINE(OBD_FL_NORPC);
297         CHECK_CDEFINE(OBD_FL_IDONLY);
298         CHECK_CDEFINE(OBD_FL_RECREATE_OBJS);
299         CHECK_CDEFINE(OBD_FL_DEBUG_CHECK);
300         CHECK_CDEFINE(OBD_FL_NO_USRQUOTA);
301         CHECK_CDEFINE(OBD_FL_NO_GRPQUOTA);
302         CHECK_CDEFINE(OBD_FL_TRUNCLOCK);
303         CHECK_CDEFINE(OBD_FL_CKSUM_CRC32);
304         CHECK_CDEFINE(OBD_FL_CKSUM_ADLER);
305         CHECK_CVALUE(OBD_CKSUM_CRC32);
306         CHECK_CVALUE(OBD_CKSUM_ADLER);
307 }
308
309 static void
310 check_lov_mds_md_v1(void)
311 {
312         BLANK_LINE();
313         CHECK_STRUCT(lov_mds_md_v1);
314         CHECK_MEMBER(lov_mds_md_v1, lmm_magic);
315         CHECK_MEMBER(lov_mds_md_v1, lmm_pattern);
316         CHECK_MEMBER(lov_mds_md_v1, lmm_object_id);
317         CHECK_MEMBER(lov_mds_md_v1, lmm_object_gr);
318         CHECK_MEMBER(lov_mds_md_v1, lmm_stripe_size);
319         CHECK_MEMBER(lov_mds_md_v1, lmm_stripe_count);
320         CHECK_MEMBER(lov_mds_md_v1, lmm_objects);
321
322         BLANK_LINE();
323         CHECK_STRUCT(lov_ost_data_v1);
324         CHECK_MEMBER(lov_ost_data_v1, l_object_id);
325         CHECK_MEMBER(lov_ost_data_v1, l_object_gr);
326         CHECK_MEMBER(lov_ost_data_v1, l_ost_gen);
327         CHECK_MEMBER(lov_ost_data_v1, l_ost_idx);
328
329         CHECK_CDEFINE(LOV_MAGIC_V1);
330         CHECK_CDEFINE(LOV_MAGIC_JOIN);
331
332         CHECK_VALUE(LOV_PATTERN_RAID0);
333         CHECK_VALUE(LOV_PATTERN_RAID1);
334 }
335
336 static void
337 check_lov_mds_md_join(void)
338 {
339         BLANK_LINE();
340         CHECK_STRUCT(lov_mds_md_join);
341         CHECK_MEMBER(lov_mds_md_join, lmmj_md);
342         CHECK_MEMBER(lov_mds_md_join, lmmj_array_id);
343         CHECK_MEMBER(lov_mds_md_join, lmmj_extent_count);
344 }
345
346 static void
347 check_lov_mds_md_v3(void)
348 {
349         BLANK_LINE();
350         CHECK_STRUCT(lov_mds_md_v3);
351         CHECK_MEMBER(lov_mds_md_v3, lmm_magic);
352         CHECK_MEMBER(lov_mds_md_v3, lmm_pattern);
353         CHECK_MEMBER(lov_mds_md_v3, lmm_object_id);
354         CHECK_MEMBER(lov_mds_md_v3, lmm_object_gr);
355         CHECK_MEMBER(lov_mds_md_v3, lmm_stripe_size);
356         CHECK_MEMBER(lov_mds_md_v3, lmm_stripe_count);
357         CHECK_MEMBER(lov_mds_md_v3, lmm_pool_name);
358         CHECK_MEMBER(lov_mds_md_v3, lmm_objects);
359
360         BLANK_LINE();
361         CHECK_STRUCT(lov_ost_data_v1);
362         CHECK_MEMBER(lov_ost_data_v1, l_object_id);
363         CHECK_MEMBER(lov_ost_data_v1, l_object_gr);
364         CHECK_MEMBER(lov_ost_data_v1, l_ost_gen);
365         CHECK_MEMBER(lov_ost_data_v1, l_ost_idx);
366
367         CHECK_CDEFINE(LOV_MAGIC_V3);
368
369         CHECK_VALUE(LOV_PATTERN_RAID0);
370         CHECK_VALUE(LOV_PATTERN_RAID1);
371 }
372
373 static void
374 check_obd_statfs(void)
375 {
376         BLANK_LINE();
377         CHECK_STRUCT(obd_statfs);
378         CHECK_MEMBER(obd_statfs, os_type);
379         CHECK_MEMBER(obd_statfs, os_blocks);
380         CHECK_MEMBER(obd_statfs, os_bfree);
381         CHECK_MEMBER(obd_statfs, os_bavail);
382         CHECK_MEMBER(obd_statfs, os_ffree);
383         CHECK_MEMBER(obd_statfs, os_fsid);
384         CHECK_MEMBER(obd_statfs, os_bsize);
385         CHECK_MEMBER(obd_statfs, os_namelen);
386         CHECK_MEMBER(obd_statfs, os_state);
387         CHECK_MEMBER(obd_statfs, os_spare1);
388         CHECK_MEMBER(obd_statfs, os_spare2);
389         CHECK_MEMBER(obd_statfs, os_spare3);
390         CHECK_MEMBER(obd_statfs, os_spare4);
391         CHECK_MEMBER(obd_statfs, os_spare5);
392         CHECK_MEMBER(obd_statfs, os_spare6);
393         CHECK_MEMBER(obd_statfs, os_spare7);
394         CHECK_MEMBER(obd_statfs, os_spare8);
395         CHECK_MEMBER(obd_statfs, os_spare9);
396 }
397
398 static void
399 check_obd_ioobj(void)
400 {
401         BLANK_LINE();
402         CHECK_STRUCT(obd_ioobj);
403         CHECK_MEMBER(obd_ioobj, ioo_id);
404         CHECK_MEMBER(obd_ioobj, ioo_gr);
405         CHECK_MEMBER(obd_ioobj, ioo_type);
406         CHECK_MEMBER(obd_ioobj, ioo_bufcnt);
407 }
408
409 static void
410 check_obd_quotactl(void)
411 {
412         BLANK_LINE();
413         CHECK_STRUCT(obd_quotactl);
414         CHECK_MEMBER(obd_quotactl, qc_cmd);
415         CHECK_MEMBER(obd_quotactl, qc_type);
416         CHECK_MEMBER(obd_quotactl, qc_id);
417         CHECK_MEMBER(obd_quotactl, qc_stat);
418         CHECK_MEMBER(obd_quotactl, qc_dqinfo);
419         CHECK_MEMBER(obd_quotactl, qc_dqblk);
420
421         BLANK_LINE();
422         CHECK_STRUCT(obd_dqinfo);
423         CHECK_MEMBER(obd_dqinfo, dqi_bgrace);
424         CHECK_MEMBER(obd_dqinfo, dqi_igrace);
425         CHECK_MEMBER(obd_dqinfo, dqi_flags);
426         CHECK_MEMBER(obd_dqinfo, dqi_valid);
427
428         BLANK_LINE();
429         CHECK_STRUCT(obd_dqblk);
430         CHECK_MEMBER(obd_dqblk, dqb_bhardlimit);
431         CHECK_MEMBER(obd_dqblk, dqb_bsoftlimit);
432         CHECK_MEMBER(obd_dqblk, dqb_curspace);
433         CHECK_MEMBER(obd_dqblk, dqb_ihardlimit);
434         CHECK_MEMBER(obd_dqblk, dqb_isoftlimit);
435         CHECK_MEMBER(obd_dqblk, dqb_curinodes);
436         CHECK_MEMBER(obd_dqblk, dqb_btime);
437         CHECK_MEMBER(obd_dqblk, dqb_itime);
438         CHECK_MEMBER(obd_dqblk, dqb_valid);
439         CHECK_MEMBER(obd_dqblk, padding);
440
441         CHECK_DEFINE(Q_QUOTACHECK);
442         CHECK_DEFINE(Q_INITQUOTA);
443         CHECK_DEFINE(Q_GETOINFO);
444         CHECK_DEFINE(Q_GETOQUOTA);
445 }
446
447 static void
448 check_niobuf_remote(void)
449 {
450         BLANK_LINE();
451         CHECK_STRUCT(niobuf_remote);
452         CHECK_MEMBER(niobuf_remote, offset);
453         CHECK_MEMBER(niobuf_remote, len);
454         CHECK_MEMBER(niobuf_remote, flags);
455
456         CHECK_VALUE(OBD_BRW_READ);
457         CHECK_VALUE(OBD_BRW_WRITE);
458         CHECK_VALUE(OBD_BRW_SYNC);
459         CHECK_VALUE(OBD_BRW_FROM_GRANT);
460         CHECK_VALUE(OBD_BRW_NOQUOTA);
461 }
462
463 static void
464 check_ost_body(void)
465 {
466         BLANK_LINE();
467         CHECK_STRUCT(ost_body);
468         CHECK_MEMBER(ost_body, oa);
469 }
470
471 static void
472 check_ll_fid(void)
473 {
474         BLANK_LINE();
475         CHECK_STRUCT(ll_fid);
476         CHECK_MEMBER(ll_fid, id);
477         CHECK_MEMBER(ll_fid, generation);
478         CHECK_MEMBER(ll_fid, f_type);
479 }
480
481 static void
482 check_mds_status_req(void)
483 {
484         BLANK_LINE();
485         CHECK_STRUCT(mds_status_req);
486         CHECK_MEMBER(mds_status_req, flags);
487         CHECK_MEMBER(mds_status_req, repbuf);
488 }
489
490 static void
491 check_mds_body(void)
492 {
493         BLANK_LINE();
494         CHECK_STRUCT(mds_body);
495         CHECK_MEMBER(mds_body, fid1);
496         CHECK_MEMBER(mds_body, fid2);
497         CHECK_MEMBER(mds_body, handle);
498         CHECK_MEMBER(mds_body, size);
499         CHECK_MEMBER(mds_body, blocks);
500         CHECK_MEMBER(mds_body, io_epoch);
501         CHECK_MEMBER(mds_body, ino);
502         CHECK_MEMBER(mds_body, valid);
503         CHECK_MEMBER(mds_body, fsuid);
504         CHECK_MEMBER(mds_body, fsgid);
505         CHECK_MEMBER(mds_body, capability);
506         CHECK_MEMBER(mds_body, mode);
507         CHECK_MEMBER(mds_body, uid);
508         CHECK_MEMBER(mds_body, gid);
509         CHECK_MEMBER(mds_body, mtime);
510         CHECK_MEMBER(mds_body, ctime);
511         CHECK_MEMBER(mds_body, atime);
512         CHECK_MEMBER(mds_body, flags);
513         CHECK_MEMBER(mds_body, rdev);
514         CHECK_MEMBER(mds_body, nlink);
515         CHECK_MEMBER(mds_body, generation);
516         CHECK_MEMBER(mds_body, suppgid);
517         CHECK_MEMBER(mds_body, eadatasize);
518         CHECK_MEMBER(mds_body, aclsize);
519         CHECK_MEMBER(mds_body, max_mdsize);
520         CHECK_MEMBER(mds_body, max_cookiesize);
521         CHECK_MEMBER(mds_body, padding_4);
522
523         CHECK_VALUE(FMODE_READ);
524         CHECK_VALUE(FMODE_WRITE);
525         CHECK_VALUE(MDS_FMODE_EXEC);
526
527         CHECK_CDEFINE(MDS_OPEN_CREAT);
528         CHECK_CDEFINE(MDS_OPEN_EXCL);
529         CHECK_CDEFINE(MDS_OPEN_TRUNC);
530         CHECK_CDEFINE(MDS_OPEN_APPEND);
531         CHECK_CDEFINE(MDS_OPEN_SYNC);
532         CHECK_CDEFINE(MDS_OPEN_DIRECTORY);
533         CHECK_CDEFINE(MDS_OPEN_DELAY_CREATE);
534         CHECK_CDEFINE(MDS_OPEN_OWNEROVERRIDE);
535         CHECK_CDEFINE(MDS_OPEN_JOIN_FILE);
536         CHECK_CDEFINE(MDS_OPEN_HAS_EA);
537         CHECK_CDEFINE(MDS_OPEN_HAS_OBJS);
538
539         /* these should be identical to their EXT3_*_FL counterparts, and
540          * are redefined only to avoid dragging in ext3_fs.h */
541         CHECK_CDEFINE(MDS_SYNC_FL);
542         CHECK_CDEFINE(MDS_IMMUTABLE_FL);
543         CHECK_CDEFINE(MDS_APPEND_FL);
544         CHECK_CDEFINE(MDS_NOATIME_FL);
545         CHECK_CDEFINE(MDS_DIRSYNC_FL);
546         CHECK_CDEFINE(MDS_BFLAG_EXT_FLAGS);
547
548         CHECK_CDEFINE(MDS_INODELOCK_LOOKUP);
549         CHECK_CDEFINE(MDS_INODELOCK_UPDATE);
550         CHECK_CDEFINE(MDS_INODELOCK_OPEN);
551 }
552
553 static void
554 check_mds_rec_setattr(void)
555 {
556         BLANK_LINE();
557         CHECK_STRUCT(mds_rec_setattr);
558         CHECK_MEMBER(mds_rec_setattr, sa_opcode);
559         CHECK_MEMBER(mds_rec_setattr, sa_fsuid);
560         CHECK_MEMBER(mds_rec_setattr, sa_fsgid);
561         CHECK_MEMBER(mds_rec_setattr, sa_cap);
562         CHECK_MEMBER(mds_rec_setattr, sa_suppgid);
563         CHECK_MEMBER(mds_rec_setattr, sa_mode);
564         CHECK_MEMBER(mds_rec_setattr, sa_fid);
565         CHECK_MEMBER(mds_rec_setattr, sa_valid);
566         CHECK_MEMBER(mds_rec_setattr, sa_size);
567         CHECK_MEMBER(mds_rec_setattr, sa_mtime);
568         CHECK_MEMBER(mds_rec_setattr, sa_atime);
569         CHECK_MEMBER(mds_rec_setattr, sa_ctime);
570         CHECK_MEMBER(mds_rec_setattr, sa_uid);
571         CHECK_MEMBER(mds_rec_setattr, sa_gid);
572         CHECK_MEMBER(mds_rec_setattr, sa_attr_flags);
573         CHECK_CDEFINE(MDS_ATTR_MODE);
574         CHECK_CDEFINE(MDS_ATTR_UID);
575         CHECK_CDEFINE(MDS_ATTR_GID);
576         CHECK_CDEFINE(MDS_ATTR_SIZE);
577         CHECK_CDEFINE(MDS_ATTR_ATIME);
578         CHECK_CDEFINE(MDS_ATTR_MTIME);
579         CHECK_CDEFINE(MDS_ATTR_CTIME);
580         CHECK_CDEFINE(MDS_ATTR_ATIME_SET);
581         CHECK_CDEFINE(MDS_ATTR_MTIME_SET);
582         CHECK_CDEFINE(MDS_ATTR_FORCE);
583         CHECK_CDEFINE(MDS_ATTR_ATTR_FLAG);
584         CHECK_CDEFINE(MDS_ATTR_KILL_SUID);
585         CHECK_CDEFINE(MDS_ATTR_KILL_SGID);
586         CHECK_CDEFINE(MDS_ATTR_CTIME_SET);
587         CHECK_CDEFINE(MDS_ATTR_FROM_OPEN);
588         CHECK_CDEFINE(MDS_ATTR_BLOCKS);
589 }
590
591 static void
592 check_mds_rec_create(void)
593 {
594         BLANK_LINE();
595         CHECK_STRUCT(mds_rec_create);
596         CHECK_MEMBER(mds_rec_create, cr_opcode);
597         CHECK_MEMBER(mds_rec_create, cr_fsuid);
598         CHECK_MEMBER(mds_rec_create, cr_fsgid);
599         CHECK_MEMBER(mds_rec_create, cr_cap);
600         CHECK_MEMBER(mds_rec_create, cr_flags);
601         CHECK_MEMBER(mds_rec_create, cr_mode);
602         CHECK_MEMBER(mds_rec_create, cr_fid);
603         CHECK_MEMBER(mds_rec_create, cr_replayfid);
604         CHECK_MEMBER(mds_rec_create, cr_time);
605         CHECK_MEMBER(mds_rec_create, cr_rdev);
606         CHECK_MEMBER(mds_rec_create, cr_suppgid);
607 }
608
609 static void
610 check_mds_rec_link(void)
611 {
612         BLANK_LINE();
613         CHECK_STRUCT(mds_rec_link);
614         CHECK_MEMBER(mds_rec_link, lk_opcode);
615         CHECK_MEMBER(mds_rec_link, lk_fsuid);
616         CHECK_MEMBER(mds_rec_link, lk_fsgid);
617         CHECK_MEMBER(mds_rec_link, lk_cap);
618         CHECK_MEMBER(mds_rec_link, lk_suppgid1);
619         CHECK_MEMBER(mds_rec_link, lk_suppgid2);
620         CHECK_MEMBER(mds_rec_link, lk_fid1);
621         CHECK_MEMBER(mds_rec_link, lk_fid2);
622         CHECK_MEMBER(mds_rec_link, lk_time);
623 }
624
625 static void
626 check_mds_rec_unlink(void)
627 {
628         BLANK_LINE();
629         CHECK_STRUCT(mds_rec_unlink);
630         CHECK_MEMBER(mds_rec_unlink, ul_opcode);
631         CHECK_MEMBER(mds_rec_unlink, ul_fsuid);
632         CHECK_MEMBER(mds_rec_unlink, ul_fsgid);
633         CHECK_MEMBER(mds_rec_unlink, ul_cap);
634         CHECK_MEMBER(mds_rec_unlink, ul_suppgid);
635         CHECK_MEMBER(mds_rec_unlink, ul_mode);
636         CHECK_MEMBER(mds_rec_unlink, ul_fid1);
637         CHECK_MEMBER(mds_rec_unlink, ul_fid2);
638         CHECK_MEMBER(mds_rec_unlink, ul_time);
639 }
640
641 static void
642 check_mds_rec_rename(void)
643 {
644         BLANK_LINE();
645         CHECK_STRUCT(mds_rec_rename);
646         CHECK_MEMBER(mds_rec_rename, rn_opcode);
647         CHECK_MEMBER(mds_rec_rename, rn_fsuid);
648         CHECK_MEMBER(mds_rec_rename, rn_fsgid);
649         CHECK_MEMBER(mds_rec_rename, rn_cap);
650         CHECK_MEMBER(mds_rec_rename, rn_suppgid1);
651         CHECK_MEMBER(mds_rec_rename, rn_suppgid2);
652         CHECK_MEMBER(mds_rec_rename, rn_fid1);
653         CHECK_MEMBER(mds_rec_rename, rn_fid2);
654         CHECK_MEMBER(mds_rec_rename, rn_time);
655 }
656
657 static void
658 check_mds_rec_join(void)
659 {
660         BLANK_LINE();
661         CHECK_STRUCT(mds_rec_join);
662         CHECK_MEMBER(mds_rec_join, jr_fid);
663         CHECK_MEMBER(mds_rec_join, jr_headsize);
664 }
665
666 static void
667 check_lov_desc(void)
668 {
669         BLANK_LINE();
670         CHECK_STRUCT(lov_desc);
671         CHECK_MEMBER(lov_desc, ld_tgt_count);
672         CHECK_MEMBER(lov_desc, ld_active_tgt_count);
673         CHECK_MEMBER(lov_desc, ld_default_stripe_count);
674         CHECK_MEMBER(lov_desc, ld_pattern);
675         CHECK_MEMBER(lov_desc, ld_default_stripe_size);
676         CHECK_MEMBER(lov_desc, ld_default_stripe_offset);
677         CHECK_MEMBER(lov_desc, ld_qos_maxage);
678         CHECK_MEMBER(lov_desc, ld_padding_1);
679         CHECK_MEMBER(lov_desc, ld_padding_2);
680         CHECK_MEMBER(lov_desc, ld_uuid);
681 }
682
683 static void
684 check_ldlm_res_id(void)
685 {
686         BLANK_LINE();
687         CHECK_STRUCT(ldlm_res_id);
688         CHECK_MEMBER(ldlm_res_id, name[RES_NAME_SIZE]);
689 }
690
691 static void
692 check_ldlm_extent(void)
693 {
694         BLANK_LINE();
695         CHECK_STRUCT(ldlm_extent);
696         CHECK_MEMBER(ldlm_extent, start);
697         CHECK_MEMBER(ldlm_extent, end);
698         CHECK_MEMBER(ldlm_extent, gid);
699 }
700
701 static void
702 check_ldlm_inodebits(void)
703 {
704         BLANK_LINE();
705         CHECK_STRUCT(ldlm_inodebits);
706         CHECK_MEMBER(ldlm_inodebits, bits);
707 }
708
709 static void
710 check_ldlm_flock(void)
711 {
712         BLANK_LINE();
713         CHECK_STRUCT(ldlm_flock);
714         CHECK_MEMBER(ldlm_flock, start);
715         CHECK_MEMBER(ldlm_flock, end);
716         CHECK_MEMBER(ldlm_flock, blocking_pid);
717         CHECK_MEMBER(ldlm_flock, pid);
718 }
719
720 static void
721 check_ldlm_intent(void)
722 {
723         BLANK_LINE();
724         CHECK_STRUCT(ldlm_intent);
725         CHECK_MEMBER(ldlm_intent, opc);
726 }
727
728 static void
729 check_ldlm_resource_desc(void)
730 {
731         BLANK_LINE();
732         CHECK_STRUCT(ldlm_resource_desc);
733         CHECK_MEMBER(ldlm_resource_desc, lr_type);
734         CHECK_MEMBER(ldlm_resource_desc, lr_padding);
735         CHECK_MEMBER(ldlm_resource_desc, lr_name);
736 }
737
738 static void
739 check_ldlm_lock_desc(void)
740 {
741         BLANK_LINE();
742         CHECK_STRUCT(ldlm_lock_desc);
743         CHECK_MEMBER(ldlm_lock_desc, l_resource);
744         CHECK_MEMBER(ldlm_lock_desc, l_req_mode);
745         CHECK_MEMBER(ldlm_lock_desc, l_granted_mode);
746         CHECK_MEMBER(ldlm_lock_desc, l_policy_data);
747 }
748
749 static void
750 check_ldlm_request(void)
751 {
752         BLANK_LINE();
753         CHECK_STRUCT(ldlm_request);
754         CHECK_MEMBER(ldlm_request, lock_flags);
755         CHECK_MEMBER(ldlm_request, lock_count);
756         CHECK_MEMBER(ldlm_request, lock_desc);
757         CHECK_MEMBER(ldlm_request, lock_handle);
758 }
759
760 static void
761 check_ldlm_reply(void)
762 {
763         BLANK_LINE();
764         CHECK_STRUCT(ldlm_reply);
765         CHECK_MEMBER(ldlm_reply, lock_flags);
766         CHECK_MEMBER(ldlm_reply, lock_padding);
767         CHECK_MEMBER(ldlm_reply, lock_desc);
768         CHECK_MEMBER(ldlm_reply, lock_handle);
769         CHECK_MEMBER(ldlm_reply, lock_policy_res1);
770         CHECK_MEMBER(ldlm_reply, lock_policy_res2);
771 }
772
773 static void
774 check_ldlm_lvb(void)
775 {
776         BLANK_LINE();
777         CHECK_STRUCT(ost_lvb);
778         CHECK_MEMBER(ost_lvb, lvb_size);
779         CHECK_MEMBER(ost_lvb, lvb_mtime);
780         CHECK_MEMBER(ost_lvb, lvb_atime);
781         CHECK_MEMBER(ost_lvb, lvb_ctime);
782         CHECK_MEMBER(ost_lvb, lvb_blocks);
783 }
784
785
786 static void
787 check_llog_logid(void)
788 {
789         BLANK_LINE();
790         CHECK_STRUCT(llog_logid);
791         CHECK_MEMBER(llog_logid, lgl_oid);
792         CHECK_MEMBER(llog_logid, lgl_ogr);
793         CHECK_MEMBER(llog_logid, lgl_ogen);
794
795         CHECK_CVALUE(OST_SZ_REC);
796         CHECK_CVALUE(OST_RAID1_REC);
797         CHECK_CVALUE(MDS_UNLINK_REC);
798         CHECK_CVALUE(MDS_SETATTR_REC);
799         CHECK_CVALUE(OBD_CFG_REC);
800         CHECK_CVALUE(PTL_CFG_REC);
801         CHECK_CVALUE(LLOG_GEN_REC);
802         CHECK_CVALUE(LLOG_JOIN_REC);
803         CHECK_CVALUE(LLOG_HDR_MAGIC);
804         CHECK_CVALUE(LLOG_LOGID_MAGIC);
805 }
806
807 static void
808 check_llog_catid(void)
809 {
810         BLANK_LINE();
811         CHECK_STRUCT(llog_catid);
812         CHECK_MEMBER(llog_catid, lci_logid);
813         CHECK_MEMBER(llog_catid, lci_padding1);
814         CHECK_MEMBER(llog_catid, lci_padding2);
815         CHECK_MEMBER(llog_catid, lci_padding3);
816 }
817
818 static void
819 check_llog_rec_hdr(void)
820 {
821         BLANK_LINE();
822         CHECK_STRUCT(llog_rec_hdr);
823         CHECK_MEMBER(llog_rec_hdr, lrh_len);
824         CHECK_MEMBER(llog_rec_hdr, lrh_index);
825         CHECK_MEMBER(llog_rec_hdr, lrh_type);
826         CHECK_MEMBER(llog_rec_hdr, padding);
827 }
828
829 static void
830 check_llog_rec_tail(void)
831 {
832         BLANK_LINE();
833         CHECK_STRUCT(llog_rec_tail);
834         CHECK_MEMBER(llog_rec_tail, lrt_len);
835         CHECK_MEMBER(llog_rec_tail, lrt_index);
836 }
837
838 static void
839 check_llog_logid_rec(void)
840 {
841         BLANK_LINE();
842         CHECK_STRUCT(llog_logid_rec);
843         CHECK_MEMBER(llog_logid_rec, lid_hdr);
844         CHECK_MEMBER(llog_logid_rec, lid_id);
845         CHECK_MEMBER(llog_logid_rec, padding1);
846         CHECK_MEMBER(llog_logid_rec, padding2);
847         CHECK_MEMBER(llog_logid_rec, padding3);
848         CHECK_MEMBER(llog_logid_rec, padding4);
849         CHECK_MEMBER(llog_logid_rec, padding5);
850         CHECK_MEMBER(llog_logid_rec, lid_tail);
851 }
852
853 static void
854 check_llog_create_rec(void)
855 {
856         BLANK_LINE();
857         CHECK_STRUCT(llog_create_rec);
858         CHECK_MEMBER(llog_create_rec, lcr_hdr);
859         CHECK_MEMBER(llog_create_rec, lcr_fid);
860         CHECK_MEMBER(llog_create_rec, lcr_oid);
861         CHECK_MEMBER(llog_create_rec, lcr_ogen);
862         CHECK_MEMBER(llog_create_rec, padding);
863 }
864
865 static void
866 check_llog_orphan_rec(void)
867 {
868         BLANK_LINE();
869         CHECK_STRUCT(llog_orphan_rec);
870         CHECK_MEMBER(llog_orphan_rec, lor_hdr);
871         CHECK_MEMBER(llog_orphan_rec, lor_oid);
872         CHECK_MEMBER(llog_orphan_rec, lor_ogen);
873         CHECK_MEMBER(llog_orphan_rec, padding);
874         CHECK_MEMBER(llog_orphan_rec, lor_tail);
875 }
876
877 static void
878 check_llog_unlink_rec(void)
879 {
880         BLANK_LINE();
881         CHECK_STRUCT(llog_unlink_rec);
882         CHECK_MEMBER(llog_unlink_rec, lur_hdr);
883         CHECK_MEMBER(llog_unlink_rec, lur_oid);
884         CHECK_MEMBER(llog_unlink_rec, lur_ogen);
885         CHECK_MEMBER(llog_unlink_rec, padding);
886         CHECK_MEMBER(llog_unlink_rec, lur_tail);
887 }
888
889 static void
890 check_llog_setattr_rec(void)
891 {
892         BLANK_LINE();
893         CHECK_STRUCT(llog_setattr_rec);
894         CHECK_MEMBER(llog_setattr_rec, lsr_hdr);
895         CHECK_MEMBER(llog_setattr_rec, lsr_oid);
896         CHECK_MEMBER(llog_setattr_rec, lsr_ogen);
897         CHECK_MEMBER(llog_setattr_rec, lsr_uid);
898         CHECK_MEMBER(llog_setattr_rec, lsr_gid);
899         CHECK_MEMBER(llog_setattr_rec, padding);
900         CHECK_MEMBER(llog_setattr_rec, lsr_tail);
901 }
902
903 static void
904 check_llog_size_change_rec(void)
905 {
906         BLANK_LINE();
907         CHECK_STRUCT(llog_size_change_rec);
908         CHECK_MEMBER(llog_size_change_rec, lsc_hdr);
909         CHECK_MEMBER(llog_size_change_rec, lsc_fid);
910         CHECK_MEMBER(llog_size_change_rec, lsc_ioepoch);
911         CHECK_MEMBER(llog_size_change_rec, padding);
912         CHECK_MEMBER(llog_size_change_rec, lsc_tail);
913 }
914
915 static void
916 check_llog_gen(void)
917 {
918         BLANK_LINE();
919         CHECK_STRUCT(llog_gen);
920         CHECK_MEMBER(llog_gen, mnt_cnt);
921         CHECK_MEMBER(llog_gen, conn_cnt);
922 }
923
924 static void
925 check_llog_gen_rec(void)
926 {
927         BLANK_LINE();
928         CHECK_STRUCT(llog_gen_rec);
929         CHECK_MEMBER(llog_gen_rec, lgr_hdr);
930         CHECK_MEMBER(llog_gen_rec, lgr_gen);
931         CHECK_MEMBER(llog_gen_rec, lgr_tail);
932 }
933
934 static void
935 check_llog_log_hdr(void)
936 {
937         BLANK_LINE();
938         CHECK_STRUCT(llog_log_hdr);
939         CHECK_MEMBER(llog_log_hdr, llh_hdr);
940         CHECK_MEMBER(llog_log_hdr, llh_timestamp);
941         CHECK_MEMBER(llog_log_hdr, llh_count);
942         CHECK_MEMBER(llog_log_hdr, llh_bitmap_offset);
943         CHECK_MEMBER(llog_log_hdr, llh_size);
944         CHECK_MEMBER(llog_log_hdr, llh_flags);
945         CHECK_MEMBER(llog_log_hdr, llh_cat_idx);
946         CHECK_MEMBER(llog_log_hdr, llh_tgtuuid);
947         CHECK_MEMBER(llog_log_hdr, llh_reserved);
948         CHECK_MEMBER(llog_log_hdr, llh_bitmap);
949         CHECK_MEMBER(llog_log_hdr, llh_tail);
950 }
951
952 static void
953 check_llog_cookie(void)
954 {
955         BLANK_LINE();
956         CHECK_STRUCT(llog_cookie);
957         CHECK_MEMBER(llog_cookie, lgc_lgl);
958         CHECK_MEMBER(llog_cookie, lgc_subsys);
959         CHECK_MEMBER(llog_cookie, lgc_index);
960         CHECK_MEMBER(llog_cookie, lgc_padding);
961 }
962
963 static void
964 check_llogd_body(void)
965 {
966         BLANK_LINE();
967         CHECK_STRUCT(llogd_body);
968         CHECK_MEMBER(llogd_body, lgd_logid);
969         CHECK_MEMBER(llogd_body, lgd_ctxt_idx);
970         CHECK_MEMBER(llogd_body, lgd_llh_flags);
971         CHECK_MEMBER(llogd_body, lgd_index);
972         CHECK_MEMBER(llogd_body, lgd_saved_index);
973         CHECK_MEMBER(llogd_body, lgd_len);
974         CHECK_MEMBER(llogd_body, lgd_cur_offset);
975
976         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_CREATE);
977         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
978         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_READ_HEADER);
979         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_WRITE_REC);
980         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_CLOSE);
981         CHECK_CVALUE(LLOG_ORIGIN_CONNECT);
982         CHECK_CVALUE(LLOG_CATINFO);
983         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_PREV_BLOCK);
984         CHECK_CVALUE(LLOG_ORIGIN_HANDLE_DESTROY);
985 }
986
987 static void
988 check_llogd_conn_body(void)
989 {
990         BLANK_LINE();
991         CHECK_STRUCT(llogd_conn_body);
992         CHECK_MEMBER(llogd_conn_body, lgdc_gen);
993         CHECK_MEMBER(llogd_conn_body, lgdc_logid);
994         CHECK_MEMBER(llogd_conn_body, lgdc_ctxt_idx);
995 }
996
997 static void
998 check_mds_extent_desc(void)
999 {
1000         BLANK_LINE();
1001         CHECK_STRUCT(mds_extent_desc);
1002         CHECK_MEMBER(mds_extent_desc, med_start);
1003         CHECK_MEMBER(mds_extent_desc, med_len);
1004         CHECK_MEMBER(mds_extent_desc, med_lmm);
1005 }
1006
1007 static void
1008 check_llog_array_rec(void)
1009 {
1010         BLANK_LINE();
1011         CHECK_STRUCT(llog_array_rec);
1012         CHECK_MEMBER(llog_array_rec, lmr_hdr);
1013         CHECK_MEMBER(llog_array_rec, lmr_med);
1014         CHECK_MEMBER(llog_array_rec, lmr_tail);
1015 }
1016
1017 static void
1018 check_qunit_data(void)
1019 {
1020         BLANK_LINE();
1021         CHECK_STRUCT(qunit_data);
1022         CHECK_MEMBER(qunit_data, qd_id);
1023         CHECK_MEMBER(qunit_data, qd_flags);
1024         CHECK_MEMBER(qunit_data, qd_count);
1025 }
1026
1027 static void
1028 check_qunit_data_old(void)
1029 {
1030         BLANK_LINE();
1031         CHECK_STRUCT(qunit_data_old);
1032         CHECK_MEMBER(qunit_data_old, qd_id);
1033         CHECK_MEMBER(qunit_data_old, qd_type);
1034         CHECK_MEMBER(qunit_data_old, qd_count);
1035         CHECK_MEMBER(qunit_data_old, qd_isblk);
1036 }
1037
1038 static void
1039 check_mgs_target_info(void)
1040 {
1041         BLANK_LINE();
1042         CHECK_STRUCT(mgs_target_info);
1043         CHECK_MEMBER(mgs_target_info, mti_lustre_ver);
1044         CHECK_MEMBER(mgs_target_info, mti_stripe_index);
1045         CHECK_MEMBER(mgs_target_info, mti_config_ver);
1046         CHECK_MEMBER(mgs_target_info, mti_flags);
1047         CHECK_MEMBER(mgs_target_info, mti_nid_count);
1048         CHECK_MEMBER(mgs_target_info, mti_fsname);
1049         CHECK_MEMBER(mgs_target_info, mti_svname);
1050         CHECK_MEMBER(mgs_target_info, mti_uuid);
1051         CHECK_MEMBER(mgs_target_info, mti_nids);
1052         CHECK_MEMBER(mgs_target_info, mti_params);
1053 }
1054
1055 static void
1056 check_lustre_disk_data(void)
1057 {
1058         BLANK_LINE();
1059         CHECK_STRUCT(lustre_disk_data);
1060         CHECK_MEMBER(lustre_disk_data, ldd_magic);
1061         CHECK_MEMBER(lustre_disk_data, ldd_feature_compat);
1062         CHECK_MEMBER(lustre_disk_data, ldd_feature_rocompat);
1063         CHECK_MEMBER(lustre_disk_data, ldd_feature_incompat);
1064         CHECK_MEMBER(lustre_disk_data, ldd_config_ver);
1065         CHECK_MEMBER(lustre_disk_data, ldd_flags);
1066         CHECK_MEMBER(lustre_disk_data, ldd_svindex);
1067         CHECK_MEMBER(lustre_disk_data, ldd_mount_type);
1068         CHECK_MEMBER(lustre_disk_data, ldd_fsname);
1069         CHECK_MEMBER(lustre_disk_data, ldd_svname);
1070         CHECK_MEMBER(lustre_disk_data, ldd_uuid);
1071         CHECK_MEMBER(lustre_disk_data, ldd_userdata);
1072         CHECK_MEMBER(lustre_disk_data, ldd_mount_opts);
1073         CHECK_MEMBER(lustre_disk_data, ldd_params);
1074 }
1075
1076 static void
1077 check_posix_acl_xattr_entry(void)
1078 {
1079         BLANK_LINE();
1080         CHECK_STRUCT_TYPEDEF(posix_acl_xattr_entry);
1081         CHECK_MEMBER_TYPEDEF(posix_acl_xattr_entry, e_tag);
1082         CHECK_MEMBER_TYPEDEF(posix_acl_xattr_entry, e_perm);
1083         CHECK_MEMBER_TYPEDEF(posix_acl_xattr_entry, e_id);
1084 }
1085
1086 static void
1087 check_posix_acl_xattr_header(void)
1088 {
1089         BLANK_LINE();
1090         CHECK_STRUCT_TYPEDEF(posix_acl_xattr_header);
1091         CHECK_MEMBER_TYPEDEF(posix_acl_xattr_header, a_version);
1092         CHECK_MEMBER_TYPEDEF(posix_acl_xattr_header, a_entries);
1093 }
1094
1095 static void
1096 check_ll_user_fiemap(void)
1097 {
1098         BLANK_LINE();
1099         CHECK_STRUCT(ll_user_fiemap);
1100         CHECK_MEMBER(ll_user_fiemap, fm_start);
1101         CHECK_MEMBER(ll_user_fiemap, fm_length);
1102         CHECK_MEMBER(ll_user_fiemap, fm_flags);
1103         CHECK_MEMBER(ll_user_fiemap, fm_mapped_extents);
1104         CHECK_MEMBER(ll_user_fiemap, fm_extent_count);
1105         CHECK_MEMBER(ll_user_fiemap, fm_reserved);
1106         CHECK_MEMBER(ll_user_fiemap, fm_extents);
1107
1108         CHECK_CDEFINE(FIEMAP_FLAG_SYNC);
1109         CHECK_CDEFINE(FIEMAP_FLAG_XATTR);
1110         CHECK_CDEFINE(FIEMAP_FLAG_DEVICE_ORDER);
1111 }
1112
1113 static void
1114 check_ll_fiemap_extent(void)
1115 {
1116         BLANK_LINE();
1117         CHECK_STRUCT(ll_fiemap_extent);
1118         CHECK_MEMBER(ll_fiemap_extent, fe_logical);
1119         CHECK_MEMBER(ll_fiemap_extent, fe_physical);
1120         CHECK_MEMBER(ll_fiemap_extent, fe_length);
1121         CHECK_MEMBER(ll_fiemap_extent, fe_flags);
1122         CHECK_MEMBER(ll_fiemap_extent, fe_device);
1123
1124         CHECK_CDEFINE(FIEMAP_EXTENT_LAST);
1125         CHECK_CDEFINE(FIEMAP_EXTENT_UNKNOWN);
1126         CHECK_CDEFINE(FIEMAP_EXTENT_DELALLOC);
1127         CHECK_CDEFINE(FIEMAP_EXTENT_NO_DIRECT);
1128         CHECK_CDEFINE(FIEMAP_EXTENT_SECONDARY);
1129         CHECK_CDEFINE(FIEMAP_EXTENT_NET);
1130         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_COMPRESSED);
1131         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_ENCRYPTED);
1132         CHECK_CDEFINE(FIEMAP_EXTENT_NOT_ALIGNED);
1133         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_INLINE);
1134         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_TAIL);
1135         CHECK_CDEFINE(FIEMAP_EXTENT_UNWRITTEN);
1136         CHECK_CDEFINE(FIEMAP_EXTENT_MERGED);
1137 }
1138
1139 static void
1140 system_string (char *cmdline, char *str, int len)
1141 {
1142         int   fds[2];
1143         int   rc;
1144         pid_t pid;
1145
1146         rc = pipe(fds);
1147         if (rc != 0)
1148                 abort();
1149
1150         pid = fork();
1151         if (pid == 0) {
1152                 /* child */
1153                 int   fd = fileno(stdout);
1154
1155                 rc = dup2(fds[1], fd);
1156                 if (rc != fd)
1157                         abort();
1158
1159                 exit(system(cmdline));
1160                 /* notreached */
1161         } else if ((int)pid < 0) {
1162                 abort();
1163         } else {
1164                 FILE *f = fdopen(fds[0], "r");
1165
1166                 if (f == NULL)
1167                         abort();
1168
1169                 close(fds[1]);
1170
1171                 if (fgets(str, len, f) == NULL)
1172                         abort();
1173
1174                 if (waitpid(pid, &rc, 0) != pid)
1175                         abort();
1176
1177                 if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
1178                         abort();
1179
1180                 if (strnlen(str, len) == len)
1181                         str[len - 1] = 0;
1182
1183                 if (str[strlen(str) - 1] == '\n')
1184                         str[strlen(str) - 1] = 0;
1185
1186                 fclose(f);
1187         }
1188 }
1189
1190 int
1191 main(int argc, char **argv)
1192 {
1193         char unameinfo[80];
1194         char gccinfo[80];
1195
1196         system_string("uname -a", unameinfo, sizeof(unameinfo));
1197         system_string(CC " -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
1198
1199         printf ("void lustre_assert_wire_constants(void)\n"
1200                 "{\n"
1201                 "        /* Wire protocol assertions generated by 'wirecheck'\n"
1202                 "         * (make -C lustre/utils newwiretest)\n"
1203                 "         * running on %s\n"
1204                 "         * with %s */\n"
1205                 "\n", unameinfo, gccinfo);
1206
1207         BLANK_LINE ();
1208
1209         COMMENT("Constants...");
1210         CHECK_DEFINE(LUSTRE_MSG_MAGIC_V2);
1211         CHECK_DEFINE(PTLRPC_MSG_VERSION);
1212         CHECK_VALUE(MSGHDR_AT_SUPPORT);
1213
1214         CHECK_VALUE(PTL_RPC_MSG_REQUEST);
1215         CHECK_VALUE(PTL_RPC_MSG_ERR);
1216         CHECK_VALUE(PTL_RPC_MSG_REPLY);
1217
1218         CHECK_VALUE(MSG_LAST_REPLAY);
1219         CHECK_VALUE(MSG_RESENT);
1220         CHECK_VALUE(MSG_REPLAY);
1221
1222         CHECK_VALUE(MSG_CONNECT_RECOVERING);
1223         CHECK_VALUE(MSG_CONNECT_RECONNECT);
1224         CHECK_VALUE(MSG_CONNECT_REPLAYABLE);
1225
1226         CHECK_VALUE(OST_REPLY);
1227         CHECK_VALUE(OST_GETATTR);
1228         CHECK_VALUE(OST_SETATTR);
1229         CHECK_VALUE(OST_READ);
1230         CHECK_VALUE(OST_WRITE);
1231         CHECK_VALUE(OST_CREATE);
1232         CHECK_VALUE(OST_DESTROY);
1233         CHECK_VALUE(OST_GET_INFO);
1234         CHECK_VALUE(OST_CONNECT);
1235         CHECK_VALUE(OST_DISCONNECT);
1236         CHECK_VALUE(OST_PUNCH);
1237         CHECK_VALUE(OST_OPEN);
1238         CHECK_VALUE(OST_CLOSE);
1239         CHECK_VALUE(OST_STATFS);
1240         CHECK_VALUE(OST_SYNC);
1241         CHECK_VALUE(OST_QUOTACHECK);
1242         CHECK_VALUE(OST_QUOTACTL);
1243         CHECK_VALUE(OST_LAST_OPC);
1244
1245         CHECK_DEFINE(OBD_OBJECT_EOF);
1246
1247         CHECK_VALUE(MDS_GETATTR);
1248         CHECK_VALUE(MDS_GETATTR_NAME);
1249         CHECK_VALUE(MDS_CLOSE);
1250         CHECK_VALUE(MDS_REINT);
1251         CHECK_VALUE(MDS_READPAGE);
1252         CHECK_VALUE(MDS_CONNECT);
1253         CHECK_VALUE(MDS_DISCONNECT);
1254         CHECK_VALUE(MDS_GETSTATUS);
1255         CHECK_VALUE(MDS_STATFS);
1256         CHECK_VALUE(MDS_PIN);
1257         CHECK_VALUE(MDS_UNPIN);
1258         CHECK_VALUE(MDS_SYNC);
1259         CHECK_VALUE(MDS_DONE_WRITING);
1260         CHECK_VALUE(MDS_SET_INFO);
1261         CHECK_VALUE(MDS_QUOTACHECK);
1262         CHECK_VALUE(MDS_QUOTACTL);
1263         CHECK_VALUE(MDS_LAST_OPC);
1264
1265         CHECK_VALUE(REINT_SETATTR);
1266         CHECK_VALUE(REINT_CREATE);
1267         CHECK_VALUE(REINT_LINK);
1268         CHECK_VALUE(REINT_UNLINK);
1269         CHECK_VALUE(REINT_RENAME);
1270         CHECK_VALUE(REINT_OPEN);
1271         CHECK_VALUE(REINT_MAX);
1272
1273         CHECK_VALUE(MGS_CONNECT);
1274         CHECK_VALUE(MGS_DISCONNECT);
1275         CHECK_VALUE(MGS_EXCEPTION);
1276         CHECK_VALUE(MGS_TARGET_REG);
1277         CHECK_VALUE(MGS_TARGET_DEL);
1278         CHECK_VALUE(MGS_SET_INFO);
1279
1280         CHECK_VALUE(DISP_IT_EXECD);
1281         CHECK_VALUE(DISP_LOOKUP_EXECD);
1282         CHECK_VALUE(DISP_LOOKUP_NEG);
1283         CHECK_VALUE(DISP_LOOKUP_POS);
1284         CHECK_VALUE(DISP_OPEN_CREATE);
1285         CHECK_VALUE(DISP_OPEN_OPEN);
1286
1287         CHECK_VALUE(MDS_STATUS_CONN);
1288         CHECK_VALUE(MDS_STATUS_LOV);
1289
1290         CHECK_VALUE(LDLM_ENQUEUE);
1291         CHECK_VALUE(LDLM_CONVERT);
1292         CHECK_VALUE(LDLM_CANCEL);
1293         CHECK_VALUE(LDLM_BL_CALLBACK);
1294         CHECK_VALUE(LDLM_CP_CALLBACK);
1295         CHECK_VALUE(LDLM_GL_CALLBACK);
1296         CHECK_VALUE(LDLM_LAST_OPC);
1297
1298         CHECK_VALUE(LCK_EX);
1299         CHECK_VALUE(LCK_PW);
1300         CHECK_VALUE(LCK_PR);
1301         CHECK_VALUE(LCK_CW);
1302         CHECK_VALUE(LCK_CR);
1303         CHECK_VALUE(LCK_NL);
1304         CHECK_VALUE(LCK_GROUP);
1305         CHECK_VALUE(LCK_MAXMODE);
1306         CHECK_VALUE(LCK_MODE_NUM);
1307
1308         CHECK_CVALUE(LDLM_PLAIN);
1309         CHECK_CVALUE(LDLM_EXTENT);
1310         CHECK_CVALUE(LDLM_FLOCK);
1311         CHECK_CVALUE(LDLM_IBITS);
1312
1313         CHECK_VALUE(OBD_PING);
1314         CHECK_VALUE(OBD_LOG_CANCEL);
1315         CHECK_VALUE(OBD_QC_CALLBACK);
1316         CHECK_VALUE(OBD_LAST_OPC);
1317
1318         CHECK_VALUE(QUOTA_DQACQ);
1319         CHECK_VALUE(QUOTA_DQREL);
1320
1321         CHECK_VALUE(MGS_CONNECT);
1322         CHECK_VALUE(MGS_DISCONNECT);
1323         CHECK_VALUE(MGS_EXCEPTION);   
1324         CHECK_VALUE(MGS_TARGET_REG);
1325         CHECK_VALUE(MGS_TARGET_DEL);
1326         CHECK_VALUE(MGS_SET_INFO);
1327
1328         COMMENT("Sizes and Offsets");
1329         BLANK_LINE();
1330         CHECK_STRUCT(obd_uuid);
1331         check_lustre_handle();
1332         check_lustre_msg_v2();
1333         check_ptlrpc_body();
1334         check_obd_connect_data();
1335         check_obdo();
1336         check_lov_mds_md_v1();
1337         check_lov_mds_md_v3();
1338         check_lov_mds_md_join();
1339         check_obd_statfs();
1340         check_obd_ioobj();
1341         check_obd_quotactl();
1342         check_niobuf_remote();
1343         check_ost_body();
1344         check_ll_fid();
1345         check_mds_status_req();
1346         check_mds_body();
1347         check_mds_rec_setattr();
1348         check_mds_rec_create();
1349         check_mds_rec_link();
1350         check_mds_rec_unlink();
1351         check_mds_rec_rename();
1352         check_mds_rec_join();
1353         check_lov_desc();
1354         check_ldlm_res_id();
1355         check_ldlm_extent();
1356         check_ldlm_flock();
1357         check_ldlm_inodebits();
1358         check_ldlm_intent();
1359         check_ldlm_resource_desc();
1360         check_ldlm_lock_desc();
1361         check_ldlm_request();
1362         check_ldlm_reply();
1363         check_ldlm_lvb();
1364         check_llog_logid();
1365         check_llog_catid();
1366         check_llog_rec_hdr();
1367         check_llog_rec_tail();
1368         check_llog_logid_rec();
1369         check_llog_create_rec();
1370         check_llog_orphan_rec();
1371         check_llog_unlink_rec();
1372         check_llog_setattr_rec();
1373         check_llog_size_change_rec();
1374         check_llog_gen();
1375         check_llog_gen_rec();
1376         check_llog_log_hdr();
1377         check_llog_cookie();
1378         check_llogd_body();
1379         check_llogd_conn_body();
1380         check_llog_array_rec();
1381         check_mds_extent_desc();
1382         check_qunit_data();
1383         check_qunit_data_old();
1384         check_mgs_target_info();
1385         check_lustre_disk_data();
1386         check_ll_user_fiemap();
1387         check_ll_fiemap_extent();
1388         printf("#ifdef LIBLUSTRE_POSIX_ACL\n");
1389 #ifndef LIBLUSTRE_POSIX_ACL
1390 #error build generator without LIBLUSTRE_POSIX_ACL defined - produce wrong check code.
1391 #endif
1392         check_posix_acl_xattr_entry();
1393         check_posix_acl_xattr_header();
1394         printf("#endif\n");
1395
1396
1397         printf("}\n\n");
1398
1399         return(0);
1400 }