Module Name:    src
Committed By:   riz
Date:           Wed Dec  8 00:25:54 UTC 2010

Modified Files:
        src/sbin/resize_ffs: TODO resize_ffs.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/resize_ffs/TODO
cvs rdiff -u -r1.18 -r1.19 src/sbin/resize_ffs/resize_ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/resize_ffs/TODO
diff -u src/sbin/resize_ffs/TODO:1.5 src/sbin/resize_ffs/TODO:1.6
--- src/sbin/resize_ffs/TODO:1.5	Fri Dec  3 05:23:34 2010
+++ src/sbin/resize_ffs/TODO	Wed Dec  8 00:25:54 2010
@@ -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

Index: src/sbin/resize_ffs/resize_ffs.c
diff -u src/sbin/resize_ffs/resize_ffs.c:1.18 src/sbin/resize_ffs/resize_ffs.c:1.19
--- src/sbin/resize_ffs/resize_ffs.c:1.18	Tue Dec  7 23:29:55 2010
+++ src/sbin/resize_ffs/resize_ffs.c	Wed Dec  8 00:25:54 2010
@@ -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;
 }
 

Reply via email to