Whamcloud - gitweb
18810ae076e85b238063887bff1335c318e11ed9
[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 #include <stdio.h>
5 #include <liblustre.h>
6 #include <linux/lustre_lib.h>
7 #include <linux/lustre_idl.h>
8
9 #define BLANK_LINE()                                            \
10 do {                                                            \
11         printf("\n");                                           \
12 } while(0)
13
14 #define COMMENT(c)                                              \
15 do {                                                            \
16         printf("        /* "c" */\n");                          \
17 } while(0)
18
19 #define STRINGIFY(a) #a
20
21 #define CHECK_DEFINE(a)                                         \
22 do {                                                            \
23         printf("        LASSERT("#a" == "STRINGIFY(a)");\n");   \
24 } while(0)
25
26 #define CHECK_VALUE(a)                                          \
27 do {                                                            \
28         printf("        LASSERT("#a" == %d);\n", a);            \
29 } while(0)
30
31 #define CHECK_MEMBER_OFFSET(s,m)                                \
32 do {                                                            \
33         CHECK_VALUE(offsetof(struct s, m));                     \
34 } while(0)
35
36 #define CHECK_MEMBER_SIZEOF(s,m)                                \
37 do {                                                            \
38         CHECK_VALUE((int)sizeof(((struct s *)0)->m));           \
39 } while(0)
40
41 #define CHECK_MEMBER(s,m)                                       \
42 do {                                                            \
43         CHECK_MEMBER_OFFSET(s, m);                              \
44                 CHECK_MEMBER_SIZEOF(s, m);                      \
45 } while(0)
46
47 #define CHECK_STRUCT(s)                                         \
48 do {                                                            \
49         COMMENT("Checks for struct "#s);                        \
50                 CHECK_VALUE((int)sizeof(struct s));             \
51 } while(0)
52
53
54
55 void check1(void)
56 {
57 #define VALUE 1234567
58
59         CHECK_VALUE(VALUE);
60         CHECK_DEFINE(VALUE);
61 }
62
63 void
64 check_lustre_handle(void)
65 {
66         BLANK_LINE();
67         CHECK_STRUCT(lustre_handle);
68         CHECK_MEMBER(lustre_handle, cookie);
69 }
70
71 void
72 check_lustre_msg(void)
73 {
74         BLANK_LINE();
75         CHECK_STRUCT(lustre_msg);
76         CHECK_MEMBER(lustre_msg, handle);
77         CHECK_MEMBER(lustre_msg, magic);
78         CHECK_MEMBER(lustre_msg, type);
79         CHECK_MEMBER(lustre_msg, version);
80         CHECK_MEMBER(lustre_msg, opc);
81         CHECK_MEMBER(lustre_msg, last_xid);
82         CHECK_MEMBER(lustre_msg, last_committed);
83         CHECK_MEMBER(lustre_msg, transno);
84         CHECK_MEMBER(lustre_msg, status);
85         CHECK_MEMBER(lustre_msg, flags);
86         CHECK_MEMBER(lustre_msg, bufcount);
87         CHECK_MEMBER(lustre_msg, buflens[7]);
88 }
89
90 void
91 check_obdo(void)
92 {
93         BLANK_LINE();
94         CHECK_STRUCT(obdo);
95         CHECK_MEMBER(obdo, o_id);
96         CHECK_MEMBER(obdo, o_gr);
97         CHECK_MEMBER(obdo, o_atime);
98         CHECK_MEMBER(obdo, o_mtime);
99         CHECK_MEMBER(obdo, o_ctime);
100         CHECK_MEMBER(obdo, o_size);
101         CHECK_MEMBER(obdo, o_blocks);
102         CHECK_MEMBER(obdo, o_rdev);
103         CHECK_MEMBER(obdo, o_blksize);
104         CHECK_MEMBER(obdo, o_mode);
105         CHECK_MEMBER(obdo, o_uid);
106         CHECK_MEMBER(obdo, o_gid);
107         CHECK_MEMBER(obdo, o_flags);
108         CHECK_MEMBER(obdo, o_nlink);
109         CHECK_MEMBER(obdo, o_generation);
110         CHECK_MEMBER(obdo, o_valid);
111         CHECK_MEMBER(obdo, o_obdflags);
112         CHECK_MEMBER(obdo, o_easize);
113         CHECK_MEMBER(obdo, o_inline);
114
115         CHECK_VALUE(OBD_MD_FLID);
116         CHECK_VALUE(OBD_MD_FLATIME);
117         CHECK_VALUE(OBD_MD_FLMTIME);
118         CHECK_VALUE(OBD_MD_FLCTIME);
119         CHECK_VALUE(OBD_MD_FLSIZE);
120         CHECK_VALUE(OBD_MD_FLBLOCKS);
121         CHECK_VALUE(OBD_MD_FLBLKSZ);
122         CHECK_VALUE(OBD_MD_FLMODE);
123         CHECK_VALUE(OBD_MD_FLTYPE);
124         CHECK_VALUE(OBD_MD_FLUID);
125         CHECK_VALUE(OBD_MD_FLGID);
126         CHECK_VALUE(OBD_MD_FLFLAGS);
127         CHECK_VALUE(OBD_MD_FLOBDFLG);
128         CHECK_VALUE(OBD_MD_FLNLINK);
129         CHECK_VALUE(OBD_MD_FLGENER);
130         CHECK_VALUE(OBD_MD_FLINLINE);
131         CHECK_VALUE(OBD_MD_FLRDEV);
132         CHECK_VALUE(OBD_MD_FLEASIZE);
133         CHECK_VALUE(OBD_MD_LINKNAME);
134         CHECK_VALUE(OBD_MD_FLHANDLE);
135         CHECK_VALUE(OBD_MD_FLCKSUM);
136         CHECK_VALUE(OBD_MD_FLQOS);
137         CHECK_VALUE(OBD_MD_FLOSCOPQ);
138         CHECK_VALUE(OBD_MD_FLCOOKIE);
139         CHECK_VALUE(OBD_MD_FLGROUP);
140
141         CHECK_VALUE(OBD_FL_INLINEDATA);
142         CHECK_VALUE(OBD_FL_OBDMDEXISTS);
143         CHECK_VALUE(OBD_FL_DELORPHAN);
144         CHECK_VALUE(OBD_FL_NORPC);
145         CHECK_VALUE(OBD_FL_IDONLY);
146 }
147
148 void
149 check_lov_mds_md_v1(void)
150 {
151         BLANK_LINE();
152         CHECK_STRUCT(lov_mds_md_v1);
153         CHECK_MEMBER(lov_mds_md_v1, lmm_magic);
154         CHECK_MEMBER(lov_mds_md_v1, lmm_pattern);
155         CHECK_MEMBER(lov_mds_md_v1, lmm_object_id);
156         CHECK_MEMBER(lov_mds_md_v1, lmm_object_gr);
157         CHECK_MEMBER(lov_mds_md_v1, lmm_stripe_size);
158         CHECK_MEMBER(lov_mds_md_v1, lmm_stripe_count);
159         CHECK_MEMBER(lov_mds_md_v1, lmm_objects);
160
161         BLANK_LINE();
162         CHECK_STRUCT(lov_ost_data_v1);
163         CHECK_MEMBER(lov_ost_data_v1, l_object_id);
164         CHECK_MEMBER(lov_ost_data_v1, l_object_gr);
165         CHECK_MEMBER(lov_ost_data_v1, l_ost_gen);
166         CHECK_MEMBER(lov_ost_data_v1, l_ost_idx);
167
168         CHECK_VALUE(LOV_MAGIC_V0);
169         CHECK_VALUE(LOV_MAGIC_V1);
170
171         CHECK_VALUE(LOV_PATTERN_RAID0);
172         CHECK_VALUE(LOV_PATTERN_RAID1);
173 }
174
175 void
176 check_obd_statfs(void)
177 {
178         BLANK_LINE();
179         CHECK_STRUCT(obd_statfs);
180         CHECK_MEMBER(obd_statfs, os_type);
181         CHECK_MEMBER(obd_statfs, os_blocks);
182         CHECK_MEMBER(obd_statfs, os_bfree);
183         CHECK_MEMBER(obd_statfs, os_bavail);
184         CHECK_MEMBER(obd_statfs, os_ffree);
185         CHECK_MEMBER(obd_statfs, os_fsid);
186         CHECK_MEMBER(obd_statfs, os_bsize);
187         CHECK_MEMBER(obd_statfs, os_namelen);
188         CHECK_MEMBER(obd_statfs, os_spare);
189 }
190
191 void
192 check_obd_ioobj(void)
193 {
194         BLANK_LINE();
195         CHECK_STRUCT(obd_ioobj);
196         CHECK_MEMBER(obd_ioobj, ioo_id);
197         CHECK_MEMBER(obd_ioobj, ioo_gr);
198         CHECK_MEMBER(obd_ioobj, ioo_type);
199         CHECK_MEMBER(obd_ioobj, ioo_bufcnt);
200 }
201
202 void
203 check_niobuf_remote(void)
204 {
205         BLANK_LINE();
206         CHECK_STRUCT(niobuf_remote);
207         CHECK_MEMBER(niobuf_remote, offset);
208         CHECK_MEMBER(niobuf_remote, len);
209         CHECK_MEMBER(niobuf_remote, flags);
210
211         CHECK_VALUE(OBD_BRW_READ);
212         CHECK_VALUE(OBD_BRW_WRITE);
213         CHECK_VALUE(OBD_BRW_CREATE);
214         CHECK_VALUE(OBD_BRW_SYNC);
215         CHECK_VALUE(OBD_BRW_FROM_GRANT);
216 }
217
218 void
219 check_ost_body(void)
220 {
221         BLANK_LINE();
222         CHECK_STRUCT(ost_body);
223         CHECK_MEMBER(ost_body, oa);
224 }
225
226 void
227 check_ll_fid(void)
228 {
229         BLANK_LINE();
230         CHECK_STRUCT(ll_fid);
231         CHECK_MEMBER(ll_fid, id);
232         CHECK_MEMBER(ll_fid, generation);
233         CHECK_MEMBER(ll_fid, f_type);
234 }
235
236 void
237 check_mds_status_req(void)
238 {
239         BLANK_LINE();
240         CHECK_STRUCT(mds_status_req);
241         CHECK_MEMBER(mds_status_req, flags);
242         CHECK_MEMBER(mds_status_req, repbuf);
243 }
244
245 void
246 check_mds_body(void)
247 {
248         BLANK_LINE();
249         CHECK_STRUCT(mds_body);
250         CHECK_MEMBER(mds_body, fid1);
251         CHECK_MEMBER(mds_body, fid2);
252         CHECK_MEMBER(mds_body, handle);
253         CHECK_MEMBER(mds_body, size);
254         CHECK_MEMBER(mds_body, blocks);
255         CHECK_MEMBER(mds_body, io_epoch);
256         CHECK_MEMBER(mds_body, ino);
257         CHECK_MEMBER(mds_body, valid);
258         CHECK_MEMBER(mds_body, fsuid);
259         CHECK_MEMBER(mds_body, fsgid);
260         CHECK_MEMBER(mds_body, capability);
261         CHECK_MEMBER(mds_body, mode);
262         CHECK_MEMBER(mds_body, uid);
263         CHECK_MEMBER(mds_body, gid);
264         CHECK_MEMBER(mds_body, mtime);
265         CHECK_MEMBER(mds_body, ctime);
266         CHECK_MEMBER(mds_body, atime);
267         CHECK_MEMBER(mds_body, flags);
268         CHECK_MEMBER(mds_body, rdev);
269         CHECK_MEMBER(mds_body, nlink);
270         CHECK_MEMBER(mds_body, generation);
271         CHECK_MEMBER(mds_body, suppgid);
272         CHECK_MEMBER(mds_body, eadatasize);
273
274         CHECK_VALUE(FMODE_READ);
275         CHECK_VALUE(FMODE_WRITE);
276         CHECK_VALUE(FMODE_EXEC);
277         CHECK_VALUE(MDS_OPEN_CREAT);
278         CHECK_VALUE(MDS_OPEN_EXCL);
279         CHECK_VALUE(MDS_OPEN_TRUNC);
280         CHECK_VALUE(MDS_OPEN_APPEND);
281         CHECK_VALUE(MDS_OPEN_SYNC);
282         CHECK_VALUE(MDS_OPEN_DIRECTORY);
283         CHECK_VALUE(MDS_OPEN_DELAY_CREATE);
284         CHECK_VALUE(MDS_OPEN_HAS_EA);
285 }
286
287 void
288 check_mds_rec_setattr(void)
289 {
290         BLANK_LINE();
291         CHECK_STRUCT(mds_rec_setattr);
292         CHECK_MEMBER(mds_rec_setattr, sa_opcode);
293         CHECK_MEMBER(mds_rec_setattr, sa_fsuid);
294         CHECK_MEMBER(mds_rec_setattr, sa_fsgid);
295         CHECK_MEMBER(mds_rec_setattr, sa_cap);
296         CHECK_MEMBER(mds_rec_setattr, sa_suppgid);
297         CHECK_MEMBER(mds_rec_setattr, sa_valid);
298         CHECK_MEMBER(mds_rec_setattr, sa_fid);
299         CHECK_MEMBER(mds_rec_setattr, sa_mode);
300         CHECK_MEMBER(mds_rec_setattr, sa_uid);
301         CHECK_MEMBER(mds_rec_setattr, sa_gid);
302         CHECK_MEMBER(mds_rec_setattr, sa_attr_flags);
303         CHECK_MEMBER(mds_rec_setattr, sa_size);
304         CHECK_MEMBER(mds_rec_setattr, sa_atime);
305         CHECK_MEMBER(mds_rec_setattr, sa_mtime);
306         CHECK_MEMBER(mds_rec_setattr, sa_ctime);
307 }
308
309 void
310 check_mds_rec_create(void)
311 {
312         BLANK_LINE();
313         CHECK_STRUCT(mds_rec_create);
314         CHECK_MEMBER(mds_rec_create, cr_opcode);
315         CHECK_MEMBER(mds_rec_create, cr_fsuid);
316         CHECK_MEMBER(mds_rec_create, cr_fsgid);
317         CHECK_MEMBER(mds_rec_create, cr_cap);
318         CHECK_MEMBER(mds_rec_create, cr_flags);
319         CHECK_MEMBER(mds_rec_create, cr_mode);
320         CHECK_MEMBER(mds_rec_create, cr_fid);
321         CHECK_MEMBER(mds_rec_create, cr_replayfid);
322         CHECK_MEMBER(mds_rec_create, cr_time);
323         CHECK_MEMBER(mds_rec_create, cr_rdev);
324         CHECK_MEMBER(mds_rec_create, cr_suppgid);
325 }
326
327 void
328 check_mds_rec_link(void)
329 {
330         BLANK_LINE();
331         CHECK_STRUCT(mds_rec_link);
332         CHECK_MEMBER(mds_rec_link, lk_opcode);
333         CHECK_MEMBER(mds_rec_link, lk_fsuid);
334         CHECK_MEMBER(mds_rec_link, lk_fsgid);
335         CHECK_MEMBER(mds_rec_link, lk_cap);
336         CHECK_MEMBER(mds_rec_link, lk_suppgid1);
337         CHECK_MEMBER(mds_rec_link, lk_suppgid2);
338         CHECK_MEMBER(mds_rec_link, lk_fid1);
339         CHECK_MEMBER(mds_rec_link, lk_fid2);
340         CHECK_MEMBER(mds_rec_link, lk_time);
341 }
342
343 void
344 check_mds_rec_unlink(void)
345 {
346         BLANK_LINE();
347         CHECK_STRUCT(mds_rec_unlink);
348         CHECK_MEMBER(mds_rec_unlink, ul_opcode);
349         CHECK_MEMBER(mds_rec_unlink, ul_fsuid);
350         CHECK_MEMBER(mds_rec_unlink, ul_fsgid);
351         CHECK_MEMBER(mds_rec_unlink, ul_cap);
352         CHECK_MEMBER(mds_rec_unlink, ul_suppgid);
353         CHECK_MEMBER(mds_rec_unlink, ul_mode);
354         CHECK_MEMBER(mds_rec_unlink, ul_fid1);
355         CHECK_MEMBER(mds_rec_unlink, ul_fid2);
356         CHECK_MEMBER(mds_rec_unlink, ul_time);
357 }
358
359 void
360 check_mds_rec_rename(void)
361 {
362         BLANK_LINE();
363         CHECK_STRUCT(mds_rec_rename);
364         CHECK_MEMBER(mds_rec_rename, rn_opcode);
365         CHECK_MEMBER(mds_rec_rename, rn_fsuid);
366         CHECK_MEMBER(mds_rec_rename, rn_fsgid);
367         CHECK_MEMBER(mds_rec_rename, rn_cap);
368         CHECK_MEMBER(mds_rec_rename, rn_suppgid1);
369         CHECK_MEMBER(mds_rec_rename, rn_suppgid2);
370         CHECK_MEMBER(mds_rec_rename, rn_fid1);
371         CHECK_MEMBER(mds_rec_rename, rn_fid2);
372         CHECK_MEMBER(mds_rec_rename, rn_time);
373 }
374
375 void
376 check_lov_desc(void)
377 {
378         BLANK_LINE();
379         CHECK_STRUCT(lov_desc);
380         CHECK_MEMBER(lov_desc, ld_tgt_count);
381         CHECK_MEMBER(lov_desc, ld_active_tgt_count);
382         CHECK_MEMBER(lov_desc, ld_default_stripe_count);
383         CHECK_MEMBER(lov_desc, ld_pattern);
384         CHECK_MEMBER(lov_desc, ld_default_stripe_size);
385         CHECK_MEMBER(lov_desc, ld_default_stripe_offset);
386         CHECK_MEMBER(lov_desc, ld_uuid);
387 }
388
389 void
390 check_ldlm_res_id(void)
391 {
392         BLANK_LINE();
393         CHECK_STRUCT(ldlm_res_id);
394         CHECK_MEMBER(ldlm_res_id, name[RES_NAME_SIZE]);
395 }
396
397 void
398 check_ldlm_extent(void)
399 {
400         BLANK_LINE();
401         CHECK_STRUCT(ldlm_extent);
402         CHECK_MEMBER(ldlm_extent, start);
403         CHECK_MEMBER(ldlm_extent, end);
404 }
405
406 void
407 check_ldlm_flock(void)
408 {
409         BLANK_LINE();
410         CHECK_STRUCT(ldlm_flock);
411         CHECK_MEMBER(ldlm_flock, start);
412         CHECK_MEMBER(ldlm_flock, end);
413         CHECK_MEMBER(ldlm_flock, blocking_export);
414         CHECK_MEMBER(ldlm_flock, blocking_pid);
415         CHECK_MEMBER(ldlm_flock, pid);
416 }
417
418 void
419 check_ldlm_intent(void)
420 {
421         BLANK_LINE();
422         CHECK_STRUCT(ldlm_intent);
423         CHECK_MEMBER(ldlm_intent, opc);
424 }
425
426 void
427 check_ldlm_resource_desc(void)
428 {
429         BLANK_LINE();
430         CHECK_STRUCT(ldlm_resource_desc);
431         CHECK_MEMBER(ldlm_resource_desc, lr_type);
432         CHECK_MEMBER(ldlm_resource_desc, lr_name);
433         CHECK_MEMBER(ldlm_resource_desc, lr_version[RES_VERSION_SIZE]);
434 }
435
436 void
437 check_ldlm_lock_desc(void)
438 {
439         BLANK_LINE();
440         CHECK_STRUCT(ldlm_lock_desc);
441         CHECK_MEMBER(ldlm_lock_desc, l_resource);
442         CHECK_MEMBER(ldlm_lock_desc, l_req_mode);
443         CHECK_MEMBER(ldlm_lock_desc, l_granted_mode);
444         CHECK_MEMBER(ldlm_lock_desc, l_policy_data);
445         CHECK_MEMBER(ldlm_lock_desc, l_version[RES_VERSION_SIZE]);
446 }
447
448 void
449 check_ldlm_request(void)
450 {
451         BLANK_LINE();
452         CHECK_STRUCT(ldlm_request);
453         CHECK_MEMBER(ldlm_request, lock_flags);
454         CHECK_MEMBER(ldlm_request, lock_desc);
455         CHECK_MEMBER(ldlm_request, lock_handle1);
456         CHECK_MEMBER(ldlm_request, lock_handle2);
457 }
458
459 void
460 check_ldlm_reply(void)
461 {
462         BLANK_LINE();
463         CHECK_STRUCT(ldlm_reply);
464         CHECK_MEMBER(ldlm_reply, lock_flags);
465         CHECK_MEMBER(ldlm_reply, lock_mode);
466         CHECK_MEMBER(ldlm_reply, lock_resource_name);
467         CHECK_MEMBER(ldlm_reply, lock_handle);
468         CHECK_MEMBER(ldlm_reply, lock_policy_data);
469         CHECK_MEMBER(ldlm_reply, lock_policy_res1);
470         CHECK_MEMBER(ldlm_reply, lock_policy_res2);
471 }
472
473 void
474 check_ptlbd_op(void)
475 {
476         BLANK_LINE();
477         CHECK_STRUCT(ptlbd_op);
478         CHECK_MEMBER(ptlbd_op, op_cmd);
479         CHECK_MEMBER(ptlbd_op, op_lun);
480         CHECK_MEMBER(ptlbd_op, op_niob_cnt);
481         CHECK_MEMBER(ptlbd_op, op__padding);
482         CHECK_MEMBER(ptlbd_op, op_block_cnt);
483 }
484
485 void
486 check_ptlbd_niob(void)
487 {
488         BLANK_LINE();
489         CHECK_STRUCT(ptlbd_niob);
490         CHECK_MEMBER(ptlbd_niob, n_xid);
491         CHECK_MEMBER(ptlbd_niob, n_block_nr);
492         CHECK_MEMBER(ptlbd_niob, n_offset);
493         CHECK_MEMBER(ptlbd_niob, n_length);
494 }
495
496 void
497 check_ptlbd_rsp(void)
498 {
499         BLANK_LINE();
500         CHECK_STRUCT(ptlbd_rsp);
501         CHECK_MEMBER(ptlbd_rsp, r_status);
502         CHECK_MEMBER(ptlbd_rsp, r_error_cnt);
503 }
504
505 void
506 check_llog_logid(void)
507 {
508         BLANK_LINE();
509         CHECK_STRUCT(llog_logid);
510         CHECK_MEMBER(llog_logid, lgl_oid);
511         CHECK_MEMBER(llog_logid, lgl_ogr);
512         CHECK_MEMBER(llog_logid, lgl_ogen);
513
514         CHECK_VALUE(OST_SZ_REC);
515         CHECK_VALUE(OST_RAID1_REC);
516         CHECK_VALUE(MDS_UNLINK_REC);
517         CHECK_VALUE(OBD_CFG_REC);
518         CHECK_VALUE(PTL_CFG_REC);
519         CHECK_VALUE(LLOG_GEN_REC);
520         CHECK_VALUE(LLOG_HDR_MAGIC);
521         CHECK_VALUE(LLOG_LOGID_MAGIC);
522 }
523
524 void
525 check_llog_rec_hdr(void)
526 {
527         BLANK_LINE();
528         CHECK_STRUCT(llog_rec_hdr);
529         CHECK_MEMBER(llog_rec_hdr, lrh_len);
530         CHECK_MEMBER(llog_rec_hdr, lrh_index);
531         CHECK_MEMBER(llog_rec_hdr, lrh_type);
532 }
533
534 void
535 check_llog_rec_tail(void)
536 {
537         BLANK_LINE();
538         CHECK_STRUCT(llog_rec_tail);
539         CHECK_MEMBER(llog_rec_tail, lrt_len);
540         CHECK_MEMBER(llog_rec_tail, lrt_index);
541 }
542
543 void
544 check_llog_logid_rec(void)
545 {
546         BLANK_LINE();
547         CHECK_STRUCT(llog_logid_rec);
548         CHECK_MEMBER(llog_logid_rec, lid_hdr);
549         CHECK_MEMBER(llog_logid_rec, lid_id);
550         CHECK_MEMBER(llog_logid_rec, lid_tail);
551 }
552
553 void
554 check_llog_create_rec(void)
555 {
556         BLANK_LINE();
557         CHECK_STRUCT(llog_create_rec);
558         CHECK_MEMBER(llog_create_rec, lcr_hdr);
559         CHECK_MEMBER(llog_create_rec, lcr_fid);
560         CHECK_MEMBER(llog_create_rec, lcr_oid);
561         CHECK_MEMBER(llog_create_rec, lcr_ogen);
562 }
563
564 void
565 check_llog_orphan_rec(void)
566 {
567         BLANK_LINE();
568         CHECK_STRUCT(llog_orphan_rec);
569         CHECK_MEMBER(llog_orphan_rec, lor_hdr);
570         CHECK_MEMBER(llog_orphan_rec, lor_oid);
571         CHECK_MEMBER(llog_orphan_rec, lor_ogen);
572         CHECK_MEMBER(llog_orphan_rec, lor_tail);
573 }
574
575 void
576 check_llog_unlink_rec(void)
577 {
578         BLANK_LINE();
579         CHECK_STRUCT(llog_unlink_rec);
580         CHECK_MEMBER(llog_unlink_rec, lur_hdr);
581         CHECK_MEMBER(llog_unlink_rec, lur_oid);
582         CHECK_MEMBER(llog_unlink_rec, lur_ogen);
583         CHECK_MEMBER(llog_unlink_rec, lur_tail);
584 }
585
586 void
587 check_llog_size_change_rec(void)
588 {
589         BLANK_LINE();
590         CHECK_STRUCT(llog_size_change_rec);
591         CHECK_MEMBER(llog_size_change_rec, lsc_hdr);
592         CHECK_MEMBER(llog_size_change_rec, lsc_fid);
593         CHECK_MEMBER(llog_size_change_rec, lsc_io_epoch);
594         CHECK_MEMBER(llog_size_change_rec, lsc_tail);
595 }
596
597 void
598 check_llog_gen(void)
599 {
600         BLANK_LINE();
601         CHECK_STRUCT(llog_gen);
602         CHECK_MEMBER(llog_gen, mnt_cnt);
603         CHECK_MEMBER(llog_gen, conn_cnt);
604 }
605
606 void
607 check_llog_gen_rec(void)
608 {
609         BLANK_LINE();
610         CHECK_STRUCT(llog_gen_rec);
611         CHECK_MEMBER(llog_gen_rec, lgr_hdr);
612         CHECK_MEMBER(llog_gen_rec, lgr_gen);
613         CHECK_MEMBER(llog_gen_rec, lgr_tail);
614 }
615
616 void
617 check_llog_log_hdr(void)
618 {
619         BLANK_LINE();
620         CHECK_STRUCT(llog_log_hdr);
621         CHECK_MEMBER(llog_log_hdr, llh_hdr);
622         CHECK_MEMBER(llog_log_hdr, llh_timestamp);
623         CHECK_MEMBER(llog_log_hdr, llh_count);
624         CHECK_MEMBER(llog_log_hdr, llh_bitmap_offset);
625         CHECK_MEMBER(llog_log_hdr, llh_size);
626         CHECK_MEMBER(llog_log_hdr, llh_flags);
627         CHECK_MEMBER(llog_log_hdr, llh_cat_idx);
628         CHECK_MEMBER(llog_log_hdr, llh_tgtuuid);
629         CHECK_MEMBER(llog_log_hdr, llh_reserved);
630         CHECK_MEMBER(llog_log_hdr, llh_bitmap);
631         CHECK_MEMBER(llog_log_hdr, llh_tail);
632 }
633
634 void
635 check_llog_cookie(void)
636 {
637         BLANK_LINE();
638         CHECK_STRUCT(llog_cookie);
639         CHECK_MEMBER(llog_cookie, lgc_lgl);
640         CHECK_MEMBER(llog_cookie, lgc_subsys);
641         CHECK_MEMBER(llog_cookie, lgc_index);
642 }
643
644 void
645 check_llogd_body(void)
646 {
647         BLANK_LINE();
648         CHECK_STRUCT(llogd_body);
649         CHECK_MEMBER(llogd_body, lgd_logid);
650         CHECK_MEMBER(llogd_body, lgd_ctxt_idx);
651         CHECK_MEMBER(llogd_body, lgd_llh_flags);
652         CHECK_MEMBER(llogd_body, lgd_index);
653         CHECK_MEMBER(llogd_body, lgd_saved_index);
654         CHECK_MEMBER(llogd_body, lgd_len);
655         CHECK_MEMBER(llogd_body, lgd_cur_offset);
656
657         CHECK_VALUE(LLOG_ORIGIN_HANDLE_CREATE);
658         CHECK_VALUE(LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
659         CHECK_VALUE(LLOG_ORIGIN_HANDLE_READ_HEADER);
660         CHECK_VALUE(LLOG_ORIGIN_HANDLE_WRITE_REC);
661         CHECK_VALUE(LLOG_ORIGIN_HANDLE_CLOSE);
662         CHECK_VALUE(LLOG_ORIGIN_CONNECT);
663         CHECK_VALUE(LLOG_CATINFO);
664 }
665
666 void
667 check_llogd_conn_body(void)
668 {
669         BLANK_LINE();
670         CHECK_STRUCT(llogd_conn_body);
671         CHECK_MEMBER(llogd_conn_body, lgdc_gen);
672         CHECK_MEMBER(llogd_conn_body, lgdc_logid);
673         CHECK_MEMBER(llogd_conn_body, lgdc_ctxt_idx);
674 }
675
676 int
677 main(int argc, char **argv)
678 {
679         printf("void lustre_assert_wire_constants(void)\n"
680                "{\n");
681
682         COMMENT("Wire protocol assertions generated by 'wirecheck'");
683         BLANK_LINE();
684
685         COMMENT("Constants...");
686         CHECK_DEFINE(PTLRPC_MSG_MAGIC);
687         CHECK_DEFINE(PTLRPC_MSG_VERSION);
688
689         CHECK_VALUE(PTL_RPC_MSG_REQUEST);
690         CHECK_VALUE(PTL_RPC_MSG_ERR);
691         CHECK_VALUE(PTL_RPC_MSG_REPLY);
692
693         CHECK_VALUE(MSG_LAST_REPLAY);
694         CHECK_VALUE(MSG_RESENT);
695
696         CHECK_VALUE(MSG_CONNECT_RECOVERING);
697         CHECK_VALUE(MSG_CONNECT_RECONNECT);
698         CHECK_VALUE(MSG_CONNECT_REPLAYABLE);
699
700         CHECK_VALUE(OST_REPLY);
701         CHECK_VALUE(OST_GETATTR);
702         CHECK_VALUE(OST_SETATTR);
703         CHECK_VALUE(OST_READ);
704         CHECK_VALUE(OST_WRITE);
705         CHECK_VALUE(OST_CREATE);
706         CHECK_VALUE(OST_DESTROY);
707         CHECK_VALUE(OST_GET_INFO);
708         CHECK_VALUE(OST_CONNECT);
709         CHECK_VALUE(OST_DISCONNECT);
710         CHECK_VALUE(OST_PUNCH);
711         CHECK_VALUE(OST_OPEN);
712         CHECK_VALUE(OST_CLOSE);
713         CHECK_VALUE(OST_STATFS);
714         CHECK_VALUE(OST_SAN_READ);
715         CHECK_VALUE(OST_SAN_WRITE);
716         CHECK_VALUE(OST_SYNC);
717         CHECK_VALUE(OST_LAST_OPC);
718
719         CHECK_DEFINE(OBD_OBJECT_EOF);
720
721         CHECK_VALUE(OST_REQ_HAS_OA1);
722
723         CHECK_VALUE(MDS_GETATTR);
724         CHECK_VALUE(MDS_GETATTR_NAME);
725         CHECK_VALUE(MDS_CLOSE);
726         CHECK_VALUE(MDS_REINT);
727         CHECK_VALUE(MDS_READPAGE);
728         CHECK_VALUE(MDS_CONNECT);
729         CHECK_VALUE(MDS_DISCONNECT);
730         CHECK_VALUE(MDS_GETSTATUS);
731         CHECK_VALUE(MDS_STATFS);
732         CHECK_VALUE(MDS_PIN);
733         CHECK_VALUE(MDS_UNPIN);
734         CHECK_VALUE(MDS_SYNC);
735         CHECK_VALUE(MDS_DONE_WRITING);
736         CHECK_VALUE(MDS_LAST_OPC);
737
738         CHECK_VALUE(REINT_SETATTR);
739         CHECK_VALUE(REINT_CREATE);
740         CHECK_VALUE(REINT_LINK);
741         CHECK_VALUE(REINT_UNLINK);
742         CHECK_VALUE(REINT_RENAME);
743         CHECK_VALUE(REINT_OPEN);
744         CHECK_VALUE(REINT_MAX);
745
746         CHECK_VALUE(DISP_IT_EXECD);
747         CHECK_VALUE(DISP_LOOKUP_EXECD);
748         CHECK_VALUE(DISP_LOOKUP_NEG);
749         CHECK_VALUE(DISP_LOOKUP_POS);
750         CHECK_VALUE(DISP_OPEN_CREATE);
751         CHECK_VALUE(DISP_OPEN_OPEN);
752
753         CHECK_VALUE(MDS_STATUS_CONN);
754         CHECK_VALUE(MDS_STATUS_LOV);
755
756         CHECK_VALUE(MDS_OPEN_HAS_EA);
757
758         CHECK_VALUE(LDLM_ENQUEUE);
759         CHECK_VALUE(LDLM_CONVERT);
760         CHECK_VALUE(LDLM_CANCEL);
761         CHECK_VALUE(LDLM_BL_CALLBACK);
762         CHECK_VALUE(LDLM_CP_CALLBACK);
763         CHECK_VALUE(LDLM_LAST_OPC);
764
765         CHECK_VALUE(LCK_EX);
766         CHECK_VALUE(LCK_PW);
767         CHECK_VALUE(LCK_PR);
768         CHECK_VALUE(LCK_CW);
769         CHECK_VALUE(LCK_CR);
770         CHECK_VALUE(LCK_NL);
771
772         CHECK_VALUE(PTLBD_QUERY);
773         CHECK_VALUE(PTLBD_READ);
774         CHECK_VALUE(PTLBD_WRITE);
775         CHECK_VALUE(PTLBD_FLUSH);
776         CHECK_VALUE(PTLBD_CONNECT);
777         CHECK_VALUE(PTLBD_DISCONNECT);
778         CHECK_VALUE(PTLBD_LAST_OPC);
779
780         CHECK_VALUE(MGMT_CONNECT);
781         CHECK_VALUE(MGMT_DISCONNECT);
782         CHECK_VALUE(MGMT_EXCEPTION);
783
784         CHECK_VALUE(OBD_PING);
785         CHECK_VALUE(OBD_LOG_CANCEL);
786         CHECK_VALUE(OBD_LAST_OPC);
787
788         COMMENT("Sizes and Offsets");
789         BLANK_LINE();
790         check_lustre_handle();
791         check_lustre_msg();
792         check_obdo();
793         check_lov_mds_md_v1();
794         check_obd_statfs();
795         check_obd_ioobj();
796         check_niobuf_remote();
797         check_ost_body();
798         check_ll_fid();
799         check_mds_status_req();
800         check_mds_body();
801         check_mds_rec_setattr();
802         check_mds_rec_create();
803         check_mds_rec_link();
804         check_mds_rec_unlink();
805         check_mds_rec_rename();
806         check_lov_desc();
807         check_ldlm_res_id();
808         check_ldlm_extent();
809         check_ldlm_flock();
810         check_ldlm_intent();
811         check_ldlm_resource_desc();
812         check_ldlm_lock_desc();
813         check_ldlm_request();
814         check_ldlm_reply();
815         check_ptlbd_op();
816         check_ptlbd_niob();
817         check_ptlbd_rsp();
818         check_llog_logid();
819         check_llog_rec_hdr();
820         check_llog_rec_tail();
821         check_llog_log_hdr();
822         check_llog_cookie();
823         check_llogd_body();
824         check_llogd_conn_body();
825
826         printf("}\n\n");
827
828         return(0);
829 }