svn commit: r221392 - stable/8/sbin/newfs

Colin Percival cperciva at FreeBSD.org
Tue May 3 16:36:39 UTC 2011


Author: cperciva
Date: Tue May  3 16:36:39 2011
New Revision: 221392
URL: http://svn.freebsd.org/changeset/base/221392

Log:
  MFC r221049: Stop zeroing UFS1 superblocks if we fall off the end of the
  disk, in order to avoid wasting time (potentially many hours) in the event
  that we find a partially-overwritten UFS1 superblock.

Modified:
  stable/8/sbin/newfs/mkfs.c
Directory Properties:
  stable/8/sbin/newfs/   (props changed)

Modified: stable/8/sbin/newfs/mkfs.c
==============================================================================
--- stable/8/sbin/newfs/mkfs.c	Tue May  3 16:00:36 2011	(r221391)
+++ stable/8/sbin/newfs/mkfs.c	Tue May  3 16:36:39 2011	(r221392)
@@ -517,9 +517,12 @@ restart:
 			fsdummy.fs_magic = 0;
 			bwrite(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize,
 			    chdummy, SBLOCKSIZE);
-			for (cg = 0; cg < fsdummy.fs_ncg; cg++)
+			for (cg = 0; cg < fsdummy.fs_ncg; cg++) {
+				if (fsbtodb(&fsdummy, cgsblock(&fsdummy, cg)) > fssize)
+					break;
 				bwrite(&disk, part_ofs + fsbtodb(&fsdummy,
 				  cgsblock(&fsdummy, cg)), chdummy, SBLOCKSIZE);
+			}
 		}
 	}
 	if (!Nflag)


More information about the svn-src-all mailing list