Module Name:    src
Committed By:   riz
Date:           Mon Nov 29 19:54:11 UTC 2010

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

Log Message:
Restore a couple of checks for updating the cg_old_ncyl value which
were commented out with XXX and a notation to "fix once fsck is fixed."
fsck seems to have been fixed for this particular issue sometime in the
7 years since the code was brought into the tree.

Update cg_old_niblk instead of cg_ni_blk, since this tool
currently supports ffsv1 only.

With these two changes, I can grow a file system and have the result
be clean according to fsck_ffs.  Shrinking still results in an unclean
file system.

OK mhitch@

While I'm here, fix a typo in an error message.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/sbin/resize_ffs/resize_ffs.c:1.14
--- src/sbin/resize_ffs/resize_ffs.c:1.13	Sat Oct 30 21:16:07 2010
+++ src/sbin/resize_ffs/resize_ffs.c	Mon Nov 29 19:54:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize_ffs.c,v 1.13 2010/10/30 21:16:07 haad Exp $	*/
+/*	$NetBSD: resize_ffs.c,v 1.14 2010/11/29 19:54:10 riz Exp $	*/
 /* From sources sent on February 17, 2003 */
 /*-
  * As its sole author, I explicitly place this code in the public
@@ -457,13 +457,11 @@
 	cg->cg_magic = CG_MAGIC;
 	cg->cg_cgx = cgn;
 	cg->cg_old_ncyl = newsb->fs_old_cpg;
-	/* fsck whines if the cg->cg_old_ncyl value in the last cg is fs_old_cpg
-	 * instead of zero, when fs_old_cpg is the correct value. */
-	/* XXX fix once fsck is fixed */
-	if ((cgn == newsb->fs_ncg - 1) /* && (newsb->fs_old_ncyl % newsb->fs_old_cpg) */ ) {
+	/* Update the cg_old_ncyl value for the last cylinder. */
+	if ((cgn == newsb->fs_ncg - 1) && (newsb->fs_old_ncyl % newsb->fs_old_cpg) ) {
 		cg->cg_old_ncyl = newsb->fs_old_ncyl % newsb->fs_old_cpg;
 	}
-	cg->cg_niblk = newsb->fs_ipg;
+	cg->cg_old_niblk = newsb->fs_ipg;
 	cg->cg_ndblk = dmax;
 	/* Set up the bitmap pointers.  We have to be careful to lay out the
 	 * cg _exactly_ the way mkfs and fsck do it, since fsck compares the
@@ -1618,14 +1616,10 @@
 	 * keeping track of exactly which ones require it. */
 	for (i = 0; i < newsb->fs_ncg; i++)
 		cgflags[i] |= CGF_DIRTY | CGF_BLKMAPS | CGF_INOMAPS;
-	/* Update the cg_old_ncyl value for the last cylinder.  The condition is
-	 * commented out because fsck whines if not - see the similar
-	 * condition in grow() for more. */
-	/* XXX fix once fsck is fixed */
-	/* if (newsb->fs_old_ncyl % newsb->fs_old_cpg) XXX */
-/*XXXJTK*/
-	cgs[newsb->fs_ncg - 1]->cg_old_ncyl =
-	    newsb->fs_old_ncyl % newsb->fs_old_cpg;
+	/* Update the cg_old_ncyl value for the last cylinder. */
+	if (newsb->fs_old_ncyl % newsb->fs_old_cpg)
+		cgs[newsb->fs_ncg - 1]->cg_old_ncyl =
+	    	    newsb->fs_old_ncyl % newsb->fs_old_cpg;
 	/* Make fs_dsize match the new reality. */
 	recompute_fs_dsize();
 }
@@ -1917,7 +1911,7 @@
 		if (where == SBLOCK_UFS2)
 			continue;
 		if (oldsb->fs_old_flags & FS_FLAGS_UPDATED)
-			err(EXIT_FAILURE, "Cannot resize ffsv2 format suberblock!");
+			err(EXIT_FAILURE, "Cannot resize ffsv2 format superblock!");
 	}
 	if (where == (off_t)-1)
 		errx(EXIT_FAILURE, "Bad magic number");

Reply via email to