2 * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
3 * Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
6 * This code is derived from software contributed to Berkeley by
7 * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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
38 * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $
43 static const char rcsid[] =
47 /* ********************************************************** INCLUDES ***** */
48 #include <sys/param.h>
53 #include <ufs/ufs/dinode.h>
54 #include <ufs/ffs/fs.h>
60 /* *********************************************************** GLOBALS ***** */
61 static FILE *dbg_log=NULL;
62 static unsigned int indent=0;
65 * prototypes not done here, as they come with debug.h
68 /* ********************************************************** dbg_open ***** */
70 * Open the filehandle where all debug output has to go.
73 dbg_open(const char *fn)
76 if (strcmp(fn, "-") == 0)
77 dbg_log=fopen("/dev/stdout", "a");
79 dbg_log=fopen(fn, "a");
84 /* ********************************************************* dbg_close ***** */
86 * Close the filehandle where all debug output went to.
100 /* ****************************************************** dbg_dump_hex ***** */
102 * Dump out a full file system block in hex.
105 dbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem)
112 fprintf(dbg_log, "===== START HEXDUMP =====\n");
113 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment);
115 for (i=0; i<sb->fs_bsize; i+=24) {
116 for (j=0; j<3; j++) {
117 for (k=0; k<8; k++) {
118 fprintf(dbg_log, "%02x ", *mem++);
120 fprintf(dbg_log, " ");
122 fprintf(dbg_log, "\n");
125 fprintf(dbg_log, "===== END HEXDUMP =====\n");
130 /* ******************************************************* dbg_dump_fs ***** */
132 * Dump the superblock.
135 dbg_dump_fs(struct fs *sb, const char *comment)
139 #endif /* FSMAXSNAP */
145 fprintf(dbg_log, "===== START SUPERBLOCK =====\n");
146 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment);
149 fprintf(dbg_log, "sblkno int32_t 0x%08x\n",
151 fprintf(dbg_log, "cblkno int32_t 0x%08x\n",
153 fprintf(dbg_log, "iblkno int32_t 0x%08x\n",
155 fprintf(dbg_log, "dblkno int32_t 0x%08x\n",
158 fprintf(dbg_log, "old_cgoffset int32_t 0x%08x\n",
159 sb->fs_old_cgoffset);
160 fprintf(dbg_log, "old_cgmask int32_t 0x%08x\n",
162 fprintf(dbg_log, "old_time int32_t %10u\n",
163 (unsigned int)sb->fs_old_time);
164 fprintf(dbg_log, "old_size int32_t 0x%08x\n",
166 fprintf(dbg_log, "old_dsize int32_t 0x%08x\n",
168 fprintf(dbg_log, "ncg int32_t 0x%08x\n",
170 fprintf(dbg_log, "bsize int32_t 0x%08x\n",
172 fprintf(dbg_log, "fsize int32_t 0x%08x\n",
174 fprintf(dbg_log, "frag int32_t 0x%08x\n",
177 fprintf(dbg_log, "minfree int32_t 0x%08x\n",
179 fprintf(dbg_log, "old_rotdelay int32_t 0x%08x\n",
180 sb->fs_old_rotdelay);
181 fprintf(dbg_log, "old_rps int32_t 0x%08x\n",
184 fprintf(dbg_log, "bmask int32_t 0x%08x\n",
186 fprintf(dbg_log, "fmask int32_t 0x%08x\n",
188 fprintf(dbg_log, "bshift int32_t 0x%08x\n",
190 fprintf(dbg_log, "fshift int32_t 0x%08x\n",
193 fprintf(dbg_log, "maxcontig int32_t 0x%08x\n",
195 fprintf(dbg_log, "maxbpg int32_t 0x%08x\n",
198 fprintf(dbg_log, "fragshift int32_t 0x%08x\n",
200 fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n",
202 fprintf(dbg_log, "sbsize int32_t 0x%08x\n",
204 fprintf(dbg_log, "spare1 int32_t[2] 0x%08x 0x%08x\n",
205 sb->fs_spare1[0], sb->fs_spare1[1]);
206 fprintf(dbg_log, "nindir int32_t 0x%08x\n",
208 fprintf(dbg_log, "inopb int32_t 0x%08x\n",
210 fprintf(dbg_log, "old_nspf int32_t 0x%08x\n",
213 fprintf(dbg_log, "optim int32_t 0x%08x\n",
216 fprintf(dbg_log, "old_npsect int32_t 0x%08x\n",
218 fprintf(dbg_log, "old_interleave int32_t 0x%08x\n",
219 sb->fs_old_interleave);
220 fprintf(dbg_log, "old_trackskew int32_t 0x%08x\n",
221 sb->fs_old_trackskew);
223 fprintf(dbg_log, "id int32_t[2] 0x%08x 0x%08x\n",
224 sb->fs_id[0], sb->fs_id[1]);
226 fprintf(dbg_log, "old_csaddr int32_t 0x%08x\n",
228 fprintf(dbg_log, "cssize int32_t 0x%08x\n",
230 fprintf(dbg_log, "cgsize int32_t 0x%08x\n",
233 fprintf(dbg_log, "spare2 int32_t 0x%08x\n",
235 fprintf(dbg_log, "old_nsect int32_t 0x%08x\n",
237 fprintf(dbg_log, "old_spc int32_t 0x%08x\n",
240 fprintf(dbg_log, "old_ncyl int32_t 0x%08x\n",
243 fprintf(dbg_log, "old_cpg int32_t 0x%08x\n",
245 fprintf(dbg_log, "ipg int32_t 0x%08x\n",
247 fprintf(dbg_log, "fpg int32_t 0x%08x\n",
250 dbg_dump_csum("internal old_cstotal", &sb->fs_old_cstotal);
252 fprintf(dbg_log, "fmod int8_t 0x%02x\n",
254 fprintf(dbg_log, "clean int8_t 0x%02x\n",
256 fprintf(dbg_log, "ronly int8_t 0x%02x\n",
258 fprintf(dbg_log, "old_flags int8_t 0x%02x\n",
260 fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n",
262 fprintf(dbg_log, "volname u_char[MAXVOLLEN] \"%s\"\n",
264 fprintf(dbg_log, "swuid u_int64_t 0x%08x%08x\n",
265 ((unsigned int *)&(sb->fs_swuid))[1],
266 ((unsigned int *)&(sb->fs_swuid))[0]);
268 fprintf(dbg_log, "pad int32_t 0x%08x\n",
271 fprintf(dbg_log, "cgrotor int32_t 0x%08x\n",
274 * struct csum[MAXCSBUFS] - is only maintained in memory
276 /* fprintf(dbg_log, " int32_t\n", sb->*fs_maxcluster);*/
277 fprintf(dbg_log, "old_cpc int32_t 0x%08x\n",
280 * int16_t fs_opostbl[16][8] - is dumped when used in dbg_dump_sptbl
282 fprintf(dbg_log, "maxbsize int32_t 0x%08x\n",
284 fprintf(dbg_log, "sblockloc int64_t 0x%08x%08x\n",
285 ((unsigned int *)&(sb->fs_sblockloc))[1],
286 ((unsigned int *)&(sb->fs_sblockloc))[0]);
288 dbg_dump_csum_total("internal cstotal", &sb->fs_cstotal);
290 fprintf(dbg_log, "time ufs_time_t %10u\n",
291 (unsigned int)sb->fs_time);
293 fprintf(dbg_log, "size int64_t 0x%08x%08x\n",
294 ((unsigned int *)&(sb->fs_size))[1],
295 ((unsigned int *)&(sb->fs_size))[0]);
296 fprintf(dbg_log, "dsize int64_t 0x%08x%08x\n",
297 ((unsigned int *)&(sb->fs_dsize))[1],
298 ((unsigned int *)&(sb->fs_dsize))[0]);
299 fprintf(dbg_log, "csaddr ufs2_daddr_t 0x%08x%08x\n",
300 ((unsigned int *)&(sb->fs_csaddr))[1],
301 ((unsigned int *)&(sb->fs_csaddr))[0]);
302 fprintf(dbg_log, "pendingblocks int64_t 0x%08x%08x\n",
303 ((unsigned int *)&(sb->fs_pendingblocks))[1],
304 ((unsigned int *)&(sb->fs_pendingblocks))[0]);
305 fprintf(dbg_log, "pendinginodes int32_t 0x%08x\n",
306 sb->fs_pendinginodes);
309 for(j=0; j<FSMAXSNAP; j++) {
310 fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n",
311 j, sb->fs_snapinum[j]);
312 if(!sb->fs_snapinum[j]) { /* list is dense */
316 #endif /* FSMAXSNAP */
317 fprintf(dbg_log, "avgfilesize int32_t 0x%08x\n",
319 fprintf(dbg_log, "avgfpdir int32_t 0x%08x\n",
321 fprintf(dbg_log, "save_cgsize int32_t 0x%08x\n",
323 fprintf(dbg_log, "flags int32_t 0x%08x\n",
325 fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n",
326 sb->fs_contigsumsize);
327 fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n",
328 sb->fs_maxsymlinklen);
329 fprintf(dbg_log, "old_inodefmt int32_t 0x%08x\n",
330 sb->fs_old_inodefmt);
331 fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n",
332 ((unsigned int *)&(sb->fs_maxfilesize))[1],
333 ((unsigned int *)&(sb->fs_maxfilesize))[0]);
334 fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n",
335 ((unsigned int *)&(sb->fs_qbmask))[1],
336 ((unsigned int *)&(sb->fs_qbmask))[0]);
337 fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n",
338 ((unsigned int *)&(sb->fs_qfmask))[1],
339 ((unsigned int *)&(sb->fs_qfmask))[0]);
340 fprintf(dbg_log, "state int32_t 0x%08x\n",
342 fprintf(dbg_log, "old_postblformat int32_t 0x%08x\n",
343 sb->fs_old_postblformat);
344 fprintf(dbg_log, "old_nrpos int32_t 0x%08x\n",
346 fprintf(dbg_log, "spare5 int32_t[2] 0x%08x 0x%08x\n",
347 sb->fs_spare5[0], sb->fs_spare5[1]);
348 fprintf(dbg_log, "magic int32_t 0x%08x\n",
352 fprintf(dbg_log, "===== END SUPERBLOCK =====\n");
357 /* ******************************************************* dbg_dump_cg ***** */
359 * Dump a cylinder group.
362 dbg_dump_cg(const char *comment, struct cg *cgr)
370 fprintf(dbg_log, "===== START CYLINDER GROUP =====\n");
371 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
374 fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic);
375 fprintf(dbg_log, "old_time int32_t 0x%08x\n", cgr->cg_old_time);
376 fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx);
377 fprintf(dbg_log, "old_ncyl int16_t 0x%04x\n", cgr->cg_old_ncyl);
378 fprintf(dbg_log, "old_niblk int16_t 0x%04x\n", cgr->cg_old_niblk);
379 fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk);
380 dbg_dump_csum("internal cs", &cgr->cg_cs);
381 fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor);
382 fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor);
383 fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor);
384 for(j=0; j<MAXFRAG; j++) {
385 fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j,
388 fprintf(dbg_log, "old_btotoff int32_t 0x%08x\n", cgr->cg_old_btotoff);
389 fprintf(dbg_log, "old_boff int32_t 0x%08x\n", cgr->cg_old_boff);
390 fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff);
391 fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff);
392 fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n",
393 cgr->cg_nextfreeoff);
394 fprintf(dbg_log, "clustersumoff int32_t 0x%08x\n",
395 cgr->cg_clustersumoff);
396 fprintf(dbg_log, "clusteroff int32_t 0x%08x\n",
398 fprintf(dbg_log, "nclusterblks int32_t 0x%08x\n",
399 cgr->cg_nclusterblks);
400 fprintf(dbg_log, "niblk int32_t 0x%08x\n", cgr->cg_niblk);
401 fprintf(dbg_log, "initediblk int32_t 0x%08x\n", cgr->cg_initediblk);
402 fprintf(dbg_log, "time ufs_time_t %10u\n",
403 (unsigned int)cgr->cg_initediblk);
406 fprintf(dbg_log, "===== END CYLINDER GROUP =====\n");
411 /* ***************************************************** dbg_dump_csum ***** */
413 * Dump a cylinder summary.
416 dbg_dump_csum(const char *comment, struct csum *cs)
423 fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n");
424 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
427 fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir);
428 fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree);
429 fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree);
430 fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree);
433 fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n");
438 /* ************************************************ dbg_dump_csum_total ***** */
440 * Dump a cylinder summary.
443 dbg_dump_csum_total(const char *comment, struct csum_total *cs)
450 fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n");
451 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
454 fprintf(dbg_log, "ndir int64_t 0x%08x%08x\n",
455 ((unsigned int *)&(cs->cs_ndir))[1],
456 ((unsigned int *)&(cs->cs_ndir))[0]);
457 fprintf(dbg_log, "nbfree int64_t 0x%08x%08x\n",
458 ((unsigned int *)&(cs->cs_nbfree))[1],
459 ((unsigned int *)&(cs->cs_nbfree))[0]);
460 fprintf(dbg_log, "nifree int64_t 0x%08x%08x\n",
461 ((unsigned int *)&(cs->cs_nifree))[1],
462 ((unsigned int *)&(cs->cs_nifree))[0]);
463 fprintf(dbg_log, "nffree int64_t 0x%08x%08x\n",
464 ((unsigned int *)&(cs->cs_nffree))[1],
465 ((unsigned int *)&(cs->cs_nffree))[0]);
466 fprintf(dbg_log, "numclusters int64_t 0x%08x%08x\n",
467 ((unsigned int *)&(cs->cs_numclusters))[1],
468 ((unsigned int *)&(cs->cs_numclusters))[0]);
471 fprintf(dbg_log, "===== END CYLINDER SUMMARY TOTAL =====\n");
475 /* **************************************************** dbg_dump_inmap ***** */
477 * Dump the inode allocation map in one cylinder group.
480 dbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr)
489 fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n");
490 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
493 cp=(unsigned char *)cg_inosused(cgr);
495 for(j=0; j<e; j+=32) {
496 fprintf(dbg_log, "%08x: ", j);
497 for(k=0; k<32; k+=8) {
500 "%02x%02x%02x%02x%02x%02x%02x%02x ",
501 cp[0], cp[1], cp[2], cp[3],
502 cp[4], cp[5], cp[6], cp[7]);
504 for(l=0; (l<8)&&(j+k+l<e); l++) {
505 fprintf(dbg_log, "%02x", cp[l]);
510 fprintf(dbg_log, "\n");
514 fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n");
520 /* **************************************************** dbg_dump_frmap ***** */
522 * Dump the fragment allocation map in one cylinder group.
525 dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr)
534 fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n");
535 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
538 cp=(unsigned char *)cg_blksfree(cgr);
540 e=howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT);
543 for(j=0; j<e; j+=32) {
544 fprintf(dbg_log, "%08x: ", j);
545 for(k=0; k<32; k+=8) {
548 "%02x%02x%02x%02x%02x%02x%02x%02x ",
549 cp[0], cp[1], cp[2], cp[3],
550 cp[4], cp[5], cp[6], cp[7]);
552 for(l=0; (l<8)&&(j+k+l<e); l++) {
553 fprintf(dbg_log, "%02x", cp[l]);
558 fprintf(dbg_log, "\n");
562 fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n");
567 /* **************************************************** dbg_dump_clmap ***** */
569 * Dump the cluster allocation map in one cylinder group.
572 dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr)
581 fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n");
582 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
585 cp=(unsigned char *)cg_clustersfree(cgr);
587 e=howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT);
590 for(j=0; j<e; j+=32) {
591 fprintf(dbg_log, "%08x: ", j);
592 for(k=0; k<32; k+=8) {
595 "%02x%02x%02x%02x%02x%02x%02x%02x ",
596 cp[0], cp[1], cp[2], cp[3],
597 cp[4], cp[5], cp[6], cp[7]);
599 for(l=0; (l<8)&&(j+k+l<e); l++) {
600 fprintf(dbg_log, "%02x", cp[l]);
605 fprintf(dbg_log, "\n");
609 fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n");
614 /* **************************************************** dbg_dump_clsum ***** */
616 * Dump the cluster availability summary of one cylinder group.
619 dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr)
628 fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n");
629 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
632 ip=(int *)cg_clustersum(cgr);
633 for(j=0; j<=sb->fs_contigsumsize; j++) {
634 fprintf(dbg_log, "%02d: %8d\n", j, *ip++);
638 fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n");
645 * This code dates from before the UFS2 integration, and doesn't compile
646 * post-UFS2 due to the use of cg_blks(). I'm not sure how best to update
647 * this for UFS2, where the rotational bits of UFS no longer apply, so
648 * will leave it disabled for now; it should probably be re-enabled
649 * specifically for UFS1.
651 /* **************************************************** dbg_dump_sptbl ***** */
653 * Dump the block summary, and the rotational layout table.
656 dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr)
666 "===== START BLOCK SUMMARY AND POSITION TABLE =====\n");
667 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
670 ip=(int *)cg_blktot(cgr);
671 for(j=0; j<sb->fs_old_cpg; j++) {
672 fprintf(dbg_log, "%2d: %5d = ", j, *ip++);
673 for(k=0; k<sb->fs_old_nrpos; k++) {
674 fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]);
675 if(k<sb->fs_old_nrpos-1) {
676 fprintf(dbg_log, " + ");
679 fprintf(dbg_log, "\n");
683 fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n");
689 /* ************************************************** dbg_dump_ufs1_ino ***** */
691 * Dump a UFS1 inode structure.
694 dbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino)
697 int remaining_blocks;
703 fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n");
704 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
707 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode);
708 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink);
709 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n",
710 ((unsigned int *)&(ino->di_size))[1],
711 ((unsigned int *)&(ino->di_size))[0]);
712 fprintf(dbg_log, "atime int32_t 0x%08x\n", ino->di_atime);
713 fprintf(dbg_log, "atimensec int32_t 0x%08x\n",
715 fprintf(dbg_log, "mtime int32_t 0x%08x\n",
717 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n",
719 fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime);
720 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n",
723 remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
724 for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
725 fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr,
728 remaining_blocks-=NDADDR;
729 if(remaining_blocks>0) {
730 fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n",
733 remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs1_daddr_t));
734 if(remaining_blocks>0) {
735 fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n",
738 #define SQUARE(a) ((a)*(a))
739 remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)));
741 if(remaining_blocks>0) {
742 fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n",
746 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
747 fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks);
748 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen);
749 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid);
750 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid);
753 fprintf(dbg_log, "===== END UFS1 INODE DUMP =====\n");
758 /* ************************************************** dbg_dump_ufs2_ino ***** */
760 * Dump a UFS2 inode structure.
763 dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino)
766 int remaining_blocks;
772 fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n");
773 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
776 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode);
777 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink);
778 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid);
779 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid);
780 fprintf(dbg_log, "blksize u_int32_t 0x%08x\n", ino->di_blksize);
781 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n",
782 ((unsigned int *)&(ino->di_size))[1],
783 ((unsigned int *)&(ino->di_size))[0]);
784 fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n",
785 ((unsigned int *)&(ino->di_blocks))[1],
786 ((unsigned int *)&(ino->di_blocks))[0]);
787 fprintf(dbg_log, "atime ufs_time_t %10jd\n", ino->di_atime);
788 fprintf(dbg_log, "mtime ufs_time_t %10jd\n", ino->di_mtime);
789 fprintf(dbg_log, "ctime ufs_time_t %10jd\n", ino->di_ctime);
790 fprintf(dbg_log, "birthtime ufs_time_t %10jd\n", ino->di_birthtime);
791 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", ino->di_mtimensec);
792 fprintf(dbg_log, "atimensec int32_t 0x%08x\n", ino->di_atimensec);
793 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", ino->di_ctimensec);
794 fprintf(dbg_log, "birthnsec int32_t 0x%08x\n", ino->di_birthnsec);
795 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen);
796 fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags);
797 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
798 fprintf(dbg_log, "extsize int32_t 0x%08x\n", ino->di_extsize);
800 /* XXX: What do we do with di_extb[NXADDR]? */
802 remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
803 for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
804 fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr,
807 remaining_blocks-=NDADDR;
808 if(remaining_blocks>0) {
809 fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n",
812 remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs2_daddr_t));
813 if(remaining_blocks>0) {
814 fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16jx\n",
817 #define SQUARE(a) ((a)*(a))
818 remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)));
820 if(remaining_blocks>0) {
821 fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16jx\n",
826 fprintf(dbg_log, "===== END UFS2 INODE DUMP =====\n");
831 /* ***************************************************** dbg_dump_iblk ***** */
833 * Dump an indirect block. The iteration to dump a full file has to be
837 dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length)
839 unsigned int *mem, i, j, size;
845 fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n");
846 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block,
850 if (sb->fs_magic == FS_UFS1_MAGIC)
851 size = sizeof(ufs1_daddr_t);
853 size = sizeof(ufs2_daddr_t);
855 mem=(unsigned int *)block;
856 for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, size),
858 fprintf(dbg_log, "%04x: ", i);
859 for (j=0; j<8; j++) {
860 if((size_t)(i+j)<length) {
861 fprintf(dbg_log, "%08X ", *mem++);
864 fprintf(dbg_log, "\n");
868 fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n");
873 #endif /* FS_DEBUG */