aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsdb
diff options
context:
space:
mode:
authorDon Lewis <truckman@FreeBSD.org>2012-02-06 21:50:11 +0000
committerDon Lewis <truckman@FreeBSD.org>2012-02-06 21:50:11 +0000
commitec1a0f73d080e9260a4aae19339ff9e78cd5fe2f (patch)
treedcf736974ab1e1549eff1b9fa05700153a2c99c9 /sbin/fsdb
parent005576f63d3001bd8cc19634a4d7f1fe4200e52d (diff)
downloadsrc-ec1a0f73d080e9260a4aae19339ff9e78cd5fe2f.tar.gz
src-ec1a0f73d080e9260a4aae19339ff9e78cd5fe2f.zip
Improve sparse file handling when printing the block list for an inode by
not bailing out early when a hole is encountered in the direct block list. Print NULL block pointers in the direct block list. Simplify the code that prints the fragment count. Match the style of the existing code. Reviewed by: mckusick MFC after: 1 week
Notes
Notes: svn path=/head/; revision=231102
Diffstat (limited to 'sbin/fsdb')
-rw-r--r--sbin/fsdb/fsdbutil.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c
index 7ed78a7f39ee..f434677beea9 100644
--- a/sbin/fsdb/fsdbutil.c
+++ b/sbin/fsdb/fsdbutil.c
@@ -293,22 +293,21 @@ printblocks(ino_t inum, union dinode *dp)
printf("Blocks for inode %d:\n", inum);
printf("Direct blocks:\n");
ndb = howmany(DIP(dp, di_size), sblock.fs_bsize);
- for (i = 0; i < NDADDR; i++) {
- if (DIP(dp, di_db[i]) == 0) {
- putchar('\n');
- return;
- }
+ for (i = 0; i < NDADDR && i < ndb; i++) {
if (i > 0)
printf(", ");
blkno = DIP(dp, di_db[i]);
printf("%jd", (intmax_t)blkno);
- if (--ndb == 0 && (offset = blkoff(&sblock, DIP(dp, di_size))) != 0) {
+ }
+ if (ndb <= NDADDR) {
+ offset = blkoff(&sblock, DIP(dp, di_size));
+ if (offset != 0) {
nfrags = numfrags(&sblock, fragroundup(&sblock, offset));
printf(" (%d frag%s)", nfrags, nfrags > 1? "s": "");
}
}
putchar('\n');
- if (ndb == 0)
+ if (ndb <= NDADDR)
return;
bufp = malloc((unsigned int)sblock.fs_bsize);