This seems to fix growfs on 4k-sector drives by doing the test write
to the last sector rather than the last 512-byte block, which can't be
accessed directly on 4k-sector drives.

Any other growfs users out there want to test on 'normal' drives?

.... Ken

Index: growfs.c
===================================================================
RCS file: /cvs/src/sbin/growfs/growfs.c,v
retrieving revision 1.33
diff -u -p -r1.33 growfs.c
--- growfs.c    10 Nov 2013 00:48:04 -0000      1.33
+++ growfs.c    29 Apr 2014 15:42:56 -0000
@@ -1899,7 +1899,7 @@ int
 main(int argc, char **argv)
 {
        DBG_FUNC("main")
-       char    *device;
+       char    *device, *lastsector;
        int     ch;
        long long       size = 0;
        unsigned int    Nflag = 0;
@@ -2072,12 +2072,16 @@ main(int argc, char **argv)
                    (intmax_t)sblock.fs_size);
 
        /*
-        * Try to access our new last block in the filesystem. Even if we
-        * later on realize we have to abort our operation, on that block
+        * Try to access our new last sector in the filesystem. Even if we
+        * later on realize we have to abort our operation, on that sector
         * there should be no data, so we can't destroy something yet.
         */
-       wtfs(DL_SECTOBLK(lp, DL_GETPSIZE(pp)) - 1, (size_t)DEV_BSIZE,
-           (void *)&sblock, fso, Nflag);
+       lastsector = calloc(1, lp->d_secsize);
+       if (!lastsector)
+               err(1, "No memory for last sector test write");
+       wtfs(DL_SECTOBLK(lp, DL_GETPSIZE(pp) - 1), lp->d_secsize,
+           lastsector, fso, Nflag);
+       free(lastsector);
 
        /*
         * Now calculate new superblock values and check for reasonable

Reply via email to