Date: Tue, 26 Apr 2011 02:06:31 +0000 (UTC) From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r221049 - head/sbin/newfs Message-ID: <201104260206.p3Q26Vh8002221@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104260206.p3Q26Vh8002221>