bin/108320: dumpfs(8) lists wrong file system size [PATCH?]

Toby Burress kurin at delete.org
Wed Jan 24 21:10:20 UTC 2007


>Number:         108320
>Category:       bin
>Synopsis:       dumpfs(8) lists wrong file system size [PATCH?]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 24 21:10:18 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Toby Burress
>Release:        FreeBSD 6.1-RELEASE amd64
>Organization:
>Environment:
/usr/src/sbin/dumpfs
>Description:
When using dumpfs(8) to check the file system size, and in particular
dumpfs -m to find a command that creates the file system, the size
listed is smaller than the actual size of the file system.
>How-To-Repeat:
Run the following shell script (without warranty, etc etc, it doesn't
do anything bad but don't blame me if your power supply explodes)
and note the df lines.

#!/bin/sh
touch testfile
FS=`mdconfig -a -t vnode -f testfile -s 200M`
fdisk -I /dev/${FS}
bsdlabel -w /dev/${FS}s1
newfs /dev/${FS}s1a
dumpfs -m /dev/${FS}s1a > newfsfile
mount /dev/${FS}s1a /mnt
df -h /mnt
umount /dev/${FS}s1a
sh newfsfile
mount /dev/${FS}s1a /mnt
df -h /mnt
umount /dev/${FS}s1a
mdconfig -d -u ${FS}
rm testfile newfsfile
>Fix:

In my case the reported file system size is 4 times too small.  This
just happens to be the size of the "ncg" parameter.  So I think a
fix might be:

--- dumpfs.c.old        Fri Apr  9 15:58:27 2004
+++ dumpfs.c    Wed Jan 24 14:57:19 2007
@@ -135,7 +135,7 @@
                printf("superblock location\t%jd\tid\t[ %x %x ]\n",
                    (intmax_t)afs.fs_sblockloc, afs.fs_id[0], afs.fs_id[1]);
                printf("ncg\t%d\tsize\t%jd\tblocks\t%jd\n",
-                   afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize);
+                   afs.fs_ncg, (intmax_t)fssize * afs.fs_ncg, (intmax_t)afs.fs_dsize);
                break;
        case 1:
                fssize = afs.fs_old_size;
@@ -144,7 +144,7 @@
                    afs.fs_magic, ctime(&fstime));
                printf("id\t[ %x %x ]\n", afs.fs_id[0], afs.fs_id[1]);
                printf("ncg\t%d\tsize\t%jd\tblocks\t%jd\n",
-                   afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize);
+                   afs.fs_ncg, (intmax_t)fssize * afs.fs_ncg, (intmax_t)afs.fs_dsize);
                break;
        default:
                goto err;
@@ -367,7 +367,7 @@
                break;
        }
        /* -p..r unimplemented */
-       printf("-s %jd ", (intmax_t)fs->fs_size);
+       printf("-s %jd ", (intmax_t)fs->fs_size * fs->fs_ncg);
        printf("%s ", disk.d_name);
        printf("\n");

Of course, long experience has taught me that I never know what I'm
talking about, so even though this gives the right answers, maybe
the fix is somewhere else?  Either way, dumpfs is wrong and needs
to be fixed.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list