Re: newfs for UFS2 problems

From: Lukas Ertl <l.ertl_at_univie.ac.at>
Date: Sat, 26 Apr 2003 23:01:41 +0200 (CEST)
Alex Popa wrote:

> It seems the problem is partly caused by newfs on -current, which does
> not remove the old UFS1 magic when creating an UFS2 superblock at a
> different location.  This leftover magic is seen by the -stable kernel
> and therefore used.

Hi Alex,

could you try this patch to newfs(8)? It wipes the old UFS1 superblock
at location SBLOCK_UFS1 before writing the new superblock at location
SBLOCK_UFS2.

---8<---
Index: sbin/newfs/mkfs.c
===================================================================
RCS file: /u/cvs/cvs/src/sbin/newfs/mkfs.c,v
retrieving revision 1.74
diff -u -r1.74 mkfs.c
--- sbin/newfs/mkfs.c	22 Feb 2003 23:26:11 -0000	1.74
+++ sbin/newfs/mkfs.c	26 Apr 2003 20:54:56 -0000
_at__at_ -113,6 +113,7 _at__at_
 	quad_t sizepb;
 	int width;
 	char tmpbuf[100];	/* XXX this will break in about 2,500 years */
+	char dummy[SBLOCKSIZE];

 	/*
 	 * Our blocks == sector size, and the version of UFS we are using is
_at__at_ -479,8 +480,13 _at__at_
 		sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree;
 		sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree;
 	}
-	if (!Nflag)
+	if (!Nflag) {
+		if (Oflag != 1) {
+			memset(dummy, '\0', SBLOCKSIZE);
+			bwrite(&disk, SBLOCK_UFS1, dummy, SBLOCKSIZE);
+		}
 		sbwrite(&disk, 0);
+	}
 	for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize)
 		wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)),
 			sblock.fs_cssize - i < sblock.fs_bsize ?
---8<---

best 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/
Received on Sat Apr 26 2003 - 12:01:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:05 UTC