debug.c (215704) | debug.c (232548) |
---|---|
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 * --- 27 unchanged lines hidden (view full) --- 36 * SUCH DAMAGE. 37 * 38 * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ 39 * 40 */ 41 42#ifndef lint 43static const char rcsid[] = | 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 * --- 27 unchanged lines hidden (view full) --- 36 * SUCH DAMAGE. 37 * 38 * $TSHeader: src/sbin/growfs/debug.c,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ 39 * 40 */ 41 42#ifndef lint 43static const char rcsid[] = |
44 "$FreeBSD: head/sbin/growfs/debug.c 215704 2010-11-22 20:10:48Z brucec $"; | 44 "$FreeBSD: head/sbin/growfs/debug.c 232548 2012-03-05 16:37:51Z trasz $"; |
45#endif /* not lint */ 46 | 45#endif /* not lint */ 46 |
47/* ********************************************************** INCLUDES ***** */ | |
48#include <sys/param.h> 49 50#include <limits.h> 51#include <stdio.h> 52#include <string.h> 53#include <ufs/ufs/dinode.h> 54#include <ufs/ffs/fs.h> 55 56#include "debug.h" 57 58#ifdef FS_DEBUG 59 | 47#include <sys/param.h> 48 49#include <limits.h> 50#include <stdio.h> 51#include <string.h> 52#include <ufs/ufs/dinode.h> 53#include <ufs/ffs/fs.h> 54 55#include "debug.h" 56 57#ifdef FS_DEBUG 58 |
60/* *********************************************************** GLOBALS ***** */ 61static FILE *dbg_log=NULL; 62static unsigned int indent=0; | 59static FILE *dbg_log = NULL; 60static unsigned int indent = 0; |
63 64/* 65 * prototypes not done here, as they come with debug.h 66 */ 67 | 61 62/* 63 * prototypes not done here, as they come with debug.h 64 */ 65 |
68/* ********************************************************** dbg_open ***** */ | |
69/* 70 * Open the filehandle where all debug output has to go. 71 */ 72void 73dbg_open(const char *fn) 74{ 75 76 if (strcmp(fn, "-") == 0) | 66/* 67 * Open the filehandle where all debug output has to go. 68 */ 69void 70dbg_open(const char *fn) 71{ 72 73 if (strcmp(fn, "-") == 0) |
77 dbg_log=fopen("/dev/stdout", "a"); | 74 dbg_log = fopen("/dev/stdout", "a"); |
78 else | 75 else |
79 dbg_log=fopen(fn, "a"); | 76 dbg_log = fopen(fn, "a"); |
80 81 return; 82} 83 | 77 78 return; 79} 80 |
84/* ********************************************************* dbg_close ***** */ | |
85/* 86 * Close the filehandle where all debug output went to. 87 */ 88void 89dbg_close(void) 90{ 91 | 81/* 82 * Close the filehandle where all debug output went to. 83 */ 84void 85dbg_close(void) 86{ 87 |
92 if(dbg_log) { | 88 if (dbg_log) { |
93 fclose(dbg_log); | 89 fclose(dbg_log); |
94 dbg_log=NULL; | 90 dbg_log = NULL; |
95 } 96 97 return; 98} 99 | 91 } 92 93 return; 94} 95 |
100/* ****************************************************** dbg_dump_hex ***** */ | |
101/* 102 * Dump out a full file system block in hex. 103 */ 104void 105dbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem) 106{ 107 int i, j, k; 108 | 96/* 97 * Dump out a full file system block in hex. 98 */ 99void 100dbg_dump_hex(struct fs *sb, const char *comment, unsigned char *mem) 101{ 102 int i, j, k; 103 |
109 if(!dbg_log) { | 104 if (!dbg_log) |
110 return; | 105 return; |
111 } | 106 |
112 fprintf(dbg_log, "===== START HEXDUMP =====\n"); 113 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment); 114 indent++; | 107 fprintf(dbg_log, "===== START HEXDUMP =====\n"); 108 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment); 109 indent++; |
115 for (i=0; i<sb->fs_bsize; i+=24) { 116 for (j=0; j<3; j++) { 117 for (k=0; k<8; k++) { | 110 for (i = 0; i < sb->fs_bsize; i += 24) { 111 for (j = 0; j < 3; j++) { 112 for (k = 0; k < 8; k++) |
118 fprintf(dbg_log, "%02x ", *mem++); | 113 fprintf(dbg_log, "%02x ", *mem++); |
119 } | |
120 fprintf(dbg_log, " "); 121 } 122 fprintf(dbg_log, "\n"); 123 } 124 indent--; 125 fprintf(dbg_log, "===== END HEXDUMP =====\n"); 126 127 return; 128} 129 | 114 fprintf(dbg_log, " "); 115 } 116 fprintf(dbg_log, "\n"); 117 } 118 indent--; 119 fprintf(dbg_log, "===== END HEXDUMP =====\n"); 120 121 return; 122} 123 |
130/* ******************************************************* dbg_dump_fs ***** */ | |
131/* 132 * Dump the superblock. 133 */ 134void 135dbg_dump_fs(struct fs *sb, const char *comment) 136{ 137#ifdef FSMAXSNAP | 124/* 125 * Dump the superblock. 126 */ 127void 128dbg_dump_fs(struct fs *sb, const char *comment) 129{ 130#ifdef FSMAXSNAP |
138 int j; | 131 int j; |
139#endif /* FSMAXSNAP */ 140 | 132#endif /* FSMAXSNAP */ 133 |
141 if(!dbg_log) { | 134 if (!dbg_log) |
142 return; | 135 return; |
143 } | |
144 145 fprintf(dbg_log, "===== START SUPERBLOCK =====\n"); 146 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment); 147 indent++; 148 149 fprintf(dbg_log, "sblkno int32_t 0x%08x\n", 150 sb->fs_sblkno); 151 fprintf(dbg_log, "cblkno int32_t 0x%08x\n", --- 151 unchanged lines hidden (view full) --- 303 ((unsigned int *)&(sb->fs_csaddr))[0]); 304 fprintf(dbg_log, "pendingblocks int64_t 0x%08x%08x\n", 305 ((unsigned int *)&(sb->fs_pendingblocks))[1], 306 ((unsigned int *)&(sb->fs_pendingblocks))[0]); 307 fprintf(dbg_log, "pendinginodes int32_t 0x%08x\n", 308 sb->fs_pendinginodes); 309 310#ifdef FSMAXSNAP | 136 137 fprintf(dbg_log, "===== START SUPERBLOCK =====\n"); 138 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment); 139 indent++; 140 141 fprintf(dbg_log, "sblkno int32_t 0x%08x\n", 142 sb->fs_sblkno); 143 fprintf(dbg_log, "cblkno int32_t 0x%08x\n", --- 151 unchanged lines hidden (view full) --- 295 ((unsigned int *)&(sb->fs_csaddr))[0]); 296 fprintf(dbg_log, "pendingblocks int64_t 0x%08x%08x\n", 297 ((unsigned int *)&(sb->fs_pendingblocks))[1], 298 ((unsigned int *)&(sb->fs_pendingblocks))[0]); 299 fprintf(dbg_log, "pendinginodes int32_t 0x%08x\n", 300 sb->fs_pendinginodes); 301 302#ifdef FSMAXSNAP |
311 for(j=0; j<FSMAXSNAP; j++) { | 303 for (j = 0; j < FSMAXSNAP; j++) { |
312 fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n", 313 j, sb->fs_snapinum[j]); | 304 fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n", 305 j, sb->fs_snapinum[j]); |
314 if(!sb->fs_snapinum[j]) { /* list is dense */ | 306 if (!sb->fs_snapinum[j]) { /* list is dense */ |
315 break; 316 } 317 } 318#endif /* FSMAXSNAP */ 319 fprintf(dbg_log, "avgfilesize int32_t 0x%08x\n", 320 sb->fs_avgfilesize); 321 fprintf(dbg_log, "avgfpdir int32_t 0x%08x\n", 322 sb->fs_avgfpdir); --- 28 unchanged lines hidden (view full) --- 351 sb->fs_magic); 352 353 indent--; 354 fprintf(dbg_log, "===== END SUPERBLOCK =====\n"); 355 356 return; 357} 358 | 307 break; 308 } 309 } 310#endif /* FSMAXSNAP */ 311 fprintf(dbg_log, "avgfilesize int32_t 0x%08x\n", 312 sb->fs_avgfilesize); 313 fprintf(dbg_log, "avgfpdir int32_t 0x%08x\n", 314 sb->fs_avgfpdir); --- 28 unchanged lines hidden (view full) --- 343 sb->fs_magic); 344 345 indent--; 346 fprintf(dbg_log, "===== END SUPERBLOCK =====\n"); 347 348 return; 349} 350 |
359/* ******************************************************* dbg_dump_cg ***** */ | |
360/* 361 * Dump a cylinder group. 362 */ 363void 364dbg_dump_cg(const char *comment, struct cg *cgr) 365{ 366 int j; 367 | 351/* 352 * Dump a cylinder group. 353 */ 354void 355dbg_dump_cg(const char *comment, struct cg *cgr) 356{ 357 int j; 358 |
368 if(!dbg_log) { | 359 if (!dbg_log) |
369 return; | 360 return; |
370 } | |
371 372 fprintf(dbg_log, "===== START CYLINDER GROUP =====\n"); 373 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 374 indent++; 375 376 fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic); 377 fprintf(dbg_log, "old_time int32_t 0x%08x\n", cgr->cg_old_time); 378 fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx); 379 fprintf(dbg_log, "old_ncyl int16_t 0x%04x\n", cgr->cg_old_ncyl); 380 fprintf(dbg_log, "old_niblk int16_t 0x%04x\n", cgr->cg_old_niblk); 381 fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk); 382 dbg_dump_csum("internal cs", &cgr->cg_cs); 383 fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor); 384 fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor); 385 fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor); | 361 362 fprintf(dbg_log, "===== START CYLINDER GROUP =====\n"); 363 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 364 indent++; 365 366 fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic); 367 fprintf(dbg_log, "old_time int32_t 0x%08x\n", cgr->cg_old_time); 368 fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx); 369 fprintf(dbg_log, "old_ncyl int16_t 0x%04x\n", cgr->cg_old_ncyl); 370 fprintf(dbg_log, "old_niblk int16_t 0x%04x\n", cgr->cg_old_niblk); 371 fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk); 372 dbg_dump_csum("internal cs", &cgr->cg_cs); 373 fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor); 374 fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor); 375 fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor); |
386 for(j=0; j<MAXFRAG; j++) { | 376 for (j = 0; j < MAXFRAG; j++) { |
387 fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j, 388 cgr->cg_frsum[j]); 389 } 390 fprintf(dbg_log, "old_btotoff int32_t 0x%08x\n", cgr->cg_old_btotoff); 391 fprintf(dbg_log, "old_boff int32_t 0x%08x\n", cgr->cg_old_boff); 392 fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff); 393 fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff); 394 fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n", --- 11 unchanged lines hidden (view full) --- 406 (unsigned int)cgr->cg_initediblk); 407 408 indent--; 409 fprintf(dbg_log, "===== END CYLINDER GROUP =====\n"); 410 411 return; 412} 413 | 377 fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j, 378 cgr->cg_frsum[j]); 379 } 380 fprintf(dbg_log, "old_btotoff int32_t 0x%08x\n", cgr->cg_old_btotoff); 381 fprintf(dbg_log, "old_boff int32_t 0x%08x\n", cgr->cg_old_boff); 382 fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff); 383 fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff); 384 fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n", --- 11 unchanged lines hidden (view full) --- 396 (unsigned int)cgr->cg_initediblk); 397 398 indent--; 399 fprintf(dbg_log, "===== END CYLINDER GROUP =====\n"); 400 401 return; 402} 403 |
414/* ***************************************************** dbg_dump_csum ***** */ | |
415/* 416 * Dump a cylinder summary. 417 */ 418void 419dbg_dump_csum(const char *comment, struct csum *cs) 420{ 421 | 404/* 405 * Dump a cylinder summary. 406 */ 407void 408dbg_dump_csum(const char *comment, struct csum *cs) 409{ 410 |
422 if(!dbg_log) { | 411 if (!dbg_log) |
423 return; | 412 return; |
424 } | |
425 426 fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n"); 427 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 428 indent++; 429 430 fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir); 431 fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree); 432 fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree); 433 fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree); 434 435 indent--; 436 fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n"); 437 438 return; 439} 440 | 413 414 fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n"); 415 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 416 indent++; 417 418 fprintf(dbg_log, "ndir int32_t 0x%08x\n", cs->cs_ndir); 419 fprintf(dbg_log, "nbfree int32_t 0x%08x\n", cs->cs_nbfree); 420 fprintf(dbg_log, "nifree int32_t 0x%08x\n", cs->cs_nifree); 421 fprintf(dbg_log, "nffree int32_t 0x%08x\n", cs->cs_nffree); 422 423 indent--; 424 fprintf(dbg_log, "===== END CYLINDER SUMMARY =====\n"); 425 426 return; 427} 428 |
441/* ************************************************ dbg_dump_csum_total ***** */ | |
442/* 443 * Dump a cylinder summary. 444 */ 445void 446dbg_dump_csum_total(const char *comment, struct csum_total *cs) 447{ 448 | 429/* 430 * Dump a cylinder summary. 431 */ 432void 433dbg_dump_csum_total(const char *comment, struct csum_total *cs) 434{ 435 |
449 if(!dbg_log) { | 436 if (!dbg_log) |
450 return; | 437 return; |
451 } | |
452 453 fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n"); 454 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 455 indent++; 456 457 fprintf(dbg_log, "ndir int64_t 0x%08x%08x\n", 458 ((unsigned int *)&(cs->cs_ndir))[1], 459 ((unsigned int *)&(cs->cs_ndir))[0]); --- 10 unchanged lines hidden (view full) --- 470 ((unsigned int *)&(cs->cs_numclusters))[1], 471 ((unsigned int *)&(cs->cs_numclusters))[0]); 472 473 indent--; 474 fprintf(dbg_log, "===== END CYLINDER SUMMARY TOTAL =====\n"); 475 476 return; 477} | 438 439 fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n"); 440 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment); 441 indent++; 442 443 fprintf(dbg_log, "ndir int64_t 0x%08x%08x\n", 444 ((unsigned int *)&(cs->cs_ndir))[1], 445 ((unsigned int *)&(cs->cs_ndir))[0]); --- 10 unchanged lines hidden (view full) --- 456 ((unsigned int *)&(cs->cs_numclusters))[1], 457 ((unsigned int *)&(cs->cs_numclusters))[0]); 458 459 indent--; 460 fprintf(dbg_log, "===== END CYLINDER SUMMARY TOTAL =====\n"); 461 462 return; 463} |
478/* **************************************************** dbg_dump_inmap ***** */ | |
479/* 480 * Dump the inode allocation map in one cylinder group. 481 */ 482void 483dbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr) 484{ 485 int j,k,l,e; 486 unsigned char *cp; 487 | 464/* 465 * Dump the inode allocation map in one cylinder group. 466 */ 467void 468dbg_dump_inmap(struct fs *sb, const char *comment, struct cg *cgr) 469{ 470 int j,k,l,e; 471 unsigned char *cp; 472 |
488 if(!dbg_log) { | 473 if (!dbg_log) |
489 return; | 474 return; |
490 } | |
491 492 fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n"); 493 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 494 indent++; 495 | 475 476 fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n"); 477 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 478 indent++; 479 |
496 cp=(unsigned char *)cg_inosused(cgr); 497 e=sb->fs_ipg/8; 498 for(j=0; j<e; j+=32) { | 480 cp = (unsigned char *)cg_inosused(cgr); 481 e = sb->fs_ipg / 8; 482 for (j = 0; j < e; j += 32) { |
499 fprintf(dbg_log, "%08x: ", j); | 483 fprintf(dbg_log, "%08x: ", j); |
500 for(k=0; k<32; k+=8) { 501 if(j+k+8<e) { | 484 for (k = 0; k < 32; k += 8) { 485 if (j + k + 8 < e) { |
502 fprintf(dbg_log, 503 "%02x%02x%02x%02x%02x%02x%02x%02x ", 504 cp[0], cp[1], cp[2], cp[3], 505 cp[4], cp[5], cp[6], cp[7]); 506 } else { | 486 fprintf(dbg_log, 487 "%02x%02x%02x%02x%02x%02x%02x%02x ", 488 cp[0], cp[1], cp[2], cp[3], 489 cp[4], cp[5], cp[6], cp[7]); 490 } else { |
507 for(l=0; (l<8)&&(j+k+l<e); l++) { | 491 for (l = 0; (l < 8) && (j + k + l < e); l++) { |
508 fprintf(dbg_log, "%02x", cp[l]); 509 } 510 } | 492 fprintf(dbg_log, "%02x", cp[l]); 493 } 494 } |
511 cp+=8; | 495 cp += 8; |
512 } 513 fprintf(dbg_log, "\n"); 514 } 515 516 indent--; 517 fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n"); 518 519 return; 520} 521 522 | 496 } 497 fprintf(dbg_log, "\n"); 498 } 499 500 indent--; 501 fprintf(dbg_log, "===== END INODE ALLOCATION MAP =====\n"); 502 503 return; 504} 505 506 |
523/* **************************************************** dbg_dump_frmap ***** */ | |
524/* 525 * Dump the fragment allocation map in one cylinder group. 526 */ 527void 528dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr) 529{ 530 int j,k,l,e; 531 unsigned char *cp; 532 | 507/* 508 * Dump the fragment allocation map in one cylinder group. 509 */ 510void 511dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr) 512{ 513 int j,k,l,e; 514 unsigned char *cp; 515 |
533 if(!dbg_log) { | 516 if (!dbg_log) |
534 return; | 517 return; |
535 } | |
536 537 fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n"); 538 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 539 indent++; 540 | 518 519 fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n"); 520 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 521 indent++; 522 |
541 cp=(unsigned char *)cg_blksfree(cgr); | 523 cp = (unsigned char *)cg_blksfree(cgr); |
542 if (sb->fs_old_nspf) | 524 if (sb->fs_old_nspf) |
543 e=howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT); | 525 e = howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT); |
544 else 545 e = 0; | 526 else 527 e = 0; |
546 for(j=0; j<e; j+=32) { | 528 for (j = 0; j < e; j += 32) { |
547 fprintf(dbg_log, "%08x: ", j); | 529 fprintf(dbg_log, "%08x: ", j); |
548 for(k=0; k<32; k+=8) { 549 if(j+k+8<e) { | 530 for (k = 0; k < 32; k += 8) { 531 if (j + k + 8 <e) { |
550 fprintf(dbg_log, 551 "%02x%02x%02x%02x%02x%02x%02x%02x ", 552 cp[0], cp[1], cp[2], cp[3], 553 cp[4], cp[5], cp[6], cp[7]); 554 } else { | 532 fprintf(dbg_log, 533 "%02x%02x%02x%02x%02x%02x%02x%02x ", 534 cp[0], cp[1], cp[2], cp[3], 535 cp[4], cp[5], cp[6], cp[7]); 536 } else { |
555 for(l=0; (l<8)&&(j+k+l<e); l++) { | 537 for (l = 0; (l < 8) && (j + k + l < e); l++) { |
556 fprintf(dbg_log, "%02x", cp[l]); 557 } 558 } | 538 fprintf(dbg_log, "%02x", cp[l]); 539 } 540 } |
559 cp+=8; | 541 cp += 8; |
560 } 561 fprintf(dbg_log, "\n"); 562 } 563 564 indent--; 565 fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n"); 566 567 return; 568} 569 | 542 } 543 fprintf(dbg_log, "\n"); 544 } 545 546 indent--; 547 fprintf(dbg_log, "===== END FRAGMENT ALLOCATION MAP =====\n"); 548 549 return; 550} 551 |
570/* **************************************************** dbg_dump_clmap ***** */ | |
571/* 572 * Dump the cluster allocation map in one cylinder group. 573 */ 574void 575dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr) 576{ 577 int j,k,l,e; 578 unsigned char *cp; 579 | 552/* 553 * Dump the cluster allocation map in one cylinder group. 554 */ 555void 556dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr) 557{ 558 int j,k,l,e; 559 unsigned char *cp; 560 |
580 if(!dbg_log) { | 561 if (!dbg_log) |
581 return; | 562 return; |
582 } | |
583 584 fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n"); 585 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 586 indent++; 587 | 563 564 fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n"); 565 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 566 indent++; 567 |
588 cp=(unsigned char *)cg_clustersfree(cgr); | 568 cp = (unsigned char *)cg_clustersfree(cgr); |
589 if (sb->fs_old_nspf) | 569 if (sb->fs_old_nspf) |
590 e=howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT); | 570 e = howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT); |
591 else 592 e = 0; | 571 else 572 e = 0; |
593 for(j=0; j<e; j+=32) { | 573 for (j = 0; j < e; j += 32) { |
594 fprintf(dbg_log, "%08x: ", j); | 574 fprintf(dbg_log, "%08x: ", j); |
595 for(k=0; k<32; k+=8) { 596 if(j+k+8<e) { | 575 for (k = 0; k < 32; k += 8) { 576 if (j + k + 8 < e) { |
597 fprintf(dbg_log, 598 "%02x%02x%02x%02x%02x%02x%02x%02x ", 599 cp[0], cp[1], cp[2], cp[3], 600 cp[4], cp[5], cp[6], cp[7]); 601 } else { | 577 fprintf(dbg_log, 578 "%02x%02x%02x%02x%02x%02x%02x%02x ", 579 cp[0], cp[1], cp[2], cp[3], 580 cp[4], cp[5], cp[6], cp[7]); 581 } else { |
602 for(l=0; (l<8)&&(j+k+l<e); l++) { | 582 for (l = 0; (l < 8) && (j + k + l <e); l++) { |
603 fprintf(dbg_log, "%02x", cp[l]); 604 } 605 } | 583 fprintf(dbg_log, "%02x", cp[l]); 584 } 585 } |
606 cp+=8; | 586 cp += 8; |
607 } 608 fprintf(dbg_log, "\n"); 609 } 610 611 indent--; 612 fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n"); 613 614 return; 615} 616 | 587 } 588 fprintf(dbg_log, "\n"); 589 } 590 591 indent--; 592 fprintf(dbg_log, "===== END CLUSTER ALLOCATION MAP =====\n"); 593 594 return; 595} 596 |
617/* **************************************************** dbg_dump_clsum ***** */ | |
618/* 619 * Dump the cluster availability summary of one cylinder group. 620 */ 621void 622dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr) 623{ 624 int j; 625 int *ip; 626 | 597/* 598 * Dump the cluster availability summary of one cylinder group. 599 */ 600void 601dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr) 602{ 603 int j; 604 int *ip; 605 |
627 if(!dbg_log) { | 606 if (!dbg_log) |
628 return; | 607 return; |
629 } | |
630 631 fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n"); 632 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 633 indent++; 634 | 608 609 fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n"); 610 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 611 indent++; 612 |
635 ip=(int *)cg_clustersum(cgr); 636 for(j=0; j<=sb->fs_contigsumsize; j++) { | 613 ip = (int *)cg_clustersum(cgr); 614 for (j = 0; j <= sb->fs_contigsumsize; j++) { |
637 fprintf(dbg_log, "%02d: %8d\n", j, *ip++); 638 } 639 640 indent--; 641 fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n"); 642 643 return; 644} 645 646#ifdef NOT_CURRENTLY 647/* 648 * This code dates from before the UFS2 integration, and doesn't compile 649 * post-UFS2 due to the use of cg_blks(). I'm not sure how best to update 650 * this for UFS2, where the rotational bits of UFS no longer apply, so 651 * will leave it disabled for now; it should probably be re-enabled 652 * specifically for UFS1. 653 */ | 615 fprintf(dbg_log, "%02d: %8d\n", j, *ip++); 616 } 617 618 indent--; 619 fprintf(dbg_log, "===== END CLUSTER SUMMARY =====\n"); 620 621 return; 622} 623 624#ifdef NOT_CURRENTLY 625/* 626 * This code dates from before the UFS2 integration, and doesn't compile 627 * post-UFS2 due to the use of cg_blks(). I'm not sure how best to update 628 * this for UFS2, where the rotational bits of UFS no longer apply, so 629 * will leave it disabled for now; it should probably be re-enabled 630 * specifically for UFS1. 631 */ |
654/* **************************************************** dbg_dump_sptbl ***** */ | |
655/* 656 * Dump the block summary, and the rotational layout table. 657 */ 658void 659dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr) 660{ 661 int j,k; 662 int *ip; 663 | 632/* 633 * Dump the block summary, and the rotational layout table. 634 */ 635void 636dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr) 637{ 638 int j,k; 639 int *ip; 640 |
664 if(!dbg_log) { | 641 if (!dbg_log) |
665 return; | 642 return; |
666 } | |
667 668 fprintf(dbg_log, 669 "===== START BLOCK SUMMARY AND POSITION TABLE =====\n"); 670 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 671 indent++; 672 | 643 644 fprintf(dbg_log, 645 "===== START BLOCK SUMMARY AND POSITION TABLE =====\n"); 646 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment); 647 indent++; 648 |
673 ip=(int *)cg_blktot(cgr); 674 for(j=0; j<sb->fs_old_cpg; j++) { | 649 ip = (int *)cg_blktot(cgr); 650 for (j = 0; j < sb->fs_old_cpg; j++) { |
675 fprintf(dbg_log, "%2d: %5d = ", j, *ip++); | 651 fprintf(dbg_log, "%2d: %5d = ", j, *ip++); |
676 for(k=0; k<sb->fs_old_nrpos; k++) { | 652 for (k = 0; k < sb->fs_old_nrpos; k++) { |
677 fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]); | 653 fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]); |
678 if(k<sb->fs_old_nrpos-1) { | 654 if (k < sb->fs_old_nrpos - 1) |
679 fprintf(dbg_log, " + "); | 655 fprintf(dbg_log, " + "); |
680 } | |
681 } 682 fprintf(dbg_log, "\n"); 683 } 684 685 indent--; 686 fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n"); 687 688 return; 689} 690#endif 691 | 656 } 657 fprintf(dbg_log, "\n"); 658 } 659 660 indent--; 661 fprintf(dbg_log, "===== END BLOCK SUMMARY AND POSITION TABLE =====\n"); 662 663 return; 664} 665#endif 666 |
692/* ************************************************** dbg_dump_ufs1_ino ***** */ | |
693/* 694 * Dump a UFS1 inode structure. 695 */ 696void 697dbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino) 698{ 699 int ictr; 700 int remaining_blocks; 701 | 667/* 668 * Dump a UFS1 inode structure. 669 */ 670void 671dbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino) 672{ 673 int ictr; 674 int remaining_blocks; 675 |
702 if(!dbg_log) { | 676 if (!dbg_log) |
703 return; | 677 return; |
704 } | |
705 706 fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n"); 707 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 708 indent++; 709 710 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 711 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 712 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", --- 5 unchanged lines hidden (view full) --- 718 fprintf(dbg_log, "mtime int32_t 0x%08x\n", 719 ino->di_mtime); 720 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", 721 ino->di_mtimensec); 722 fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime); 723 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", 724 ino->di_ctimensec); 725 | 678 679 fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n"); 680 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 681 indent++; 682 683 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 684 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 685 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", --- 5 unchanged lines hidden (view full) --- 691 fprintf(dbg_log, "mtime int32_t 0x%08x\n", 692 ino->di_mtime); 693 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", 694 ino->di_mtimensec); 695 fprintf(dbg_log, "ctime int32_t 0x%08x\n", ino->di_ctime); 696 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", 697 ino->di_ctimensec); 698 |
726 remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 727 for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { | 699 remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 700 for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { |
728 fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr, 729 ino->di_db[ictr]); 730 } | 701 fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr, 702 ino->di_db[ictr]); 703 } |
731 remaining_blocks-=NDADDR; 732 if(remaining_blocks>0) { | 704 remaining_blocks -= NDADDR; 705 if (remaining_blocks > 0) { |
733 fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n", 734 ino->di_ib[0]); 735 } | 706 fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n", 707 ino->di_ib[0]); 708 } |
736 remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)); 737 if(remaining_blocks>0) { | 709 remaining_blocks -= howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)); 710 if (remaining_blocks > 0) { |
738 fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n", 739 ino->di_ib[1]); 740 } | 711 fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n", 712 ino->di_ib[1]); 713 } |
741#define SQUARE(a) ((a)*(a)) 742 remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t))); | 714#define SQUARE(a) ((a) * (a)) 715 remaining_blocks -= SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t))); |
743#undef SQUARE | 716#undef SQUARE |
744 if(remaining_blocks>0) { | 717 if (remaining_blocks > 0) { |
745 fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n", 746 ino->di_ib[2]); 747 } 748 749 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 750 fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks); 751 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 752 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 753 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 754 755 indent--; 756 fprintf(dbg_log, "===== END UFS1 INODE DUMP =====\n"); 757 758 return; 759} 760 | 718 fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n", 719 ino->di_ib[2]); 720 } 721 722 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 723 fprintf(dbg_log, "blocks int32_t 0x%08x\n", ino->di_blocks); 724 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 725 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 726 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 727 728 indent--; 729 fprintf(dbg_log, "===== END UFS1 INODE DUMP =====\n"); 730 731 return; 732} 733 |
761/* ************************************************** dbg_dump_ufs2_ino ***** */ | |
762/* 763 * Dump a UFS2 inode structure. 764 */ 765void 766dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino) 767{ 768 int ictr; 769 int remaining_blocks; 770 | 734/* 735 * Dump a UFS2 inode structure. 736 */ 737void 738dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino) 739{ 740 int ictr; 741 int remaining_blocks; 742 |
771 if(!dbg_log) { | 743 if (!dbg_log) |
772 return; | 744 return; |
773 } | |
774 775 fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n"); 776 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 777 indent++; 778 779 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 780 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 781 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 782 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 783 fprintf(dbg_log, "blksize u_int32_t 0x%08x\n", ino->di_blksize); 784 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", 785 ((unsigned int *)&(ino->di_size))[1], 786 ((unsigned int *)&(ino->di_size))[0]); 787 fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n", | 745 746 fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n"); 747 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment); 748 indent++; 749 750 fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode); 751 fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink); 752 fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid); 753 fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid); 754 fprintf(dbg_log, "blksize u_int32_t 0x%08x\n", ino->di_blksize); 755 fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n", 756 ((unsigned int *)&(ino->di_size))[1], 757 ((unsigned int *)&(ino->di_size))[0]); 758 fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n", |
788 ((unsigned int *)&(ino->di_blocks))[1], 789 ((unsigned int *)&(ino->di_blocks))[0]); | 759 ((unsigned int *)&(ino->di_blocks))[1], 760 ((unsigned int *)&(ino->di_blocks))[0]); |
790 fprintf(dbg_log, "atime ufs_time_t %10jd\n", ino->di_atime); 791 fprintf(dbg_log, "mtime ufs_time_t %10jd\n", ino->di_mtime); 792 fprintf(dbg_log, "ctime ufs_time_t %10jd\n", ino->di_ctime); 793 fprintf(dbg_log, "birthtime ufs_time_t %10jd\n", ino->di_birthtime); 794 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", ino->di_mtimensec); 795 fprintf(dbg_log, "atimensec int32_t 0x%08x\n", ino->di_atimensec); 796 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", ino->di_ctimensec); 797 fprintf(dbg_log, "birthnsec int32_t 0x%08x\n", ino->di_birthnsec); 798 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 799 fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags); 800 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 801 fprintf(dbg_log, "extsize int32_t 0x%08x\n", ino->di_extsize); 802 803 /* XXX: What do we do with di_extb[NXADDR]? */ 804 | 761 fprintf(dbg_log, "atime ufs_time_t %10jd\n", ino->di_atime); 762 fprintf(dbg_log, "mtime ufs_time_t %10jd\n", ino->di_mtime); 763 fprintf(dbg_log, "ctime ufs_time_t %10jd\n", ino->di_ctime); 764 fprintf(dbg_log, "birthtime ufs_time_t %10jd\n", ino->di_birthtime); 765 fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", ino->di_mtimensec); 766 fprintf(dbg_log, "atimensec int32_t 0x%08x\n", ino->di_atimensec); 767 fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", ino->di_ctimensec); 768 fprintf(dbg_log, "birthnsec int32_t 0x%08x\n", ino->di_birthnsec); 769 fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen); 770 fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags); 771 fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags); 772 fprintf(dbg_log, "extsize int32_t 0x%08x\n", ino->di_extsize); 773 774 /* XXX: What do we do with di_extb[NXADDR]? */ 775 |
805 remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 806 for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { | 776 remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ 777 for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { |
807 fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr, 808 ino->di_db[ictr]); 809 } | 778 fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr, 779 ino->di_db[ictr]); 780 } |
810 remaining_blocks-=NDADDR; 811 if(remaining_blocks>0) { | 781 remaining_blocks -= NDADDR; 782 if (remaining_blocks > 0) { |
812 fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n", 813 ino->di_ib[0]); 814 } | 783 fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n", 784 ino->di_ib[0]); 785 } |
815 remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)); 816 if(remaining_blocks>0) { | 786 remaining_blocks -= howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)); 787 if (remaining_blocks > 0) { |
817 fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16jx\n", 818 ino->di_ib[1]); 819 } | 788 fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16jx\n", 789 ino->di_ib[1]); 790 } |
820#define SQUARE(a) ((a)*(a)) 821 remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t))); | 791#define SQUARE(a) ((a) * (a)) 792 remaining_blocks -= SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t))); |
822#undef SQUARE | 793#undef SQUARE |
823 if(remaining_blocks>0) { | 794 if (remaining_blocks > 0) { |
824 fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16jx\n", 825 ino->di_ib[2]); 826 } 827 828 indent--; 829 fprintf(dbg_log, "===== END UFS2 INODE DUMP =====\n"); 830 831 return; 832} 833 | 795 fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16jx\n", 796 ino->di_ib[2]); 797 } 798 799 indent--; 800 fprintf(dbg_log, "===== END UFS2 INODE DUMP =====\n"); 801 802 return; 803} 804 |
834/* ***************************************************** dbg_dump_iblk ***** */ | |
835/* 836 * Dump an indirect block. The iteration to dump a full file has to be 837 * written around. 838 */ 839void 840dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length) 841{ 842 unsigned int *mem, i, j, size; 843 | 805/* 806 * Dump an indirect block. The iteration to dump a full file has to be 807 * written around. 808 */ 809void 810dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length) 811{ 812 unsigned int *mem, i, j, size; 813 |
844 if(!dbg_log) { | 814 if (!dbg_log) |
845 return; | 815 return; |
846 } | |
847 848 fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n"); 849 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block, 850 comment); 851 indent++; 852 853 if (sb->fs_magic == FS_UFS1_MAGIC) 854 size = sizeof(ufs1_daddr_t); 855 else 856 size = sizeof(ufs2_daddr_t); 857 | 816 817 fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n"); 818 fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block, 819 comment); 820 indent++; 821 822 if (sb->fs_magic == FS_UFS1_MAGIC) 823 size = sizeof(ufs1_daddr_t); 824 else 825 size = sizeof(ufs2_daddr_t); 826 |
858 mem=(unsigned int *)block; 859 for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, size), 860 length); i+=8) { | 827 mem = (unsigned int *)block; 828 for (i = 0; (size_t)i < MIN(howmany(sb->fs_bsize, size), length); 829 i += 8) { |
861 fprintf(dbg_log, "%04x: ", i); | 830 fprintf(dbg_log, "%04x: ", i); |
862 for (j=0; j<8; j++) { 863 if((size_t)(i+j)<length) { | 831 for (j = 0; j < 8; j++) { 832 if ((size_t)(i + j) < length) |
864 fprintf(dbg_log, "%08X ", *mem++); | 833 fprintf(dbg_log, "%08X ", *mem++); |
865 } | |
866 } 867 fprintf(dbg_log, "\n"); 868 } 869 870 indent--; 871 fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n"); 872 873 return; 874} 875 876#endif /* FS_DEBUG */ 877 | 834 } 835 fprintf(dbg_log, "\n"); 836 } 837 838 indent--; 839 fprintf(dbg_log, "===== END INDIRECT BLOCK DUMP =====\n"); 840 841 return; 842} 843 844#endif /* FS_DEBUG */ 845 |