Commit 1 of 2 to fix ffsinfo(8) for UFS2.

Add support for UFS2 to the UFS debugging routines in growfs; required
to update ffsinfo(8) for UFS2.  A variety of types and fs variables are
renamed to reflect UFS1/2 structures.  Also, the print routines for
inodes are now split into separate UFS1 and UFS2 versions.  We now
define dbg_dump_csum_total(), but lose the printing of rotational
information since that's not present in UFS2.  In the future, we may
want to re-add this functionality to print it solely for UFS1.

Submitted by:	Lukas Ertl <l.ertl@univie.ac.at>
PR:		bin/53517
This commit is contained in:
Robert Watson 2003-08-14 18:40:59 +00:00
parent 92bdf888a6
commit 0b22953b4c
2 changed files with 292 additions and 115 deletions

View File

@ -145,168 +145,206 @@ dbg_dump_fs(struct fs *sb, const char *comment)
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment);
indent++;
fprintf(dbg_log, "sblkno ufs_daddr_t 0x%08x\n",
fprintf(dbg_log, "sblkno int32_t 0x%08x\n",
sb->fs_sblkno);
fprintf(dbg_log, "cblkno ufs_daddr_t 0x%08x\n",
fprintf(dbg_log, "cblkno int32_t 0x%08x\n",
sb->fs_cblkno);
fprintf(dbg_log, "iblkno ufs_daddr_t 0x%08x\n",
fprintf(dbg_log, "iblkno int32_t 0x%08x\n",
sb->fs_iblkno);
fprintf(dbg_log, "dblkno ufs_daddr_t 0x%08x\n",
fprintf(dbg_log, "dblkno int32_t 0x%08x\n",
sb->fs_dblkno);
fprintf(dbg_log, "cgoffset int32_t 0x%08x\n",
sb->fs_cgoffset);
fprintf(dbg_log, "cgmask int32_t 0x%08x\n",
sb->fs_cgmask);
fprintf(dbg_log, "time time_t %10u\n",
(unsigned int)sb->fs_time);
fprintf(dbg_log, "size int32_t 0x%08x\n",
sb->fs_size);
fprintf(dbg_log, "dsize int32_t 0x%08x\n",
sb->fs_dsize);
fprintf(dbg_log, "ncg int32_t 0x%08x\n",
fprintf(dbg_log, "old_cgoffset int32_t 0x%08x\n",
sb->fs_old_cgoffset);
fprintf(dbg_log, "old_cgmask int32_t 0x%08x\n",
sb->fs_old_cgmask);
fprintf(dbg_log, "old_time int32_t %10u\n",
(unsigned int)sb->fs_old_time);
fprintf(dbg_log, "old_size int32_t 0x%08x\n",
sb->fs_old_size);
fprintf(dbg_log, "old_dsize int32_t 0x%08x\n",
sb->fs_old_dsize);
fprintf(dbg_log, "ncg int32_t 0x%08x\n",
sb->fs_ncg);
fprintf(dbg_log, "bsize int32_t 0x%08x\n",
fprintf(dbg_log, "bsize int32_t 0x%08x\n",
sb->fs_bsize);
fprintf(dbg_log, "fsize int32_t 0x%08x\n",
fprintf(dbg_log, "fsize int32_t 0x%08x\n",
sb->fs_fsize);
fprintf(dbg_log, "frag int32_t 0x%08x\n",
fprintf(dbg_log, "frag int32_t 0x%08x\n",
sb->fs_frag);
fprintf(dbg_log, "minfree int32_t 0x%08x\n",
fprintf(dbg_log, "minfree int32_t 0x%08x\n",
sb->fs_minfree);
fprintf(dbg_log, "rotdelay int32_t 0x%08x\n",
sb->fs_rotdelay);
fprintf(dbg_log, "rps int32_t 0x%08x\n",
sb->fs_rps);
fprintf(dbg_log, "old_rotdelay int32_t 0x%08x\n",
sb->fs_old_rotdelay);
fprintf(dbg_log, "old_rps int32_t 0x%08x\n",
sb->fs_old_rps);
fprintf(dbg_log, "bmask int32_t 0x%08x\n",
fprintf(dbg_log, "bmask int32_t 0x%08x\n",
sb->fs_bmask);
fprintf(dbg_log, "fmask int32_t 0x%08x\n",
fprintf(dbg_log, "fmask int32_t 0x%08x\n",
sb->fs_fmask);
fprintf(dbg_log, "bshift int32_t 0x%08x\n",
fprintf(dbg_log, "bshift int32_t 0x%08x\n",
sb->fs_bshift);
fprintf(dbg_log, "fshift int32_t 0x%08x\n",
fprintf(dbg_log, "fshift int32_t 0x%08x\n",
sb->fs_fshift);
fprintf(dbg_log, "maxcontig int32_t 0x%08x\n",
fprintf(dbg_log, "maxcontig int32_t 0x%08x\n",
sb->fs_maxcontig);
fprintf(dbg_log, "maxbpg int32_t 0x%08x\n",
fprintf(dbg_log, "maxbpg int32_t 0x%08x\n",
sb->fs_maxbpg);
fprintf(dbg_log, "fragshift int32_t 0x%08x\n",
fprintf(dbg_log, "fragshift int32_t 0x%08x\n",
sb->fs_fragshift);
fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n",
fprintf(dbg_log, "fsbtodb int32_t 0x%08x\n",
sb->fs_fsbtodb);
fprintf(dbg_log, "sbsize int32_t 0x%08x\n",
fprintf(dbg_log, "sbsize int32_t 0x%08x\n",
sb->fs_sbsize);
fprintf(dbg_log, "csmask int32_t 0x%08x\n",
sb->fs_csmask);
fprintf(dbg_log, "csshift int32_t 0x%08x\n",
sb->fs_csshift);
fprintf(dbg_log, "nindir int32_t 0x%08x\n",
fprintf(dbg_log, "spare1 int32_t[2] 0x%08x 0x%08x\n",
sb->fs_spare1[0], sb->fs_spare1[1]);
fprintf(dbg_log, "nindir int32_t 0x%08x\n",
sb->fs_nindir);
fprintf(dbg_log, "inopb int32_t 0x%08x\n",
fprintf(dbg_log, "inopb int32_t 0x%08x\n",
sb->fs_inopb);
fprintf(dbg_log, "nspf int32_t 0x%08x\n",
sb->fs_nspf);
fprintf(dbg_log, "old_nspf int32_t 0x%08x\n",
sb->fs_old_nspf);
fprintf(dbg_log, "optim int32_t 0x%08x\n",
fprintf(dbg_log, "optim int32_t 0x%08x\n",
sb->fs_optim);
fprintf(dbg_log, "npsect int32_t 0x%08x\n",
sb->fs_npsect);
fprintf(dbg_log, "interleave int32_t 0x%08x\n",
sb->fs_interleave);
fprintf(dbg_log, "trackskew int32_t 0x%08x\n",
sb->fs_trackskew);
fprintf(dbg_log, "old_npsect int32_t 0x%08x\n",
sb->fs_old_npsect);
fprintf(dbg_log, "old_interleave int32_t 0x%08x\n",
sb->fs_old_interleave);
fprintf(dbg_log, "old_trackskew int32_t 0x%08x\n",
sb->fs_old_trackskew);
fprintf(dbg_log, "id int32_t[2] %08x %08x\n",
fprintf(dbg_log, "id int32_t[2] 0x%08x 0x%08x\n",
sb->fs_id[0], sb->fs_id[1]);
fprintf(dbg_log, "csaddr ufs_daddr_t 0x%08x\n",
sb->fs_csaddr);
fprintf(dbg_log, "cssize int32_t 0x%08x\n",
fprintf(dbg_log, "old_csaddr int32_t 0x%08x\n",
sb->fs_old_csaddr);
fprintf(dbg_log, "cssize int32_t 0x%08x\n",
sb->fs_cssize);
fprintf(dbg_log, "cgsize int32_t 0x%08x\n",
fprintf(dbg_log, "cgsize int32_t 0x%08x\n",
sb->fs_cgsize);
fprintf(dbg_log, "ntrak int32_t 0x%08x\n",
sb->fs_ntrak);
fprintf(dbg_log, "nsect int32_t 0x%08x\n",
sb->fs_nsect);
fprintf(dbg_log, "spc int32_t 0x%08x\n",
sb->fs_spc);
fprintf(dbg_log, "spare2 int32_t 0x%08x\n",
sb->fs_spare2);
fprintf(dbg_log, "old_nsect int32_t 0x%08x\n",
sb->fs_old_nsect);
fprintf(dbg_log, "old_spc int32_t 0x%08x\n",
sb->fs_old_spc);
fprintf(dbg_log, "ncyl int32_t 0x%08x\n",
sb->fs_ncyl);
fprintf(dbg_log, "old_ncyl int32_t 0x%08x\n",
sb->fs_old_ncyl);
fprintf(dbg_log, "cpg int32_t 0x%08x\n",
sb->fs_cpg);
fprintf(dbg_log, "ipg int32_t 0x%08x\n",
fprintf(dbg_log, "old_cpg int32_t 0x%08x\n",
sb->fs_old_cpg);
fprintf(dbg_log, "ipg int32_t 0x%08x\n",
sb->fs_ipg);
fprintf(dbg_log, "fpg int32_t 0x%08x\n",
fprintf(dbg_log, "fpg int32_t 0x%08x\n",
sb->fs_fpg);
dbg_dump_csum("internal cstotal", &sb->fs_cstotal);
dbg_dump_csum("internal old_cstotal", &sb->fs_old_cstotal);
fprintf(dbg_log, "fmod int8_t 0x%02x\n",
fprintf(dbg_log, "fmod int8_t 0x%02x\n",
sb->fs_fmod);
fprintf(dbg_log, "clean int8_t 0x%02x\n",
fprintf(dbg_log, "clean int8_t 0x%02x\n",
sb->fs_clean);
fprintf(dbg_log, "ronly int8_t 0x%02x\n",
fprintf(dbg_log, "ronly int8_t 0x%02x\n",
sb->fs_ronly);
fprintf(dbg_log, "flags int8_t 0x%02x\n",
sb->fs_flags);
fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n",
fprintf(dbg_log, "old_flags int8_t 0x%02x\n",
sb->fs_old_flags);
fprintf(dbg_log, "fsmnt u_char[MAXMNTLEN] \"%s\"\n",
sb->fs_fsmnt);
fprintf(dbg_log, "volname u_char[MAXVOLLEN] \"%s\"\n",
sb->fs_volname);
fprintf(dbg_log, "swuid u_int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_swuid))[1],
((unsigned int *)&(sb->fs_swuid))[0]);
fprintf(dbg_log, "cgrotor int32_t 0x%08x\n",
fprintf(dbg_log, "pad int32_t 0x%08x\n",
sb->fs_pad);
fprintf(dbg_log, "cgrotor int32_t 0x%08x\n",
sb->fs_cgrotor);
/*
* struct csum[MAXCSBUFS] - is only maintained in memory
*/
/* fprintf(dbg_log, " int32_t\n", sb->*fs_maxcluster);*/
fprintf(dbg_log, "cpc int32_t 0x%08x\n",
sb->fs_cpc);
fprintf(dbg_log, "old_cpc int32_t 0x%08x\n",
sb->fs_old_cpc);
/*
* int16_t fs_opostbl[16][8] - is dumped when used in dbg_dump_sptbl
*/
fprintf(dbg_log, "maxbsize int32_t 0x%08x\n",
sb->fs_maxbsize);
fprintf(dbg_log, "sblockloc int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_sblockloc))[1],
((unsigned int *)&(sb->fs_sblockloc))[0]);
dbg_dump_csum_total("internal cstotal", &sb->fs_cstotal);
fprintf(dbg_log, "time ufs_time_t %10u\n",
(unsigned int)sb->fs_time);
fprintf(dbg_log, "size int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_size))[1],
((unsigned int *)&(sb->fs_size))[0]);
fprintf(dbg_log, "dsize int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_dsize))[1],
((unsigned int *)&(sb->fs_dsize))[0]);
fprintf(dbg_log, "csaddr ufs2_daddr_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_csaddr))[1],
((unsigned int *)&(sb->fs_csaddr))[0]);
fprintf(dbg_log, "pendingblocks int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_pendingblocks))[1],
((unsigned int *)&(sb->fs_pendingblocks))[0]);
fprintf(dbg_log, "pendinginodes int32_t 0x%08x\n",
sb->fs_pendinginodes);
#ifdef FSMAXSNAP
for(j=0; j<FSMAXSNAP; j++) {
fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n",
fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n",
j, sb->fs_snapinum[j]);
if(!sb->fs_snapinum[j]) { /* list is dense */
break;
}
}
#endif /* FSMAXSNAP */
fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n",
fprintf(dbg_log, "avgfilesize int32_t 0x%08x\n",
sb->fs_avgfilesize);
fprintf(dbg_log, "avgfpdir int32_t 0x%08x\n",
sb->fs_avgfpdir);
fprintf(dbg_log, "save_cgsize int32_t 0x%08x\n",
sb->fs_save_cgsize);
fprintf(dbg_log, "flags int32_t 0x%08x\n",
sb->fs_flags);
fprintf(dbg_log, "contigsumsize int32_t 0x%08x\n",
sb->fs_contigsumsize);
fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n",
fprintf(dbg_log, "maxsymlinklen int32_t 0x%08x\n",
sb->fs_maxsymlinklen);
fprintf(dbg_log, "inodefmt int32_t 0x%08x\n",
sb->fs_inodefmt);
fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n",
fprintf(dbg_log, "old_inodefmt int32_t 0x%08x\n",
sb->fs_old_inodefmt);
fprintf(dbg_log, "maxfilesize u_int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_maxfilesize))[1],
((unsigned int *)&(sb->fs_maxfilesize))[0]);
fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n",
fprintf(dbg_log, "qbmask int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_qbmask))[1],
((unsigned int *)&(sb->fs_qbmask))[0]);
fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n",
fprintf(dbg_log, "qfmask int64_t 0x%08x%08x\n",
((unsigned int *)&(sb->fs_qfmask))[1],
((unsigned int *)&(sb->fs_qfmask))[0]);
fprintf(dbg_log, "state int32_t 0x%08x\n",
fprintf(dbg_log, "state int32_t 0x%08x\n",
sb->fs_state);
fprintf(dbg_log, "postblformat int32_t 0x%08x\n",
sb->fs_postblformat);
fprintf(dbg_log, "nrpos int32_t 0x%08x\n",
sb->fs_nrpos);
fprintf(dbg_log, "postbloff int32_t 0x%08x\n",
sb->fs_postbloff);
fprintf(dbg_log, "rotbloff int32_t 0x%08x\n",
sb->fs_rotbloff);
fprintf(dbg_log, "magic int32_t 0x%08x\n",
fprintf(dbg_log, "old_postblformat int32_t 0x%08x\n",
sb->fs_old_postblformat);
fprintf(dbg_log, "old_nrpos int32_t 0x%08x\n",
sb->fs_old_nrpos);
fprintf(dbg_log, "spare5 int32_t[2] 0x%08x 0x%08x\n",
sb->fs_spare5[0], sb->fs_spare5[1]);
fprintf(dbg_log, "magic int32_t 0x%08x\n",
sb->fs_magic);
indent--;
@ -333,11 +371,10 @@ dbg_dump_cg(const char *comment, struct cg *cgr)
indent++;
fprintf(dbg_log, "magic int32_t 0x%08x\n", cgr->cg_magic);
fprintf(dbg_log, "time time_t %10u\n", (unsigned int)
cgr->cg_time);
fprintf(dbg_log, "old_time int32_t 0x%08x\n", cgr->cg_old_time);
fprintf(dbg_log, "cgx int32_t 0x%08x\n", cgr->cg_cgx);
fprintf(dbg_log, "ncyl int16_t 0x%04x\n", cgr->cg_ncyl);
fprintf(dbg_log, "niblk int16_t 0x%04x\n", cgr->cg_niblk);
fprintf(dbg_log, "old_ncyl int16_t 0x%04x\n", cgr->cg_old_ncyl);
fprintf(dbg_log, "old_niblk int16_t 0x%04x\n", cgr->cg_old_niblk);
fprintf(dbg_log, "ndblk int32_t 0x%08x\n", cgr->cg_ndblk);
dbg_dump_csum("internal cs", &cgr->cg_cs);
fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor);
@ -347,18 +384,22 @@ dbg_dump_cg(const char *comment, struct cg *cgr)
fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j,
cgr->cg_frsum[j]);
}
fprintf(dbg_log, "btotoff int32_t 0x%08x\n", cgr->cg_btotoff);
fprintf(dbg_log, "boff int32_t 0x%08x\n", cgr->cg_boff);
fprintf(dbg_log, "old_btotoff int32_t 0x%08x\n", cgr->cg_old_btotoff);
fprintf(dbg_log, "old_boff int32_t 0x%08x\n", cgr->cg_old_boff);
fprintf(dbg_log, "iusedoff int32_t 0x%08x\n", cgr->cg_iusedoff);
fprintf(dbg_log, "freeoff int32_t 0x%08x\n", cgr->cg_freeoff);
fprintf(dbg_log, "nextfreeoff int32_t 0x%08x\n",
cgr->cg_nextfreeoff);
fprintf(dbg_log, "clustersumoff int32_t 0x%08x\n",
cgr->cg_clustersumoff);
fprintf(dbg_log, "clusterof int32_t 0x%08x\n",
fprintf(dbg_log, "clusteroff int32_t 0x%08x\n",
cgr->cg_clusteroff);
fprintf(dbg_log, "nclusterblks int32_t 0x%08x\n",
cgr->cg_nclusterblks);
fprintf(dbg_log, "niblk int32_t 0x%08x\n", cgr->cg_niblk);
fprintf(dbg_log, "initediblk int32_t 0x%08x\n", cgr->cg_initediblk);
fprintf(dbg_log, "time ufs_time_t %10u\n",
(unsigned int)cgr->cg_initediblk);
indent--;
fprintf(dbg_log, "===== END CYLINDER GROUP =====\n");
@ -393,6 +434,43 @@ dbg_dump_csum(const char *comment, struct csum *cs)
return;
}
/* ************************************************ dbg_dump_csum_total ***** */
/*
* Dump a cylinder summary.
*/
void
dbg_dump_csum_total(const char *comment, struct csum_total *cs)
{
if(!dbg_log) {
return;
}
fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
indent++;
fprintf(dbg_log, "ndir int64_t 0x%08x%08x\n",
((unsigned int *)&(cs->cs_ndir))[1],
((unsigned int *)&(cs->cs_ndir))[0]);
fprintf(dbg_log, "nbfree int64_t 0x%08x%08x\n",
((unsigned int *)&(cs->cs_nbfree))[1],
((unsigned int *)&(cs->cs_nbfree))[0]);
fprintf(dbg_log, "nifree int64_t 0x%08x%08x\n",
((unsigned int *)&(cs->cs_nifree))[1],
((unsigned int *)&(cs->cs_nifree))[0]);
fprintf(dbg_log, "nffree int64_t 0x%08x%08x\n",
((unsigned int *)&(cs->cs_nffree))[1],
((unsigned int *)&(cs->cs_nffree))[0]);
fprintf(dbg_log, "numclusters int64_t 0x%08x%08x\n",
((unsigned int *)&(cs->cs_numclusters))[1],
((unsigned int *)&(cs->cs_numclusters))[0]);
indent--;
fprintf(dbg_log, "===== END CYLINDER SUMMARY TOTAL =====\n");
return;
}
/* **************************************************** dbg_dump_inmap ***** */
/*
* Dump the inode allocation map in one cylinder group.
@ -457,7 +535,10 @@ dbg_dump_frmap(struct fs *sb, const char *comment, struct cg *cgr)
indent++;
cp=(unsigned char *)cg_blksfree(cgr);
e=howmany((sb->fs_cpg * sb->fs_spc / NSPF(sb)), CHAR_BIT);
if (sb->fs_old_nspf)
e=howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT);
else
e = 0;
for(j=0; j<e; j+=32) {
fprintf(dbg_log, "%08x: ", j);
for(k=0; k<32; k+=8) {
@ -501,7 +582,10 @@ dbg_dump_clmap(struct fs *sb, const char *comment, struct cg *cgr)
indent++;
cp=(unsigned char *)cg_clustersfree(cgr);
e=howmany(sb->fs_cpg * sb->fs_spc / NSPB(sb), CHAR_BIT);
if (sb->fs_old_nspf)
e=howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT);
else
e = 0;
for(j=0; j<e; j+=32) {
fprintf(dbg_log, "%08x: ", j);
for(k=0; k<32; k+=8) {
@ -555,6 +639,14 @@ dbg_dump_clsum(struct fs *sb, const char *comment, struct cg *cgr)
return;
}
#ifdef NOT_CURRENTLY
/*
* This code dates from before the UFS2 integration, and doesn't compile
* post-UFS2 due to the use of cg_blks(). I'm not sure how best to update
* this for UFS2, where the rotational bits of UFS no longer apply, so
* will leave it disabled for now; it should probably be re-enabled
* specifically for UFS1.
*/
/* **************************************************** dbg_dump_sptbl ***** */
/*
* Dump the block summary, and the rotational layout table.
@ -575,11 +667,11 @@ dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr)
indent++;
ip=(int *)cg_blktot(cgr);
for(j=0; j<sb->fs_cpg; j++) {
for(j=0; j<sb->fs_old_cpg; j++) {
fprintf(dbg_log, "%2d: %5d = ", j, *ip++);
for(k=0; k<sb->fs_nrpos; k++) {
for(k=0; k<sb->fs_old_nrpos; k++) {
fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]);
if(k<sb->fs_nrpos-1) {
if(k<sb->fs_old_nrpos-1) {
fprintf(dbg_log, " + ");
}
}
@ -591,13 +683,14 @@ dbg_dump_sptbl(struct fs *sb, const char *comment, struct cg *cgr)
return;
}
#endif
/* ****************************************************** dbg_dump_ino ***** */
/* ************************************************** dbg_dump_ufs1_ino ***** */
/*
* Dump an inode structure.
* Dump a UFS1 inode structure.
*/
void
dbg_dump_ino(struct fs *sb, const char *comment, struct dinode *ino)
dbg_dump_ufs1_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino)
{
int ictr;
int remaining_blocks;
@ -606,7 +699,7 @@ dbg_dump_ino(struct fs *sb, const char *comment, struct dinode *ino)
return;
}
fprintf(dbg_log, "===== START INODE DUMP =====\n");
fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
indent++;
@ -636,13 +729,13 @@ dbg_dump_ino(struct fs *sb, const char *comment, struct dinode *ino)
fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n",
ino->di_ib[0]);
}
remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs_daddr_t));
remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs1_daddr_t));
if(remaining_blocks>0) {
fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n",
ino->di_ib[1]);
}
#define SQUARE(a) ((a)*(a))
remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs_daddr_t)));
remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)));
#undef SQUARE
if(remaining_blocks>0) {
fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n",
@ -656,7 +749,80 @@ dbg_dump_ino(struct fs *sb, const char *comment, struct dinode *ino)
fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid);
indent--;
fprintf(dbg_log, "===== END INODE DUMP =====\n");
fprintf(dbg_log, "===== END UFS1 INODE DUMP =====\n");
return;
}
/* ************************************************** dbg_dump_ufs2_ino ***** */
/*
* Dump a UFS2 inode structure.
*/
void
dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino)
{
int ictr;
int remaining_blocks;
if(!dbg_log) {
return;
}
fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
indent++;
fprintf(dbg_log, "mode u_int16_t 0%o\n", ino->di_mode);
fprintf(dbg_log, "nlink int16_t 0x%04x\n", ino->di_nlink);
fprintf(dbg_log, "uid u_int32_t 0x%08x\n", ino->di_uid);
fprintf(dbg_log, "gid u_int32_t 0x%08x\n", ino->di_gid);
fprintf(dbg_log, "blksize u_int32_t 0x%08x\n", ino->di_blksize);
fprintf(dbg_log, "size u_int64_t 0x%08x%08x\n",
((unsigned int *)&(ino->di_size))[1],
((unsigned int *)&(ino->di_size))[0]);
fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n",
((unsigned int *)&(ino->di_blocks))[1],
((unsigned int *)&(ino->di_blocks))[0]);
fprintf(dbg_log, "atime ufs_time_t %10u\n", ino->di_atime);
fprintf(dbg_log, "mtime ufs_time_t %10u\n", ino->di_mtime);
fprintf(dbg_log, "ctime ufs_time_t %10u\n", ino->di_ctime);
fprintf(dbg_log, "birthtime ufs_time_t %10u\n", ino->di_birthtime);
fprintf(dbg_log, "mtimensec int32_t 0x%08x\n", ino->di_mtimensec);
fprintf(dbg_log, "atimensec int32_t 0x%08x\n", ino->di_atimensec);
fprintf(dbg_log, "ctimensec int32_t 0x%08x\n", ino->di_ctimensec);
fprintf(dbg_log, "birthnsec int32_t 0x%08x\n", ino->di_birthnsec);
fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen);
fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags);
fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
fprintf(dbg_log, "extsize int32_t 0x%08x\n", ino->di_extsize);
/* XXX: What do we do with di_extb[NXADDR]? */
remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16x\n", ictr,
ino->di_db[ictr]);
}
remaining_blocks-=NDADDR;
if(remaining_blocks>0) {
fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16x\n",
ino->di_ib[0]);
}
remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs2_daddr_t));
if(remaining_blocks>0) {
fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16x\n",
ino->di_ib[1]);
}
#define SQUARE(a) ((a)*(a))
remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)));
#undef SQUARE
if(remaining_blocks>0) {
fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16x\n",
ino->di_ib[2]);
}
indent--;
fprintf(dbg_log, "===== END UFS2 INODE DUMP =====\n");
return;
}
@ -670,7 +836,7 @@ void
dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length)
{
unsigned int *mem;
int i, j;
int i, j, size;
if(!dbg_log) {
return;
@ -681,8 +847,13 @@ dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length)
comment);
indent++;
if (sb->fs_magic == FS_UFS1_MAGIC)
size = sizeof(ufs1_daddr_t);
else
size = sizeof(ufs2_daddr_t);
mem=(unsigned int *)block;
for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, sizeof(ufs_daddr_t)),
for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, size),
length); i+=8) {
fprintf(dbg_log, "%04x: ", i);
for (j=0; j<8; j++) {

View File

@ -54,7 +54,9 @@ void dbg_dump_hex(struct fs *, const char *, unsigned char *);
void dbg_dump_fs(struct fs *, const char *);
void dbg_dump_cg(const char *, struct cg *);
void dbg_dump_csum(const char *, struct csum *);
void dbg_dump_ino(struct fs *, const char *, struct dinode *);
void dbg_dump_csum_total(const char *, struct csum_total *);
void dbg_dump_ufs1_ino(struct fs *, const char *, struct ufs1_dinode *);
void dbg_dump_ufs2_ino(struct fs *, const char *, struct ufs2_dinode *);
void dbg_dump_iblk(struct fs *, const char *, char *, size_t);
void dbg_dump_inmap(struct fs *, const char *, struct cg *);
void dbg_dump_frmap(struct fs *, const char *, struct cg *);
@ -68,13 +70,17 @@ void dbg_dump_sptbl(struct fs *, const char *, struct cg *);
#define DBG_DUMP_FS(F,C) dbg_dump_fs((F),(C))
#define DBG_DUMP_CG(F,C,M) dbg_dump_cg((C),(M))
#define DBG_DUMP_CSUM(F,C,M) dbg_dump_csum((C),(M))
#define DBG_DUMP_INO(F,C,M) dbg_dump_ino((F),(C),(M))
#define DBG_DUMP_INO(F,C,M) (F)->fs_magic == FS_UFS1_MAGIC \
? dbg_dump_ufs1_ino((F),(C),(struct ufs1_dinode *)(M)) \
: dbg_dump_ufs2_ino((F),(C),(struct ufs2_dinode *)(M))
#define DBG_DUMP_IBLK(F,C,M,L) dbg_dump_iblk((F),(C),(M),(L))
#define DBG_DUMP_INMAP(F,C,M) dbg_dump_inmap((F),(C),(M))
#define DBG_DUMP_FRMAP(F,C,M) dbg_dump_frmap((F),(C),(M))
#define DBG_DUMP_CLMAP(F,C,M) dbg_dump_clmap((F),(C),(M))
#define DBG_DUMP_CLSUM(F,C,M) dbg_dump_clsum((F),(C),(M))
#ifdef NOT_CURRENTLY
#define DBG_DUMP_SPTBL(F,C,M) dbg_dump_sptbl((F),(C),(M))
#endif
#define DL_TRC 0x01
#define DL_INFO 0x02