Pre-2.0 release: Sync with HAMMER 64 - NFS and cross-device link fixes.
[dragonfly.git] / sbin / growfs / debug.c
bloba58bce094965e3bed6765581854afc1f6cd7b873
1 /*
2 * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
3 * Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgment:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors, as well as Christoph
21 * Herrmann and Thomas-Henning von Kamptz.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
38 * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $
39 * $FreeBSD: src/sbin/growfs/debug.c,v 1.3.2.1 2001/07/16 15:02:13 tomsoft Exp $
40 * $DragonFly: src/sbin/growfs/debug.c,v 1.5 2007/05/20 23:21:36 dillon Exp $
42 * $FreeBSD: src/sbin/growfs/debug.c,v 1.3.2.1 2001/07/16 15:02:13 tomsoft Exp $
45 /* ********************************************************** INCLUDES ***** */
46 #include <sys/param.h>
48 #include <stdio.h>
49 #include <vfs/ufs/dinode.h>
50 #include <vfs/ufs/fs.h>
52 #include "debug.h"
54 #ifdef FS_DEBUG
56 /* *********************************************************** GLOBALS ***** */
57 static FILE *dbg_log;
58 static unsigned int indent;
59 static unsigned int dbg_log_isstdout;
62 * prototypes not done here, as they come with debug.h
65 /* ********************************************************** dbg_open ***** */
67 * Open the filehandle where all debug output has to go.
69 void
70 dbg_open(const char *fn)
72 if (fn) {
73 dbg_log=fopen(fn, "a");
74 } else {
75 dbg_log_isstdout = 1;
76 dbg_log=stdout;
79 return;
82 /* ********************************************************* dbg_close ***** */
84 * Close the filehandle where all debug output went to.
86 void
87 dbg_close(void)
89 if (dbg_log && dbg_log_isstdout == 0) {
90 fclose(dbg_log);
92 dbg_log = NULL;
93 dbg_log_isstdout = 0;
95 return;
98 /* ****************************************************** dbg_dump_hex ***** */
100 * Dump out a full filesystem block in hex.
102 void
103 dbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem)
105 int i, j, k;
107 if(!dbg_log) {
108 return;
110 fprintf(dbg_log, "===== START HEXDUMP =====\n");
111 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment);
112 indent++;
113 for (i=0; i<sb->fs_bsize; i+=24) {
114 for (j=0; j<3; j++) {
115 for (k=0; k<8; k++) {
116 fprintf(dbg_log, "%02x ", *mem++);
118 fprintf(dbg_log, " ");
120 fprintf(dbg_log, "\n");
122 indent--;
123 fprintf(dbg_log, "===== END HEXDUMP =====\n");
125 return;
128 /* ******************************************************* dbg_dump_fs ***** */
130 * Dump the superblock.
132 void
133 dbg_dump_fs(struct fs *sb, const char *comment)
135 #ifdef FSMAXSNAP
136 int j;
137 #endif /* FSMAXSNAP */
139 if(!dbg_log) {
140 return;
143 fprintf(dbg_log, "===== START SUPERBLOCK =====\n");
144 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment);
145 indent++;
147 fprintf(dbg_log, "sblkno ufs_daddr_t 0x%08x\n",
148 sb->fs_sblkno);
149 fprintf(dbg_log, "cblkno ufs_daddr_t 0x%08x\n",
150 sb->fs_cblkno);
151 fprintf(dbg_log, "iblkno ufs_daddr_t 0x%08x\n",
152 sb->fs_iblkno);
153 fprintf(dbg_log, "dblkno ufs_daddr_t 0x%08x\n",
154 sb->fs_dblkno);
156 fprintf(dbg_log, "cgoffset int32_t 0x%08x\n",
157 sb->fs_cgoffset);
158 fprintf(dbg_log, "cgmask int32_t 0x%08x\n",
159 sb->fs_cgmask);
160 fprintf(dbg_log, "time time_t %10u\n",
161 (unsigned int)sb->fs_time);
162 fprintf(dbg_log, "size int32_t 0x%08x\n",
163 sb->fs_size);
164 fprintf(dbg_log, "dsize int32_t 0x%08x\n",
165 sb->fs_dsize);
166 fprintf(dbg_log, "ncg int32_t 0x%08x\n",
167 sb->fs_ncg);
168 fprintf(dbg_log, "bsize int32_t 0x%08x\n",
169 sb->fs_bsize);
170 fprintf(dbg_log, "fsize int32_t 0x%08x\n",
171 sb->fs_fsize);
172 fprintf(dbg_log, "frag int32_t 0x%08x\n",
173 sb->fs_frag);
175 fprintf(dbg_log, "minfree int32_t 0x%08x\n",
176 sb->fs_minfree);
177 fprintf(dbg_log, "rotdelay int32_t 0x%08x\n",
178 sb->fs_rotdelay);
179 fprintf(dbg_log, "rps int32_t 0x%08x\n",
180 sb->fs_rps);
182 fprintf(dbg_log, "bmask int32_t 0x%08x\n",
183 sb->fs_bmask);
184 fprintf(dbg_log, "fmask int32_t 0x%08x\n",
185 sb->fs_fmask);
186 fprintf(dbg_log, "bshift int32_t 0x%08x\n",
187 sb->fs_bshift);
188 fprintf(dbg_log, "fshift int32_t 0x%08x\n",
189 sb->fs_fshift);
191 fprintf(dbg_log, "maxcontig int32_t 0x%08x\n",
192 sb->fs_maxcontig);
193 fprintf(dbg_log, "maxbpg int32_t 0x%08x\n",
194 sb->fs_maxbpg);
196 fprintf(dbg_log, "fragshift int32_t 0x%08x\n",
197 sb->fs_fragshift);
198 fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n",
199 sb->fs_fsbtodb);
200 fprintf(dbg_log, "sbsize int32_t 0x%08x\n",
201 sb->fs_sbsize);
202 fprintf(dbg_log, "csmask int32_t 0x%08x\n",
203 sb->fs_csmask);
204 fprintf(dbg_log, "csshift int32_t 0x%08x\n",
205 sb->fs_csshift);
206 fprintf(dbg_log, "nindir int32_t 0x%08x\n",
207 sb->fs_nindir);
208 fprintf(dbg_log, "inopb int32_t 0x%08x\n",
209 sb->fs_inopb);
210 fprintf(dbg_log, "nspf int32_t 0x%08x\n",
211 sb->fs_nspf);
213 fprintf(dbg_log, "optim int32_t 0x%08x\n",
214 sb->fs_optim);
216 fprintf(dbg_log, "npsect int32_t 0x%08x\n",
217 sb->fs_npsect);
218 fprintf(dbg_log, "interleave int32_t 0x%08x\n",
219 sb->fs_interleave);
220 fprintf(dbg_log, "trackskew int32_t 0x%08x\n",
221 sb->fs_trackskew);
223 fprintf(dbg_log, "id int32_t[2] %08x %08x\n",
224 sb->fs_id[0], sb->fs_id[1]);
226 fprintf(dbg_log, "csaddr ufs_daddr_t 0x%08x\n",
227 sb->fs_csaddr);
228 fprintf(dbg_log, "cssize int32_t 0x%08x\n",
229 sb->fs_cssize);
230 fprintf(dbg_log, "cgsize int32_t 0x%08x\n",
231 sb->fs_cgsize);
233 fprintf(dbg_log, "ntrak int32_t 0x%08x\n",
234 sb->fs_ntrak);
235 fprintf(dbg_log, "nsect int32_t 0x%08x\n",
236 sb->fs_nsect);
237 fprintf(dbg_log, "spc int32_t 0x%08x\n",
238 sb->fs_spc);
240 fprintf(dbg_log, "ncyl int32_t 0x%08x\n",
241 sb->fs_ncyl);
243 fprintf(dbg_log, "cpg int32_t 0x%08x\n",
244 sb->fs_cpg);
245 fprintf(dbg_log, "ipg int32_t 0x%08x\n",
246 sb->fs_ipg);
247 fprintf(dbg_log, "fpg int32_t 0x%08x\n",
248 sb->fs_fpg);
250 dbg_dump_csum("internal cstotal", &sb->fs_cstotal);
252 fprintf(dbg_log, "fmod int8_t 0x%02x\n",
253 sb->fs_fmod);
254 fprintf(dbg_log, "clean int8_t 0x%02x\n",
255 sb->fs_clean);
256 fprintf(dbg_log, "ronly int8_t 0x%02x\n",
257 sb->fs_ronly);
258 fprintf(dbg_log, "flags int8_t 0x%02x\n",
259 sb->fs_flags);
260 fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n",
261 sb->fs_fsmnt);
263 fprintf(dbg_log, "cgrotor int32_t 0x%08x\n",
264 sb->fs_cgrotor);
266 * struct csum[MAXCSBUFS] - is only maintained in memory
268 /* fprintf(dbg_log, " int32_t\n", sb->*fs_maxcluster);*/
269 fprintf(dbg_log, "cpc int32_t 0x%08x\n",
270 sb->fs_cpc);
272 * int16_t fs_opostbl[16][8] - is dumped when used in dbg_dump_sptbl
274 #ifdef FSMAXSNAP
275 for(j=0; j<FSMAXSNAP; j++) {
276 fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n",
277 j, sb->fs_snapinum[j]);
278 if(!sb->fs_snapinum[j]) { /* list is dense */
279 break;
282 #endif /* FSMAXSNAP */
283 fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n",
284 sb->fs_contigsumsize);
285 fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n",
286 sb->fs_maxsymlinklen);
287 fprintf(dbg_log, "inodefmt int32_t 0x%08x\n",
288 sb->fs_inodefmt);
289 fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n",
290 ((unsigned int *)&(sb->fs_maxfilesize))[1],
291 ((unsigned int *)&(sb->fs_maxfilesize))[0]);
292 fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n",
293 ((unsigned int *)&(sb->fs_qbmask))[1],
294 ((unsigned int *)&(sb->fs_qbmask))[0]);
295 fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n",
296 ((unsigned int *)&(sb->fs_qfmask))[1],
297 ((unsigned int *)&(sb->fs_qfmask))[0]);
298 fprintf(dbg_log, "state int32_t 0x%08x\n",
299 sb->fs_state);
300 fprintf(dbg_log, "postblformat int32_t 0x%08x\n",
301 sb->fs_postblformat);
302 fprintf(dbg_log, "nrpos int32_t 0x%08x\n",
303 sb->fs_nrpos);
304 fprintf(dbg_log, "postbloff int32_t 0x%08x\n",
305 sb->fs_postbloff);
306 fprintf(dbg_log, "rotbloff int32_t 0x%08x\n",
307 sb->fs_rotbloff);
308 fprintf(dbg_log, "magic int32_t 0x%08x\n",
309 sb->fs_magic);
311 indent--;
312 fprintf(dbg_log, "===== END SUPERBLOCK =====\n");
314 return;
317 /* ******************************************************* dbg_dump_cg ***** */
319 * Dump a cylinder group.
321 void
322 dbg_dump_cg(const char *comment, struct cg *cgr)
324 int j;
326 if(!dbg_log) {
327 return;
330 fprintf(dbg_log, "===== START CYLINDER GROUP =====\n");
331 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
332 indent++;
334 fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic);
335 fprintf(dbg_log, "time time_t %10u\n", (unsigned int)
336 cgr->cg_time);
337 fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx);
338 fprintf(dbg_log, "ncyl int16_t 0x%04x\n", cgr->cg_ncyl);
339 fprintf(dbg_log, "niblk int16_t 0x%04x\n", cgr->cg_niblk);
340 fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk);
341 dbg_dump_csum("internal cs", &cgr->cg_cs);
342 fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor);
343 fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor);
344 fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor);
345 for(j=0; j<MAXFRAG; j++) {
346 fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j,
347 cgr->cg_frsum[j]);
349 fprintf(dbg_log, "btotoff int32_t 0x%08x\n", cgr->cg_btotoff);
350 fprintf(dbg_log, "boff int32_t 0x%08x\n", cgr->cg_boff);
351 fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff);
352 fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff);
353 fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n",
354 cgr->cg_nextfreeoff);
355 fprintf(dbg_log, "clustersumoff int32_t 0x%08x\n",
356 cgr->cg_clustersumoff);
357 fprintf(dbg_log, "clusterof int32_t 0x%08x\n",
358 cgr->cg_clusteroff);
359 fprintf(dbg_log, "nclusterblks int32_t 0x%08x\n",
360 cgr->cg_nclusterblks);
362 indent--;
363 fprintf(dbg_log, "===== END CYLINDER GROUP =====\n");
365 return;
368 /* ***************************************************** dbg_dump_csum ***** */
370 * Dump a cylinder summary.
372 void
373 dbg_dump_csum(const char *comment, struct csum *cs)
376 if(!dbg_log) {
377 return;
380 fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n");
381 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
382 indent++;
384 fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir);
385 fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree);
386 fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree);
387 fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree);
389 indent--;
390 fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n");
392 return;
395 /* **************************************************** dbg_dump_inmap ***** */
397 * Dump the inode allocation map in one cylinder group.
399 void
400 dbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr)
402 int j,k,l,e;
403 unsigned char *cp;
405 if(!dbg_log) {
406 return;
409 fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n");
410 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
411 indent++;
413 cp=(unsigned char *)cg_inosused(cgr);
414 e=sb->fs_ipg/8;
415 for(j=0; j<e; j+=32) {
416 fprintf(dbg_log, "%08x: ", j);
417 for(k=0; k<32; k+=8) {
418 if(j+k+8<e) {
419 fprintf(dbg_log,
420 "%02x%02x%02x%02x%02x%02x%02x%02x ",
421 cp[0], cp[1], cp[2], cp[3],
422 cp[4], cp[5], cp[6], cp[7]);
423 } else {
424 for(l=0; (l<8)&&(j+k+l<e); l++) {
425 fprintf(dbg_log, "%02x", cp[l]);
428 cp+=8;
430 fprintf(dbg_log, "\n");
433 indent--;
434 fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n");
436 return;
440 /* **************************************************** dbg_dump_frmap ***** */
442 * Dump the fragment allocation map in one cylinder group.
444 void
445 dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr)
447 int j,k,l,e;
448 unsigned char *cp;
450 if(!dbg_log) {
451 return;
454 fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n");
455 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
456 indent++;
458 cp=(unsigned char *)cg_blksfree(cgr);
459 e=howmany((sb->fs_cpg * sb->fs_spc / NSPF(sb)), NBBY);
460 for(j=0; j<e; j+=32) {
461 fprintf(dbg_log, "%08x: ", j);
462 for(k=0; k<32; k+=8) {
463 if(j+k+8<e) {
464 fprintf(dbg_log,
465 "%02x%02x%02x%02x%02x%02x%02x%02x ",
466 cp[0], cp[1], cp[2], cp[3],
467 cp[4], cp[5], cp[6], cp[7]);
468 } else {
469 for(l=0; (l<8)&&(j+k+l<e); l++) {
470 fprintf(dbg_log, "%02x", cp[l]);
473 cp+=8;
475 fprintf(dbg_log, "\n");
478 indent--;
479 fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n");
481 return;
484 /* **************************************************** dbg_dump_clmap ***** */
486 * Dump the cluster allocation map in one cylinder group.
488 void
489 dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr)
491 int j,k,l,e;
492 unsigned char *cp;
494 if(!dbg_log) {
495 return;
498 fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n");
499 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
500 indent++;
502 cp=(unsigned char *)cg_clustersfree(cgr);
503 e=howmany(sb->fs_cpg * sb->fs_spc / NSPB(sb), NBBY);
504 for(j=0; j<e; j+=32) {
505 fprintf(dbg_log, "%08x: ", j);
506 for(k=0; k<32; k+=8) {
507 if(j+k+8<e) {
508 fprintf(dbg_log,
509 "%02x%02x%02x%02x%02x%02x%02x%02x ",
510 cp[0], cp[1], cp[2], cp[3],
511 cp[4], cp[5], cp[6], cp[7]);
512 } else {
513 for(l=0; (l<8)&&(j+k+l<e); l++) {
514 fprintf(dbg_log, "%02x", cp[l]);
517 cp+=8;
519 fprintf(dbg_log, "\n");
522 indent--;
523 fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n");
525 return;
528 /* **************************************************** dbg_dump_clsum ***** */
530 * Dump the cluster availability summary of one cylinder group.
532 void
533 dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr)
535 int j;
536 int *ip;
538 if(!dbg_log) {
539 return;
542 fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n");
543 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
544 indent++;
546 ip=(int *)cg_clustersum(cgr);
547 for(j=0; j<=sb->fs_contigsumsize; j++) {
548 fprintf(dbg_log, "%02d: %8d\n", j, *ip++);
551 indent--;
552 fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n");
554 return;
557 /* **************************************************** dbg_dump_sptbl ***** */
559 * Dump the block summary, and the rotational layout table.
561 void
562 dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr)
564 int j,k;
565 int *ip;
567 if(!dbg_log) {
568 return;
571 fprintf(dbg_log,
572 "===== START BLOCK SUMMARY AND POSITION TABLE =====\n");
573 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
574 indent++;
576 ip=(int *)cg_blktot(cgr);
577 for(j=0; j<sb->fs_cpg; j++) {
578 fprintf(dbg_log, "%2d: %5d = ", j, *ip++);
579 for(k=0; k<sb->fs_nrpos; k++) {
580 fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]);
581 if(k<sb->fs_nrpos-1) {
582 fprintf(dbg_log, " + ");
585 fprintf(dbg_log, "\n");
588 indent--;
589 fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n");
591 return;
594 /* ****************************************************** dbg_dump_ino ***** */
596 * Dump an inode structure.
598 void
599 dbg_dump_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino)
601 int ictr;
602 int remaining_blocks;
604 if(!dbg_log) {
605 return;
608 fprintf(dbg_log, "===== START INODE DUMP =====\n");
609 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
610 indent++;
612 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode);
613 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink);
614 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n",
615 ((unsigned int *)&(ino->di_size))[1],
616 ((unsigned int *)&(ino->di_size))[0]);
617 fprintf(dbg_log, "atime int32_t 0x%08x\n", ino->di_atime);
618 fprintf(dbg_log, "atimensec int32_t 0x%08x\n",
619 ino->di_atimensec);
620 fprintf(dbg_log, "mtime int32_t 0x%08x\n",
621 ino->di_mtime);
622 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n",
623 ino->di_mtimensec);
624 fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime);
625 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n",
626 ino->di_ctimensec);
628 remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
629 for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
630 fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr,
631 ino->di_db[ictr]);
633 remaining_blocks-=NDADDR;
634 if(remaining_blocks>0) {
635 fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n",
636 ino->di_ib[0]);
638 remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs_daddr_t));
639 if(remaining_blocks>0) {
640 fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n",
641 ino->di_ib[1]);
643 #define SQUARE(a) ((a)*(a))
644 remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs_daddr_t)));
645 #undef SQUARE
646 if(remaining_blocks>0) {
647 fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n",
648 ino->di_ib[2]);
651 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
652 fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks);
653 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen);
654 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid);
655 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid);
657 indent--;
658 fprintf(dbg_log, "===== END INODE DUMP =====\n");
660 return;
663 /* ***************************************************** dbg_dump_iblk ***** */
665 * Dump an indirect block. The iteration to dump a full file has to be
666 * written around.
668 void
669 dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length)
671 unsigned int *mem;
672 int i, j;
674 if(!dbg_log) {
675 return;
678 fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n");
679 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block,
680 comment);
681 indent++;
683 mem=(unsigned int *)block;
684 for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, sizeof(ufs_daddr_t)),
685 length); i+=8) {
686 fprintf(dbg_log, "%04x: ", i);
687 for (j=0; j<8; j++) {
688 if((size_t)(i+j)<length) {
689 fprintf(dbg_log, "%08X ", *mem++);
692 fprintf(dbg_log, "\n");
695 indent--;
696 fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n");
698 return;
701 #endif /* FS_DEBUG */