Date: Mon, 6 Feb 2012 21:50:12 +0000 (UTC) From: Don Lewis <truckman@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r231102 - head/sbin/fsdb Message-ID: <201202062150.q16LoCJd055113@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: truckman Date: Mon Feb 6 21:50:11 2012 New Revision: 231102 URL: http://svn.freebsd.org/changeset/base/231102 Log: 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 Modified: head/sbin/fsdb/fsdbutil.c Modified: head/sbin/fsdb/fsdbutil.c ============================================================================== --- head/sbin/fsdb/fsdbutil.c Mon Feb 6 21:35:11 2012 (r231101) +++ head/sbin/fsdb/fsdbutil.c Mon Feb 6 21:50:11 2012 (r231102) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202062150.q16LoCJd055113>