From owner-freebsd-current@FreeBSD.ORG Thu May 8 13:47:16 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 F30A637B401; Thu, 8 May 2003 13:47:15 -0700 (PDT) Received: from beastie.mckusick.com (beastie.mckusick.com [209.31.233.184]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4B2DC43F75; Thu, 8 May 2003 13:47:15 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Received: from beastie.mckusick.com (localhost [127.0.0.1]) by beastie.mckusick.com (8.12.8/8.12.3) with ESMTP id h48KlDTh026805; Thu, 8 May 2003 13:47:13 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Message-Id: <200305082047.h48KlDTh026805@beastie.mckusick.com> To: Lukas Ertl In-Reply-To: Your message of "Thu, 08 May 2003 12:45:20 +0200." <20030508124346.A42559@pcle2.cc.univie.ac.at> Date: Thu, 08 May 2003 13:47:13 -0700 From: Kirk McKusick 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: Thu, 08 May 2003 20:47:16 -0000 Your proposed patch would work much better. There is a small possibility that it would stomp a boot block that just happened to have the filesystem magic number at that location, but the chances of that seem pretty remote. It does not address the alternate superblock issue. The first UFS1 alternate is 32 sectors (16K) in from the beginning of the disk. That alternate also remains untouched by UFS2. So, someone manually running fsck will be given the opportunity to look for alternate superblocks and will find that one and *still* end up messing 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). Kirk McKusick =-=-=-=-=-= Date: Thu, 8 May 2003 12:45:20 +0200 (CEST) From: Lukas Ertl To: Kirk McKusick cc: freebsd-current@freebsd.org, DougB@freebsd.org Subject: Re: bin/51619 X-ASK-Info: Whitelist match On Wed, 7 May 2003, Kirk McKusick wrote: > At one time I had the suggested change that you made in bin/51619 > in the FreeBSD-5.0 newfs program. The problem with that change is > that the bootstrap on some architectures now exceeds 8K which means > that instead of zeroing an old superblock you destroy the boot code. > So, I removed the zeroing of the old UFS1 superblock area. A possible > alternative would be to check for a UFS1 magic number at the old > location (and also at the 16K first backup location) and zero out > just those fields if they are found. While it is possible that a > bootstrap might just have that number at that offset, it is highly > unlikely. Hi Kirk, thanks for clarifying this. Would this patch here be better suited? ---8<--- Index: sbin/newfs/mkfs.c =================================================================== RCS file: /u/cvs/cvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.75 diff -u -r1.75 mkfs.c --- sbin/newfs/mkfs.c 3 May 2003 18:41:58 -0000 1.75 +++ sbin/newfs/mkfs.c 8 May 2003 10:42:15 -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 @@ -479,8 +485,22 @@ 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) { + /* + * Wipe out old UFS1 superblock if necessary. + */ + if (Oflag != 1) { + i = bread(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE); + if (i == -1) + err(1, "can't bread: %s", disk.d_error); + + if (fsdummy.fs_magic == FS_UFS1_MAGIC) { + fsdummy.fs_magic = 0; + bwrite(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, 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<--- regards, le -- 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ät Wien http://mailbox.univie.ac.at/~le/