hammer2 - Shift inode xop functions into hammer2_xop.c
[dragonfly.git] / sbin / growfs / debug.c
blob0ad3004f5bae5bb56e1e45eae194e3a72da6aa81
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 $
42 /* ********************************************************** INCLUDES ***** */
43 #include <sys/param.h>
45 #include <stdio.h>
46 #include <vfs/ufs/dinode.h>
47 #include <vfs/ufs/fs.h>
49 #include "debug.h"
51 #ifdef FS_DEBUG
53 /* *********************************************************** GLOBALS ***** */
54 static FILE *dbg_log;
55 static unsigned int indent;
56 static unsigned int dbg_log_isstdout;
59 * prototypes not done here, as they come with debug.h
62 /* ********************************************************** dbg_open ***** */
64 * Open the filehandle where all debug output has to go.
66 void
67 dbg_open(const char *fn)
69 if (fn) {
70 dbg_log=fopen(fn, "a");
71 } else {
72 dbg_log_isstdout = 1;
73 dbg_log=stdout;
76 return;
79 /* ********************************************************* dbg_close ***** */
81 * Close the filehandle where all debug output went to.
83 void
84 dbg_close(void)
86 if (dbg_log && dbg_log_isstdout == 0) {
87 fclose(dbg_log);
89 dbg_log = NULL;
90 dbg_log_isstdout = 0;
92 return;
95 /* ****************************************************** dbg_dump_hex ***** */
97 * Dump out a full filesystem block in hex.
99 void
100 dbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem)
102 int i, j, k;
104 if(!dbg_log) {
105 return;
107 fprintf(dbg_log, "===== START HEXDUMP =====\n");
108 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment);
109 indent++;
110 for (i=0; i<sb->fs_bsize; i+=24) {
111 for (j=0; j<3; j++) {
112 for (k=0; k<8; k++) {
113 fprintf(dbg_log, "%02x ", *mem++);
115 fprintf(dbg_log, " ");
117 fprintf(dbg_log, "\n");
119 indent--;
120 fprintf(dbg_log, "===== END HEXDUMP =====\n");
122 return;
125 /* ******************************************************* dbg_dump_fs ***** */
127 * Dump the superblock.
129 void
130 dbg_dump_fs(struct fs *sb, const char *comment)
132 #ifdef FSMAXSNAP
133 int j;
134 #endif /* FSMAXSNAP */
136 if(!dbg_log) {
137 return;
140 fprintf(dbg_log, "===== START SUPERBLOCK =====\n");
141 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment);
142 indent++;
144 fprintf(dbg_log, "sblkno ufs_daddr_t 0x%08x\n",
145 sb->fs_sblkno);
146 fprintf(dbg_log, "cblkno ufs_daddr_t 0x%08x\n",
147 sb->fs_cblkno);
148 fprintf(dbg_log, "iblkno ufs_daddr_t 0x%08x\n",
149 sb->fs_iblkno);
150 fprintf(dbg_log, "dblkno ufs_daddr_t 0x%08x\n",
151 sb->fs_dblkno);
153 fprintf(dbg_log, "cgoffset int32_t 0x%08x\n",
154 sb->fs_cgoffset);
155 fprintf(dbg_log, "cgmask int32_t 0x%08x\n",
156 sb->fs_cgmask);
157 fprintf(dbg_log, "time time_t %10u\n",
158 (unsigned int)sb->fs_time);
159 fprintf(dbg_log, "size int32_t 0x%08x\n",
160 sb->fs_size);
161 fprintf(dbg_log, "dsize int32_t 0x%08x\n",
162 sb->fs_dsize);
163 fprintf(dbg_log, "ncg int32_t 0x%08x\n",
164 sb->fs_ncg);
165 fprintf(dbg_log, "bsize int32_t 0x%08x\n",
166 sb->fs_bsize);
167 fprintf(dbg_log, "fsize int32_t 0x%08x\n",
168 sb->fs_fsize);
169 fprintf(dbg_log, "frag int32_t 0x%08x\n",
170 sb->fs_frag);
172 fprintf(dbg_log, "minfree int32_t 0x%08x\n",
173 sb->fs_minfree);
174 fprintf(dbg_log, "rotdelay int32_t 0x%08x\n",
175 sb->fs_rotdelay);
176 fprintf(dbg_log, "rps int32_t 0x%08x\n",
177 sb->fs_rps);
179 fprintf(dbg_log, "bmask int32_t 0x%08x\n",
180 sb->fs_bmask);
181 fprintf(dbg_log, "fmask int32_t 0x%08x\n",
182 sb->fs_fmask);
183 fprintf(dbg_log, "bshift int32_t 0x%08x\n",
184 sb->fs_bshift);
185 fprintf(dbg_log, "fshift int32_t 0x%08x\n",
186 sb->fs_fshift);
188 fprintf(dbg_log, "maxcontig int32_t 0x%08x\n",
189 sb->fs_maxcontig);
190 fprintf(dbg_log, "maxbpg int32_t 0x%08x\n",
191 sb->fs_maxbpg);
193 fprintf(dbg_log, "fragshift int32_t 0x%08x\n",
194 sb->fs_fragshift);
195 fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n",
196 sb->fs_fsbtodb);
197 fprintf(dbg_log, "sbsize int32_t 0x%08x\n",
198 sb->fs_sbsize);
199 fprintf(dbg_log, "csmask int32_t 0x%08x\n",
200 sb->fs_csmask);
201 fprintf(dbg_log, "csshift int32_t 0x%08x\n",
202 sb->fs_csshift);
203 fprintf(dbg_log, "nindir int32_t 0x%08x\n",
204 sb->fs_nindir);
205 fprintf(dbg_log, "inopb int32_t 0x%08x\n",
206 sb->fs_inopb);
207 fprintf(dbg_log, "nspf int32_t 0x%08x\n",
208 sb->fs_nspf);
210 fprintf(dbg_log, "optim int32_t 0x%08x\n",
211 sb->fs_optim);
213 fprintf(dbg_log, "npsect int32_t 0x%08x\n",
214 sb->fs_npsect);
215 fprintf(dbg_log, "interleave int32_t 0x%08x\n",
216 sb->fs_interleave);
217 fprintf(dbg_log, "trackskew int32_t 0x%08x\n",
218 sb->fs_trackskew);
220 fprintf(dbg_log, "id int32_t[2] %08x %08x\n",
221 sb->fs_id[0], sb->fs_id[1]);
223 fprintf(dbg_log, "csaddr ufs_daddr_t 0x%08x\n",
224 sb->fs_csaddr);
225 fprintf(dbg_log, "cssize int32_t 0x%08x\n",
226 sb->fs_cssize);
227 fprintf(dbg_log, "cgsize int32_t 0x%08x\n",
228 sb->fs_cgsize);
230 fprintf(dbg_log, "ntrak int32_t 0x%08x\n",
231 sb->fs_ntrak);
232 fprintf(dbg_log, "nsect int32_t 0x%08x\n",
233 sb->fs_nsect);
234 fprintf(dbg_log, "spc int32_t 0x%08x\n",
235 sb->fs_spc);
237 fprintf(dbg_log, "ncyl int32_t 0x%08x\n",
238 sb->fs_ncyl);
240 fprintf(dbg_log, "cpg int32_t 0x%08x\n",
241 sb->fs_cpg);
242 fprintf(dbg_log, "ipg int32_t 0x%08x\n",
243 sb->fs_ipg);
244 fprintf(dbg_log, "fpg int32_t 0x%08x\n",
245 sb->fs_fpg);
247 dbg_dump_csum("internal cstotal", &sb->fs_cstotal);
249 fprintf(dbg_log, "fmod int8_t 0x%02x\n",
250 sb->fs_fmod);
251 fprintf(dbg_log, "clean int8_t 0x%02x\n",
252 sb->fs_clean);
253 fprintf(dbg_log, "ronly int8_t 0x%02x\n",
254 sb->fs_ronly);
255 fprintf(dbg_log, "flags int8_t 0x%02x\n",
256 sb->fs_flags);
257 fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n",
258 sb->fs_fsmnt);
260 fprintf(dbg_log, "cgrotor int32_t 0x%08x\n",
261 sb->fs_cgrotor);
263 * struct csum[MAXCSBUFS] - is only maintained in memory
265 /* fprintf(dbg_log, " int32_t\n", sb->*fs_maxcluster);*/
266 fprintf(dbg_log, "cpc int32_t 0x%08x\n",
267 sb->fs_cpc);
269 * int16_t fs_opostbl[16][8] - is dumped when used in dbg_dump_sptbl
271 #ifdef FSMAXSNAP
272 for(j=0; j<FSMAXSNAP; j++) {
273 fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n",
274 j, sb->fs_snapinum[j]);
275 if(!sb->fs_snapinum[j]) { /* list is dense */
276 break;
279 #endif /* FSMAXSNAP */
280 fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n",
281 sb->fs_contigsumsize);
282 fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n",
283 sb->fs_maxsymlinklen);
284 fprintf(dbg_log, "inodefmt int32_t 0x%08x\n",
285 sb->fs_inodefmt);
286 fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n",
287 ((unsigned int *)&(sb->fs_maxfilesize))[1],
288 ((unsigned int *)&(sb->fs_maxfilesize))[0]);
289 fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n",
290 ((unsigned int *)&(sb->fs_qbmask))[1],
291 ((unsigned int *)&(sb->fs_qbmask))[0]);
292 fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n",
293 ((unsigned int *)&(sb->fs_qfmask))[1],
294 ((unsigned int *)&(sb->fs_qfmask))[0]);
295 fprintf(dbg_log, "state int32_t 0x%08x\n",
296 sb->fs_state);
297 fprintf(dbg_log, "postblformat int32_t 0x%08x\n",
298 sb->fs_postblformat);
299 fprintf(dbg_log, "nrpos int32_t 0x%08x\n",
300 sb->fs_nrpos);
301 fprintf(dbg_log, "postbloff int32_t 0x%08x\n",
302 sb->fs_postbloff);
303 fprintf(dbg_log, "rotbloff int32_t 0x%08x\n",
304 sb->fs_rotbloff);
305 fprintf(dbg_log, "magic int32_t 0x%08x\n",
306 sb->fs_magic);
308 indent--;
309 fprintf(dbg_log, "===== END SUPERBLOCK =====\n");
311 return;
314 /* ******************************************************* dbg_dump_cg ***** */
316 * Dump a cylinder group.
318 void
319 dbg_dump_cg(const char *comment, struct cg *cgr)
321 int j;
323 if(!dbg_log) {
324 return;
327 fprintf(dbg_log, "===== START CYLINDER GROUP =====\n");
328 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
329 indent++;
331 fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic);
332 fprintf(dbg_log, "time time_t %10u\n", (unsigned int)
333 cgr->cg_time);
334 fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx);
335 fprintf(dbg_log, "ncyl int16_t 0x%04x\n", cgr->cg_ncyl);
336 fprintf(dbg_log, "niblk int16_t 0x%04x\n", cgr->cg_niblk);
337 fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk);
338 dbg_dump_csum("internal cs", &cgr->cg_cs);
339 fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor);
340 fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor);
341 fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor);
342 for(j=0; j<MAXFRAG; j++) {
343 fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j,
344 cgr->cg_frsum[j]);
346 fprintf(dbg_log, "btotoff int32_t 0x%08x\n", cgr->cg_btotoff);
347 fprintf(dbg_log, "boff int32_t 0x%08x\n", cgr->cg_boff);
348 fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff);
349 fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff);
350 fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n",
351 cgr->cg_nextfreeoff);
352 fprintf(dbg_log, "clustersumoff int32_t 0x%08x\n",
353 cgr->cg_clustersumoff);
354 fprintf(dbg_log, "clusterof int32_t 0x%08x\n",
355 cgr->cg_clusteroff);
356 fprintf(dbg_log, "nclusterblks int32_t 0x%08x\n",
357 cgr->cg_nclusterblks);
359 indent--;
360 fprintf(dbg_log, "===== END CYLINDER GROUP =====\n");
362 return;
365 /* ***************************************************** dbg_dump_csum ***** */
367 * Dump a cylinder summary.
369 void
370 dbg_dump_csum(const char *comment, struct csum *cs)
373 if(!dbg_log) {
374 return;
377 fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n");
378 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
379 indent++;
381 fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir);
382 fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree);
383 fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree);
384 fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree);
386 indent--;
387 fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n");
389 return;
392 /* **************************************************** dbg_dump_inmap ***** */
394 * Dump the inode allocation map in one cylinder group.
396 void
397 dbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr)
399 int j,k,l,e;
400 unsigned char *cp;
402 if(!dbg_log) {
403 return;
406 fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n");
407 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
408 indent++;
410 cp=(unsigned char *)cg_inosused(cgr);
411 e=sb->fs_ipg/8;
412 for(j=0; j<e; j+=32) {
413 fprintf(dbg_log, "%08x: ", j);
414 for(k=0; k<32; k+=8) {
415 if(j+k+8<e) {
416 fprintf(dbg_log,
417 "%02x%02x%02x%02x%02x%02x%02x%02x ",
418 cp[0], cp[1], cp[2], cp[3],
419 cp[4], cp[5], cp[6], cp[7]);
420 } else {
421 for(l=0; (l<8)&&(j+k+l<e); l++) {
422 fprintf(dbg_log, "%02x", cp[l]);
425 cp+=8;
427 fprintf(dbg_log, "\n");
430 indent--;
431 fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n");
433 return;
437 /* **************************************************** dbg_dump_frmap ***** */
439 * Dump the fragment allocation map in one cylinder group.
441 void
442 dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr)
444 int j,k,l,e;
445 unsigned char *cp;
447 if(!dbg_log) {
448 return;
451 fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n");
452 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
453 indent++;
455 cp=(unsigned char *)cg_blksfree(cgr);
456 e=howmany((sb->fs_cpg * sb->fs_spc / NSPF(sb)), NBBY);
457 for(j=0; j<e; j+=32) {
458 fprintf(dbg_log, "%08x: ", j);
459 for(k=0; k<32; k+=8) {
460 if(j+k+8<e) {
461 fprintf(dbg_log,
462 "%02x%02x%02x%02x%02x%02x%02x%02x ",
463 cp[0], cp[1], cp[2], cp[3],
464 cp[4], cp[5], cp[6], cp[7]);
465 } else {
466 for(l=0; (l<8)&&(j+k+l<e); l++) {
467 fprintf(dbg_log, "%02x", cp[l]);
470 cp+=8;
472 fprintf(dbg_log, "\n");
475 indent--;
476 fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n");
478 return;
481 /* **************************************************** dbg_dump_clmap ***** */
483 * Dump the cluster allocation map in one cylinder group.
485 void
486 dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr)
488 int j,k,l,e;
489 unsigned char *cp;
491 if(!dbg_log) {
492 return;
495 fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n");
496 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
497 indent++;
499 cp=(unsigned char *)cg_clustersfree(cgr);
500 e=howmany(sb->fs_cpg * sb->fs_spc / NSPB(sb), NBBY);
501 for(j=0; j<e; j+=32) {
502 fprintf(dbg_log, "%08x: ", j);
503 for(k=0; k<32; k+=8) {
504 if(j+k+8<e) {
505 fprintf(dbg_log,
506 "%02x%02x%02x%02x%02x%02x%02x%02x ",
507 cp[0], cp[1], cp[2], cp[3],
508 cp[4], cp[5], cp[6], cp[7]);
509 } else {
510 for(l=0; (l<8)&&(j+k+l<e); l++) {
511 fprintf(dbg_log, "%02x", cp[l]);
514 cp+=8;
516 fprintf(dbg_log, "\n");
519 indent--;
520 fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n");
522 return;
525 /* **************************************************** dbg_dump_clsum ***** */
527 * Dump the cluster availability summary of one cylinder group.
529 void
530 dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr)
532 int j;
533 int *ip;
535 if(!dbg_log) {
536 return;
539 fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n");
540 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
541 indent++;
543 ip=(int *)cg_clustersum(cgr);
544 for(j=0; j<=sb->fs_contigsumsize; j++) {
545 fprintf(dbg_log, "%02d: %8d\n", j, *ip++);
548 indent--;
549 fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n");
551 return;
554 /* **************************************************** dbg_dump_sptbl ***** */
556 * Dump the block summary, and the rotational layout table.
558 void
559 dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr)
561 int j,k;
562 int *ip;
564 if(!dbg_log) {
565 return;
568 fprintf(dbg_log,
569 "===== START BLOCK SUMMARY AND POSITION TABLE =====\n");
570 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
571 indent++;
573 ip=(int *)cg_blktot(cgr);
574 for(j=0; j<sb->fs_cpg; j++) {
575 fprintf(dbg_log, "%2d: %5d = ", j, *ip++);
576 for(k=0; k<sb->fs_nrpos; k++) {
577 fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]);
578 if(k<sb->fs_nrpos-1) {
579 fprintf(dbg_log, " + ");
582 fprintf(dbg_log, "\n");
585 indent--;
586 fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n");
588 return;
591 /* ****************************************************** dbg_dump_ino ***** */
593 * Dump an inode structure.
595 void
596 dbg_dump_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino)
598 int ictr;
599 int remaining_blocks;
601 if(!dbg_log) {
602 return;
605 fprintf(dbg_log, "===== START INODE DUMP =====\n");
606 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
607 indent++;
609 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode);
610 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink);
611 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n",
612 ((unsigned int *)&(ino->di_size))[1],
613 ((unsigned int *)&(ino->di_size))[0]);
614 fprintf(dbg_log, "atime int32_t 0x%08x\n", ino->di_atime);
615 fprintf(dbg_log, "atimensec int32_t 0x%08x\n",
616 ino->di_atimensec);
617 fprintf(dbg_log, "mtime int32_t 0x%08x\n",
618 ino->di_mtime);
619 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n",
620 ino->di_mtimensec);
621 fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime);
622 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n",
623 ino->di_ctimensec);
625 remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
626 for(ictr=0; ictr < MIN(UFS_NDADDR, remaining_blocks); ictr++) {
627 fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr,
628 ino->di_db[ictr]);
630 remaining_blocks-=UFS_NDADDR;
631 if(remaining_blocks>0) {
632 fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n",
633 ino->di_ib[0]);
635 remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs_daddr_t));
636 if(remaining_blocks>0) {
637 fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n",
638 ino->di_ib[1]);
640 #define SQUARE(a) ((a)*(a))
641 remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs_daddr_t)));
642 #undef SQUARE
643 if(remaining_blocks>0) {
644 fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n",
645 ino->di_ib[2]);
648 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
649 fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks);
650 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen);
651 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid);
652 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid);
654 indent--;
655 fprintf(dbg_log, "===== END INODE DUMP =====\n");
657 return;
660 /* ***************************************************** dbg_dump_iblk ***** */
662 * Dump an indirect block. The iteration to dump a full file has to be
663 * written around.
665 void
666 dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length)
668 unsigned int *mem;
669 int i, j;
671 if(!dbg_log) {
672 return;
675 fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n");
676 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block,
677 comment);
678 indent++;
680 mem=(unsigned int *)block;
681 for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, sizeof(ufs_daddr_t)),
682 length); i+=8) {
683 fprintf(dbg_log, "%04x: ", i);
684 for (j=0; j<8; j++) {
685 if((size_t)(i+j)<length) {
686 fprintf(dbg_log, "%08X ", *mem++);
689 fprintf(dbg_log, "\n");
692 indent--;
693 fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n");
695 return;
698 #endif /* FS_DEBUG */