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 41959 : static void print_it(const char *label, const char *fmt, const char *fmt2, ...)
12 : {
13 : va_list args;
14 :
15 41959 : va_start(args, fmt2);
16 41959 : printf("%s: ", label);
17 41959 : vprintf(fmt, args);
18 41959 : va_end(args);
19 41959 : }
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 626 : void inum_print(void *nop)
35 : {
36 626 : struct gfs2_inum *no = nop;
37 :
38 626 : printbe64(no, no_formal_ino);
39 626 : printbe64(no, no_addr);
40 626 : }
41 :
42 626 : void meta_header_print(void *mhp)
43 : {
44 626 : struct gfs2_meta_header *mh = mhp;
45 :
46 626 : print_it(" mh_magic", "0x%08"PRIX32, NULL, be32_to_cpu(mh->mh_magic));
47 626 : printbe32(mh, mh_type);
48 626 : printbe32(mh, mh_format);
49 626 : }
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 5354 : void rindex_print(void *rip)
70 : {
71 5354 : struct gfs2_rindex *ri = rip;
72 :
73 5354 : printbe64(ri, ri_addr);
74 5354 : printbe32(ri, ri_length);
75 5354 : printbe64(ri, ri_data0);
76 5354 : printbe32(ri, ri_data);
77 5354 : printbe32(ri, ri_bitbytes);
78 5354 : }
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 626 : void dinode_print(void *dip)
106 : {
107 626 : struct gfs2_dinode *di = dip;
108 :
109 626 : meta_header_print(&di->di_header);
110 626 : inum_print(&di->di_num);
111 :
112 626 : print_it(" di_mode", "0%"PRIo32, NULL, be32_to_cpu(di->di_mode));
113 626 : printbe32(di, di_uid);
114 626 : printbe32(di, di_gid);
115 626 : printbe32(di, di_nlink);
116 626 : printbe64(di, di_size);
117 626 : printbe64(di, di_blocks);
118 626 : printbe64(di, di_atime);
119 626 : printbe64(di, di_mtime);
120 626 : printbe64(di, di_ctime);
121 626 : printbe32(di, di_major);
122 626 : printbe32(di, di_minor);
123 626 : printbe64(di, di_goal_meta);
124 626 : printbe64(di, di_goal_data);
125 626 : print_it(" di_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(di->di_flags));
126 626 : printbe32(di, di_payload_format);
127 626 : printbe16(di, di_height);
128 626 : printbe16(di, di_depth);
129 626 : printbe32(di, di_entries);
130 626 : printbe64(di, di_eattr);
131 626 : }
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 ea_header_print(void *eap)
149 : {
150 : char buf[GFS2_EA_MAX_NAME_LEN + 1];
151 0 : struct gfs2_ea_header *ea = eap;
152 0 : unsigned len = ea->ea_name_len;
153 :
154 0 : printbe32(ea, ea_rec_len);
155 0 : printbe32(ea, ea_data_len);
156 0 : print8(ea, ea_name_len);
157 0 : print8(ea, ea_type);
158 0 : print8(ea, ea_flags);
159 0 : print8(ea, ea_num_ptrs);
160 :
161 0 : if (len > GFS2_EA_MAX_NAME_LEN)
162 0 : len = GFS2_EA_MAX_NAME_LEN;
163 0 : memcpy(buf, ea + 1, len);
164 0 : buf[len] = '\0';
165 0 : print_it(" name", "%s", NULL, buf);
166 0 : }
167 :
168 0 : void log_header_print(void *lhp)
169 : {
170 0 : struct gfs2_log_header *lh = lhp;
171 :
172 0 : meta_header_print(&lh->lh_header);
173 0 : printbe64(lh, lh_sequence);
174 0 : print_it(" lh_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_flags));
175 0 : printbe32(lh, lh_tail);
176 0 : printbe32(lh, lh_blkno);
177 0 : print_it(" lh_hash", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_hash));
178 0 : print_it(" lh_crc", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_crc));
179 0 : printbe32(lh, lh_nsec);
180 0 : printbe64(lh, lh_sec);
181 0 : printbe64(lh, lh_addr);
182 0 : printbe64(lh, lh_jinode);
183 0 : printbe64(lh, lh_statfs_addr);
184 0 : printbe64(lh, lh_quota_addr);
185 0 : print_it(" lh_local_total", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_total));
186 0 : print_it(" lh_local_free", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_free));
187 0 : print_it(" lh_local_dinodes", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_dinodes));
188 0 : }
189 :
190 0 : void log_descriptor_print(void *ldp)
191 : {
192 0 : struct gfs2_log_descriptor *ld = ldp;
193 :
194 0 : meta_header_print(&ld->ld_header);
195 0 : printbe32(ld, ld_type);
196 0 : printbe32(ld, ld_length);
197 0 : printbe32(ld, ld_data1);
198 0 : printbe32(ld, ld_data2);
199 0 : }
200 :
201 55 : void statfs_change_print(void *scp)
202 : {
203 55 : struct gfs2_statfs_change *sc = scp;
204 :
205 55 : print_it(" sc_total", "%"PRId64, "0x%"PRIx64, be64_to_cpu(sc->sc_total));
206 55 : print_it(" sc_free", "%"PRId64, "0x%"PRIx64, be64_to_cpu(sc->sc_free));
207 55 : print_it(" sc_dinodes", "%"PRId64, "0x%"PRIx64, be64_to_cpu(sc->sc_dinodes));
208 55 : }
209 :
210 0 : void quota_change_print(void *qcp)
211 : {
212 0 : struct gfs2_quota_change *qc = qcp;
213 :
214 0 : print_it(" qc_change", "%"PRId64, "0x%"PRIx64, be64_to_cpu(qc->qc_change));
215 0 : print_it(" qc_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(qc->qc_flags));
216 0 : printbe32(qc, qc_id);
217 0 : }
218 :
|