From owner-cvs-src@FreeBSD.ORG Thu May 22 16:29:35 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 931) id 3EA4537B401; Thu, 22 May 2003 16:29:35 -0700 (PDT) Date: Thu, 22 May 2003 18:29:35 -0500 From: Juli Mallett To: Nate Lawson Message-ID: <20030522182935.A44330@FreeBSD.org> References: <20030522183930.564EF37B49D@hub.freebsd.org> <20030522161035.X95941@root.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030522161035.X95941@root.org>; from nate@root.org on Thu, May 22, 2003 at 04:14:51PM -0700 X-Title: Code Maven X-Towel: Yes X-Negacore: Yes X-Authentication-Warning: localhost: juli pwned teh intarweb cc: cvs-src@FreeBSD.org cc: Doug Barton cc: cvs-all@FreeBSD.org cc: src-committers@FreeBSD.org Subject: Re: cvs commit: src/sbin/newfs mkfs.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 May 2003 23:29:35 -0000 * Nate Lawson [ Date: 2003-05-22 ] [ w.r.t. Re: cvs commit: src/sbin/newfs mkfs.c ] > On Thu, 22 May 2003, Doug Barton wrote: > > When newfs'ing a partition with UFS2 that had previously been newfs'ed > > with UFS1, the UFS1 superblocks were not deleted. This allowed any > > RELENG_4 (or other non-UFS2-aware) fsck to think it knew how to "fix" > > the file system, resulting in severe data scrambling. > > > > This patch is a more advanced version than the one originally submitted. > > Lukas improved it based on feedback from Kirk, and testing by me. It > > blanks all UFS1 superblocks (if any) during a UFS2 newfs, thereby causing > > fsck's that are not UFS2 aware to generate the "SEARCH FOR ALTERNATE > > SUPER-BLOCK FAILED" message, and exit without damaging the fs. > > It's great to see user-friendly fixes hitting the tree. We really need > more seatbelts. > > > --- src/sbin/newfs/mkfs.c:1.76 Sat May 10 11:58:17 2003 > > +++ src/sbin/newfs/mkfs.c Thu May 22 11:38:54 2003 > > @@ -113,6 +113,12 @@ > > quad_t sizepb; > > int width; > > char tmpbuf[100]; /* XXX this will break in about 2,500 years */ > > + union { > > + struct fs fdummy; > > + char cdummy[SBLOCKSIZE]; > > + } dummy; > > +#define fsdummy dummy.fdummy > > +#define chdummy dummy.cdummy > > > > /* > > * Our blocks == sector size, and the version of UFS we are using is > > Should we have compatibility structs for past versions of the superblock? > It seems the union would be unnecessary if you had a "struct fs1". > > > @@ -425,6 +431,24 @@ > > if (sblock.fs_flags & FS_DOSOFTDEP) > > printf("\twith soft updates\n"); > > # undef B2MBFACTOR > > + > > + /* > > + * Wipe out old UFS1 superblock(s) if necessary. > > + */ > > + if (!Nflag && Oflag != 1) { > > + i = bread(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE); > > + if (i == -1) > > + err(1, "can't read old UFS1 superblock: %s", disk.d_error); > > + > > + if (fsdummy.fs_magic == FS_UFS1_MAGIC) { > > + fsdummy.fs_magic = 0; > > + bwrite(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE); > > + for (i = 0; i < fsdummy.fs_ncg; i++) > > + bwrite(&disk, fsbtodb(&fsdummy, cgsblock(&fsdummy, i)), > > + chdummy, SBLOCKSIZE); > > + } > > + } > > + > > /* > > * Now build the cylinders group blocks and > > * then print out indices of cylinder groups. > > I must be missing something -- I can't see how this wipes out the > alternate superblocks and not just the first one. The ones at each cylinder group, see line 54 of this mail, as well as the line of context before and after. Also, this should not be UFS1 specific, but rather, zero the inverse of the superblock we mean to be writing, even if the situation is not as likely to be a problem, you never know. -- juli mallett. email: jmallett@freebsd.org; efnet: juli;