Line data Source code
1 : #include <stddef.h>
2 : #include <string.h>
3 : #include <inttypes.h>
4 : #include <uuid.h>
5 : #include <stdarg.h>
6 : #include <libgfs2.h>
7 :
8 : #include "struct_print.h"
9 :
10 : __attribute__((format(printf,2,4)))
11 42631 : static void print_it(const char *label, const char *fmt, const char *fmt2, ...)
12 : {
13 : va_list args;
14 :
15 42631 : va_start(args, fmt2);
16 42631 : printf("%s: ", label);
17 42631 : vprintf(fmt, args);
18 42631 : va_end(args);
19 42631 : }
20 :
21 : #define printbe16(struct, member) do { \
22 : print_it(" "#member, "%"PRIu16, "0x%"PRIx16, be16_to_cpu(struct->member)); \
23 : } while(0)
24 : #define printbe32(struct, member) do { \
25 : print_it(" "#member, "%"PRIu32, "0x%"PRIx32, be32_to_cpu(struct->member)); \
26 : } while(0)
27 : #define printbe64(struct, member) do { \
28 : print_it(" "#member, "%"PRIu64, "0x%"PRIx64, be64_to_cpu(struct->member)); \
29 : } while(0)
30 : #define print8(struct, member) do { \
31 : print_it(" "#member, "%"PRIu8, "0x%"PRIx8, struct->member); \
32 : } while(0)
33 :
34 637 : void inum_print(void *nop)
35 : {
36 637 : struct gfs2_inum *no = nop;
37 :
38 637 : printbe64(no, no_formal_ino);
39 637 : printbe64(no, no_addr);
40 637 : }
41 :
42 637 : void meta_header_print(void *mhp)
43 : {
44 637 : struct gfs2_meta_header *mh = mhp;
45 :
46 637 : print_it(" mh_magic", "0x%08"PRIX32, NULL, be32_to_cpu(mh->mh_magic));
47 637 : printbe32(mh, mh_type);
48 637 : printbe32(mh, mh_format);
49 637 : }
50 :
51 0 : void sb_print(void *sbp)
52 : {
53 0 : struct gfs2_sb *sb = sbp;
54 : char readable_uuid[36+1];
55 :
56 0 : meta_header_print(&sb->sb_header);
57 0 : printbe32(sb, sb_fs_format);
58 0 : printbe32(sb, sb_multihost_format);
59 0 : printbe32(sb, sb_bsize);
60 0 : printbe32(sb, sb_bsize_shift);
61 0 : inum_print(&sb->sb_master_dir);
62 0 : inum_print(&sb->sb_root_dir);
63 0 : print_it(" sb_lockproto", "%.64s", NULL, sb->sb_lockproto);
64 0 : print_it(" sb_locktable", "%.64s", NULL, sb->sb_locktable);
65 0 : uuid_unparse(sb->sb_uuid, readable_uuid);
66 0 : print_it(" uuid", "%36s", NULL, readable_uuid);
67 0 : }
68 :
69 5435 : void rindex_print(void *rip)
70 : {
71 5435 : struct gfs2_rindex *ri = rip;
72 :
73 5435 : printbe64(ri, ri_addr);
74 5435 : printbe32(ri, ri_length);
75 5435 : printbe64(ri, ri_data0);
76 5435 : printbe32(ri, ri_data);
77 5435 : printbe32(ri, ri_bitbytes);
78 5435 : }
79 :
80 0 : void rgrp_print(void *rgp)
81 : {
82 0 : struct gfs2_rgrp *rg = rgp;
83 :
84 0 : meta_header_print(&rg->rg_header);
85 0 : printbe32(rg, rg_flags);
86 0 : printbe32(rg, rg_free);
87 0 : printbe32(rg, rg_dinodes);
88 0 : printbe32(rg, rg_skip);
89 0 : printbe64(rg, rg_igeneration);
90 0 : printbe64(rg, rg_data0);
91 0 : printbe32(rg, rg_data);
92 0 : printbe32(rg, rg_bitbytes);
93 0 : printbe32(rg, rg_crc);
94 0 : }
95 :
96 0 : void quota_print(void *qp)
97 : {
98 0 : struct gfs2_quota *q = qp;
99 :
100 0 : printbe64(q, qu_limit);
101 0 : printbe64(q, qu_warn);
102 0 : printbe64(q, qu_value);
103 0 : }
104 :
105 637 : void dinode_print(void *dip)
106 : {
107 637 : struct gfs2_dinode *di = dip;
108 :
109 637 : meta_header_print(&di->di_header);
110 637 : inum_print(&di->di_num);
111 :
112 637 : print_it(" di_mode", "0%"PRIo32, NULL, be32_to_cpu(di->di_mode));
113 637 : printbe32(di, di_uid);
114 637 : printbe32(di, di_gid);
115 637 : printbe32(di, di_nlink);
116 637 : printbe64(di, di_size);
117 637 : printbe64(di, di_blocks);
118 637 : printbe64(di, di_atime);
119 637 : printbe64(di, di_mtime);
120 637 : printbe64(di, di_ctime);
121 637 : printbe32(di, di_major);
122 637 : printbe32(di, di_minor);
123 637 : printbe64(di, di_goal_meta);
124 637 : printbe64(di, di_goal_data);
125 637 : print_it(" di_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(di->di_flags));
126 637 : printbe32(di, di_payload_format);
127 637 : printbe16(di, di_height);
128 637 : printbe16(di, di_depth);
129 637 : printbe32(di, di_entries);
130 637 : printbe64(di, di_eattr);
131 637 : }
132 :
133 0 : void leaf_print(void *lfp)
134 : {
135 0 : struct gfs2_leaf *lf = lfp;
136 :
137 0 : meta_header_print(&lf->lf_header);
138 0 : printbe16(lf, lf_depth);
139 0 : printbe16(lf, lf_entries);
140 0 : printbe32(lf, lf_dirent_format);
141 0 : printbe64(lf, lf_next);
142 0 : printbe64(lf, lf_inode);
143 0 : printbe32(lf, lf_dist);
144 0 : printbe32(lf, lf_nsec);
145 0 : printbe64(lf, lf_sec);
146 0 : }
147 :
148 0 : void log_header_print(void *lhp)
149 : {
150 0 : struct gfs2_log_header *lh = lhp;
151 :
152 0 : meta_header_print(&lh->lh_header);
153 0 : printbe64(lh, lh_sequence);
154 0 : print_it(" lh_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_flags));
155 0 : printbe32(lh, lh_tail);
156 0 : printbe32(lh, lh_blkno);
157 0 : print_it(" lh_hash", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_hash));
158 0 : print_it(" lh_crc", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_crc));
159 0 : printbe32(lh, lh_nsec);
160 0 : printbe64(lh, lh_sec);
161 0 : printbe64(lh, lh_addr);
162 0 : printbe64(lh, lh_jinode);
163 0 : printbe64(lh, lh_statfs_addr);
164 0 : printbe64(lh, lh_quota_addr);
165 0 : print_it(" lh_local_total", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_total));
166 0 : print_it(" lh_local_free", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_free));
167 0 : print_it(" lh_local_dinodes", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_dinodes));
168 0 : }
169 :
170 0 : void log_descriptor_print(void *ldp)
171 : {
172 0 : struct gfs2_log_descriptor *ld = ldp;
173 :
174 0 : meta_header_print(&ld->ld_header);
175 0 : printbe32(ld, ld_type);
176 0 : printbe32(ld, ld_length);
177 0 : printbe32(ld, ld_data1);
178 0 : printbe32(ld, ld_data2);
179 0 : }
180 :
181 56 : void statfs_change_print(void *scp)
182 : {
183 56 : struct gfs2_statfs_change *sc = scp;
184 :
185 56 : print_it(" sc_total", "%"PRId64, "0x%"PRIx64, be64_to_cpu(sc->sc_total));
186 56 : print_it(" sc_free", "%"PRId64, "0x%"PRIx64, be64_to_cpu(sc->sc_free));
187 56 : print_it(" sc_dinodes", "%"PRId64, "0x%"PRIx64, be64_to_cpu(sc->sc_dinodes));
188 56 : }
189 :
190 0 : void quota_change_print(void *qcp)
191 : {
192 0 : struct gfs2_quota_change *qc = qcp;
193 :
194 0 : print_it(" qc_change", "%"PRId64, "0x%"PRIx64, be64_to_cpu(qc->qc_change));
195 0 : print_it(" qc_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(qc->qc_flags));
196 0 : printbe32(qc, qc_id);
197 0 : }
198 :
|