aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsdb
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsdb')
-rw-r--r--sbin/fsdb/fsdb.c11
-rw-r--r--sbin/fsdb/fsdbutil.c26
2 files changed, 20 insertions, 17 deletions
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c
index f7354e86d9cc..5622cbb29196 100644
--- a/sbin/fsdb/fsdb.c
+++ b/sbin/fsdb/fsdb.c
@@ -396,7 +396,8 @@ const char *typename[] = {
"unregistered #13",
"whiteout",
};
-
+
+int diroff;
int slot;
int
@@ -404,9 +405,10 @@ scannames(struct inodesc *idesc)
{
struct direct *dirp = idesc->id_dirp;
- printf("slot %d ino %d reclen %d: %s, `%.*s'\n",
- slot++, dirp->d_ino, dirp->d_reclen, typename[dirp->d_type],
- dirp->d_namlen, dirp->d_name);
+ printf("slot %d off %d ino %d reclen %d: %s, `%.*s'\n",
+ slot++, diroff, dirp->d_ino, dirp->d_reclen,
+ typename[dirp->d_type], dirp->d_namlen, dirp->d_name);
+ diroff += dirp->d_reclen;
return (KEEPON);
}
@@ -416,6 +418,7 @@ CMDFUNCSTART(ls)
checkactivedir(); /* let it go on anyway */
slot = 0;
+ diroff = 0;
idesc.id_number = curinum;
idesc.id_func = scannames;
idesc.id_type = DATA;
diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c
index d50c6c00d331..2c5710a80aa8 100644
--- a/sbin/fsdb/fsdbutil.c
+++ b/sbin/fsdb/fsdbutil.c
@@ -52,7 +52,7 @@ static const char rcsid[] =
#include "fsck.h"
static int charsperline(void);
-static int printindir(ufs2_daddr_t blk, int level, char *bufp);
+static void printindir(ufs2_daddr_t blk, int level, char *bufp);
static void printblocks(ino_t inum, union dinode *dp);
char **
@@ -226,7 +226,7 @@ charsperline(void)
/*
* Recursively print a list of indirect blocks.
*/
-static int
+static void
printindir(ufs2_daddr_t blk, int level, char *bufp)
{
struct bufarea buf, *bp;
@@ -234,6 +234,9 @@ printindir(ufs2_daddr_t blk, int level, char *bufp)
int i, j, cpl, charssofar;
ufs2_daddr_t blkno;
+ if (blk == 0)
+ return;
+ printf("%jd (%d) =>\n", (intmax_t)blk, level);
if (level == 0) {
/* for the final indirect level, don't use the cache */
bp = &buf;
@@ -251,11 +254,8 @@ printindir(ufs2_daddr_t blk, int level, char *bufp)
blkno = bp->b_un.b_indir1[i];
else
blkno = bp->b_un.b_indir2[i];
- if (blkno == 0) {
- if (level == 0)
- putchar('\n');
- return 0;
- }
+ if (blkno == 0)
+ continue;
j = sprintf(tempbuf, "%jd", (intmax_t)blkno);
if (level == 0) {
charssofar += j;
@@ -270,13 +270,14 @@ printindir(ufs2_daddr_t blk, int level, char *bufp)
charssofar += 2;
} else {
printf(" =>\n");
- if (printindir(blkno, level - 1, bufp) == 0)
- return 0;
+ printindir(blkno, level - 1, bufp);
+ printf("\n");
+ charssofar = 0;
}
}
if (level == 0)
putchar('\n');
- return 1;
+ return;
}
@@ -309,7 +310,7 @@ printblocks(ino_t inum, union dinode *dp)
}
}
putchar('\n');
- if (DIP(dp, di_ib[0]) == 0)
+ if (ndb == 0)
return;
bufp = malloc((unsigned int)sblock.fs_bsize);
@@ -317,8 +318,7 @@ printblocks(ino_t inum, union dinode *dp)
errx(EEXIT, "cannot allocate indirect block buffer");
printf("Indirect blocks:\n");
for (i = 0; i < NIADDR; i++)
- if (printindir(DIP(dp, di_ib[i]), i, bufp) == 0)
- break;
+ printindir(DIP(dp, di_ib[i]), i, bufp);
free(bufp);
}