Module Name:    src
Committed By:   riz
Date:           Thu Dec  2 22:00:27 UTC 2010

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

Log Message:
Use howmany() instead of "/" to calculate the number of cylinders for
the changed file system, so as to not drop a partial cylinder at the
end.  Fixes PR bin/44177.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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/resize_ffs.c
diff -u src/sbin/resize_ffs/resize_ffs.c:1.16 src/sbin/resize_ffs/resize_ffs.c:1.17
--- src/sbin/resize_ffs/resize_ffs.c:1.16	Wed Dec  1 17:39:21 2010
+++ src/sbin/resize_ffs/resize_ffs.c	Thu Dec  2 22:00:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize_ffs.c,v 1.16 2010/12/01 17:39:21 riz Exp $	*/
+/*	$NetBSD: resize_ffs.c,v 1.17 2010/12/02 22:00:27 riz Exp $	*/
 /* From sources sent on February 17, 2003 */
 /*-
  * As its sole author, I explicitly place this code in the public
@@ -882,7 +882,8 @@
 	 * to be at least one frag in size.) */
 	writeat(newsb->fs_size - 1, &sbbuf, newsb->fs_fsize);
 	/* Update fs_old_ncyl and fs_ncg. */
-	newsb->fs_old_ncyl = (newsb->fs_size * NSPF(newsb)) / newsb->fs_old_spc;
+	newsb->fs_old_ncyl = howmany(newsb->fs_size * NSPF(newsb),
+	    newsb->fs_old_spc);
 	newsb->fs_ncg = howmany(newsb->fs_old_ncyl, newsb->fs_old_cpg);
 	/* Does the last cg end before the end of its inode area? There is no
 	 * reason why this couldn't be handled, but it would complicate a lot
@@ -1521,7 +1522,8 @@
 	newsb->fs_time = timestamp();
 	/* Update the size figures. */
 	newsb->fs_size = dbtofsb(newsb, newsize);
-	newsb->fs_old_ncyl = (newsb->fs_size * NSPF(newsb)) / newsb->fs_old_spc;
+	newsb->fs_old_ncyl = howmany(newsb->fs_size * NSPF(newsb),
+	    newsb->fs_old_spc);
 	newsb->fs_ncg = howmany(newsb->fs_old_ncyl, newsb->fs_old_cpg);
 	/* Does the (new) last cg end before the end of its inode area?  See
 	 * the similar code in grow() for more on this. */

Reply via email to