From owner-freebsd-current@FreeBSD.ORG Fri May 9 09:23:15 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE27E37B401; Fri, 9 May 2003 09:23:15 -0700 (PDT) Received: from beastie.mckusick.com (beastie.mckusick.com [209.31.233.184]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4FEA843FA3; Fri, 9 May 2003 09:23:15 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Received: from beastie.mckusick.com (localhost [127.0.0.1]) by beastie.mckusick.com (8.12.8/8.12.3) with ESMTP id h49GNETh028440; Fri, 9 May 2003 09:23:14 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Message-Id: <200305091623.h49GNETh028440@beastie.mckusick.com> To: Lukas Ertl In-Reply-To: Your message of "Fri, 09 May 2003 14:11:44 +0200." <20030509140632.D596@korben.in.tern> Date: Fri, 09 May 2003 09:23:14 -0700 From: Kirk McKusick cc: DougB@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: bin/51619 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2003 16:23:16 -0000 I would say you have a winning fix. I am happy to have it go in. Kirk McKusick =-=-=-=-= Date: Fri, 9 May 2003 14:11:44 +0200 (CEST) From: Lukas Ertl To: Kirk McKusick cc: freebsd-current@freebsd.org, DougB@freebsd.org Subject: Re: bin/51619 X-ASK-Info: Whitelist match On Thu, 8 May 2003, Kirk McKusick wrote: > up the filesystem. Indeed to be completely safe, you would > need to look up every alternate superblock and zero out its > magic number (see the last for-loop in mkfs() for details > on how this is done). Allright, how about this one? I'm not quite sure if I got it right, but a quick test with fsck_ffs -b showed that the old superblocks were wiped out. I also moved that code to an earlier position, so that I do it before anything of the new stuff is written. ---8<--- Index: mkfs.c =================================================================== RCS file: /u/cvs/cvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.75 diff -u -r1.75 mkfs.c --- mkfs.c 3 May 2003 18:41:58 -0000 1.75 +++ mkfs.c 9 May 2003 12:11:02 -0000 @@ -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 @@ -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. ---8<--- regards, le -- Lukas Ertl eMail: l.ertl@univie.ac.at UNIX-Systemadministrator Tel.: (+43 1) 4277-14073 Zentraler Informatikdienst (ZID) Fax.: (+43 1) 4277-9140 der Universität Wien http://mailbox.univie.ac.at/~le/