bin/51619
Lukas Ertl
l.ertl at univie.ac.at
Fri May 9 05:12:06 PDT 2003
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 at 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/
More information about the freebsd-current
mailing list