diff options
author | cperciva <cperciva@FreeBSD.org> | 2011-04-26 02:06:31 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2011-04-26 02:06:31 +0000 |
commit | bbad79fbccca2804019c96f95a06e828f227a9a4 (patch) | |
tree | 719c084adac61ea799d8159dbf93d28c27290cd4 /sbin/newfs | |
parent | 617fb5f51700207d1e18631393930ccbcff389db (diff) | |
download | FreeBSD-src-bbad79fbccca2804019c96f95a06e828f227a9a4.zip FreeBSD-src-bbad79fbccca2804019c96f95a06e828f227a9a4.tar.gz |
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
Diffstat (limited to 'sbin/newfs')
-rw-r--r-- | sbin/newfs/mkfs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index f98a51a..0503ebf 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -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) |