svn commit: r221049 - head/sbin/newfs
Colin Percival
cperciva at FreeBSD.org
Tue Apr 26 02:06:32 UTC 2011
Author: cperciva
Date: Tue Apr 26 02:06:31 2011
New Revision: 221049
URL: http://svn.freebsd.org/changeset/base/221049
Log:
Stop trying to zero UFS1 superblocks if we fall off the end of the disk.
This avoids a potentially many-hours-long loop of failed writes if newfs
finds a partially-overwritten superblock (or, for that matter, random
garbage which happens to have superblock magic bytes); on one occasion I
found newfs trying to zero 800 million superblocks on a 50 MB disk.
Reviewed by: mckusick
MFC after: 1 week
Modified:
head/sbin/newfs/mkfs.c
Modified: head/sbin/newfs/mkfs.c
==============================================================================
--- head/sbin/newfs/mkfs.c Tue Apr 26 01:56:18 2011 (r221048)
+++ head/sbin/newfs/mkfs.c Tue Apr 26 02:06:31 2011 (r221049)
@@ -516,9 +516,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