Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/resize_ffs If we're operating on a plain file instead o...



details:   https://anonhg.NetBSD.org/src/rev/e49b31fccaac
branches:  trunk
changeset: 759386:e49b31fccaac
user:      riz <riz%NetBSD.org@localhost>
date:      Wed Dec 08 00:25:54 2010 +0000

description:
If we're operating on a plain file instead of a device, ftruncate() it
to ensure it's been properly extended.  Clears up some problems at certain
blocksizes which showed up during creation of atf tests, which is done
using file-backed file systems.

diffstat:

 sbin/resize_ffs/TODO         |   1 +
 sbin/resize_ffs/resize_ffs.c |  13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diffs (44 lines):

diff -r a5c565810eee -r e49b31fccaac sbin/resize_ffs/TODO
--- a/sbin/resize_ffs/TODO      Wed Dec 08 00:09:14 2010 +0000
+++ b/sbin/resize_ffs/TODO      Wed Dec 08 00:25:54 2010 +0000
@@ -2,5 +2,6 @@
 
 * Add support for swapped byte order
 * Fix support for disk blocks of size other than 512 bytes
+* Add support for plain files (primarily to ease testing)
 * Extend to support UFS2.  Probably growth first, then shrinking separately.
 * Expand the testing done in src/tests/sbin/resize_ffs
diff -r a5c565810eee -r e49b31fccaac sbin/resize_ffs/resize_ffs.c
--- a/sbin/resize_ffs/resize_ffs.c      Wed Dec 08 00:09:14 2010 +0000
+++ b/sbin/resize_ffs/resize_ffs.c      Wed Dec 08 00:25:54 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: resize_ffs.c,v 1.18 2010/12/07 23:29:55 riz Exp $      */
+/*     $NetBSD: resize_ffs.c,v 1.19 2010/12/08 00:25:54 riz Exp $      */
 /* From sources sent on February 17, 2003 */
 /*-
  * As its sole author, I explicitly place this code in the public
@@ -149,6 +149,15 @@
        fstat(fd, &stb);
        smallio = ((stb.st_mode & S_IFMT) == S_IFCHR);
 }
+
+static int
+isplainfile(void)
+{
+       struct stat stb;
+
+       fstat(fd, &stb);
+       return S_ISREG(stb.st_mode);
+}
 /*
  * Read size bytes starting at blkno into buf.  blkno is in DEV_BSIZE
  *  units, ie, after fsbtodb(); size is in bytes.
@@ -1942,6 +1951,8 @@
        }
        flush_cgs();
        write_sbs();
+       if (isplainfile())
+               ftruncate(fd,newsize * DEV_BSIZE);
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index