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