Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 May 2003 14:11:44 +0200 (CEST)
From:      Lukas Ertl <l.ertl@univie.ac.at>
To:        Kirk McKusick <mckusick@beastie.mckusick.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: bin/51619 
Message-ID:  <20030509140632.D596@korben.in.tern>
In-Reply-To: <200305082047.h48KlDTh026805@beastie.mckusick.com>
References:  <200305082047.h48KlDTh026805@beastie.mckusick.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030509140632.D596>