From le@univie.ac.at Wed Apr 30 04:35:32 2003 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B29AE37B401 for ; Wed, 30 Apr 2003 04:35:32 -0700 (PDT) Received: from mailbox.univie.ac.at (mail.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A25343F75 for ; Wed, 30 Apr 2003 04:35:31 -0700 (PDT) (envelope-from le@univie.ac.at) Received: from leelou.in.tern (adslle.cc.univie.ac.at [131.130.102.11]) by mailbox.univie.ac.at (8.12.2/8.12.2) with ESMTP id h3UBZBAv198068 for ; Wed, 30 Apr 2003 13:35:17 +0200 Received: from leelou.in.tern (leelou [127.0.0.1]) by leelou.in.tern (8.12.9/8.12.9) with ESMTP id h3UBZAIG001533 for ; Wed, 30 Apr 2003 13:35:11 +0200 (CEST) (envelope-from le@leelou.in.tern) Received: (from le@localhost) by leelou.in.tern (8.12.9/8.12.9/Submit) id h3UBZAoP001532; Wed, 30 Apr 2003 13:35:10 +0200 (CEST) (envelope-from le) Message-Id: <200304301135.h3UBZAoP001532@leelou.in.tern> Date: Wed, 30 Apr 2003 13:35:10 +0200 (CEST) From: Lukas Ertl Reply-To: Lukas Ertl To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: [PATCH] newfs: wipe UFS1 superblock before writing UFS2 superblock X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 51619 >Category: bin >Synopsis: [PATCH] newfs: wipe UFS1 superblock before writing UFS2 superblock >Confidential: no >Severity: non-critical >Priority: medium >Responsible: dougb >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 30 04:40:14 PDT 2003 >Closed-Date: Tue May 13 02:23:00 PDT 2003 >Last-Modified: Tue May 13 02:33:06 PDT 2003 >Originator: Lukas Ertl >Release: FreeBSD 5.0-CURRENT i386 >Organization: Vienna University Computer Center >Environment: System: FreeBSD leelou 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Thu Apr 24 16:53:52 CEST 2003 le@leelou:/usr/obj/usr/src/sys/LEELOU i386 >Description: If you have a UFS1 filesystem and create a new UFS2 filesystem over that one, the old superblock still exists since UFS2 places the superblock to a different location. This can cause problems if you try to use this UFS2 filesystem in FreeBSD 4.x, which has no support of UFS2, but sees the old UFS1 superblock. See also http://lists.freebsd.org/pipermail/freebsd-current/2003-April/001649.html >How-To-Repeat: In 4.x: newfs /dev/bla # create UFS1 In 5-current, but with the same disk: newfs /dev/bla # create UFS2 - but UFS1 superblock is still in place Back in 4.x: mount /dev/bla /mnt # succeeds, although it is UFS2... >Fix: --- mkfs.c.diff begins here --- 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 30 Apr 2003 11:23:49 -0000 @@ -113,6 +113,7 @@ 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 @@ -479,8 +480,13 @@ 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 / disk.d_bsize, 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 ? --- mkfs.c.diff ends here --- >Release-Note: >Audit-Trail: State-Changed-From-To: open->closed State-Changed-By: dougb State-Changed-When: Tue May 13 02:21:56 PDT 2003 State-Changed-Why: After discussion with Kirk, and an improved patch from Lukas, the fix was committed. Responsible-Changed-From-To: freebsd-bugs->dougb Responsible-Changed-By: dougb Responsible-Changed-When: Tue May 13 02:21:56 PDT 2003 Responsible-Changed-Why: I helped test the patch, and did the commit. http://www.freebsd.org/cgi/query-pr.cgi?pr=51619 >Unformatted: