From owner-freebsd-current@FreeBSD.ORG Fri May 9 05:12:05 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 AED8C37B401; Fri, 9 May 2003 05:12:05 -0700 (PDT) Received: from mailbox.univie.ac.at (mail.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1693643FA3; Fri, 9 May 2003 05:12:04 -0700 (PDT) (envelope-from l.ertl@univie.ac.at) Received: from [10.0.0.2] (adslle.cc.univie.ac.at [131.130.102.11]) by mailbox.univie.ac.at (8.12.2/8.12.2) with ESMTP id h49CBnU7189522; Fri, 9 May 2003 14:11:53 +0200 Date: Fri, 9 May 2003 14:11:44 +0200 (CEST) From: Lukas Ertl To: Kirk McKusick In-Reply-To: <200305082047.h48KlDTh026805@beastie.mckusick.com> Message-ID: <20030509140632.D596@korben.in.tern> References: <200305082047.h48KlDTh026805@beastie.mckusick.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-DCC-ZID-Univie-Metrics: unet 4261; Body=3 Fuz1=3 Fuz2=3 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 12:12:06 -0000 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /u/cvs/cvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.75 diff -u -r1.75 mkfs.c --- mkfs.c=093 May 2003 18:41:58 -0000=091.75 +++ mkfs.c=099 May 2003 12:11:02 -0000 @@ -113,6 +113,12 @@ =09quad_t sizepb; =09int width; =09char tmpbuf[100];=09/* XXX this will break in about 2,500 years */ +=09union { +=09=09struct fs fdummy; +=09=09char cdummy[SBLOCKSIZE]; +=09} dummy; +#define fsdummy dummy.fdummy +#define chdummy dummy.cdummy =09/* =09 * Our blocks =3D=3D sector size, and the version of UFS we are using i= s @@ -425,6 +431,24 @@ =09if (sblock.fs_flags & FS_DOSOFTDEP) =09=09printf("\twith soft updates\n"); #=09undef B2MBFACTOR + +=09/* +=09 * Wipe out old UFS1 superblock(s) if necessary. +=09 */ +=09if (!Nflag && Oflag !=3D 1) { +=09=09i =3D bread(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE); +=09=09if (i =3D=3D -1) +=09=09=09err(1, "can't read old UFS1 superblock: %s", disk.d_error); + +=09=09if (fsdummy.fs_magic =3D=3D FS_UFS1_MAGIC) { +=09=09=09fsdummy.fs_magic =3D 0; +=09=09=09bwrite(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE); +=09=09=09for (i =3D 0; i < fsdummy.fs_ncg; i++) +=09=09=09=09bwrite(&disk, fsbtodb(&fsdummy, cgsblock(&fsdummy, i)), +=09 chdummy, SBLOCKSIZE); +=09=09} +=09} + =09/* =09 * Now build the cylinders group blocks and =09 * then print out indices of cylinder groups. ---8<--- regards, le --=20 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=E4t Wien http://mailbox.univie.ac.at/~le/