From owner-freebsd-current@FreeBSD.ORG Tue Apr 29 15:24:54 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 BF21537B401 for ; Tue, 29 Apr 2003 15:24:53 -0700 (PDT) Received: from ldc.ro (ldc-gw.rdsnet.ro [213.157.163.8]) by mx1.FreeBSD.org (Postfix) with SMTP id 5A27443FBD for ; Tue, 29 Apr 2003 15:24:52 -0700 (PDT) (envelope-from razor@ldc.ro) Received: (qmail 61238 invoked by uid 666); 29 Apr 2003 22:24:51 -0000 Date: Wed, 30 Apr 2003 01:24:50 +0300 From: Alex Popa To: Lukas Ertl Message-ID: <20030429222450.GA59203@ldc.ro> References: <20030426225533.R743@leelou.in.tern> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030426225533.R743@leelou.in.tern> User-Agent: Mutt/1.4.1i cc: freebsd-current@freebsd.org Subject: Re: newfs for UFS2 problems 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: Tue, 29 Apr 2003 22:24:54 -0000 Hello, sorry for the delay in testing and answering. The patch seems to work with a little modification, deduced from this: lib/libufs/block.c, line 80: bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size) ... cnt = pwrite(disk->d_fd, data, size, (off_t)(blockno * disk->d_bsize)); ... It look that it multiplies by a block size. However, in sys/ufs/ffs/fs.h, lines 68-69 mention the superblock offset is defined in bytes, not blocks. So it seems we need to change your "SBLOCK_UFS1" to "SBLOCK_UFS1 / disk.d_bsize", to get the expected result (overwriting the old ufs1 superblock). This is all I have changed in your patch (the modified patch is below). I have tested it, and dumpfs and mount from 4.8 now complain about a missing magic number / incorrect superblock. Thanks for your help Alex ---8<--- Index: sbin/newfs/mkfs.c =================================================================== RCS file: /home/ncvs/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 29 Apr 2003 21:57:33 -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 ? ---8<--- On Sat, Apr 26, 2003 at 11:01:41PM +0200, Lukas Ertl wrote: > 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. > > > best 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/ ------------+------------------------------------------------------- Alex Popa, | "Computer science is no more about computers than razor@ldc.ro| astronomy is about telescopes" -- E. W. Dijkstra ------------+------------------------------------------------------