Date: Thu, 8 May 2003 12:45:20 +0200 (CEST) From: Lukas Ertl <l.ertl@univie.ac.at> To: Kirk McKusick <mckusick@McKusick.COM> Cc: freebsd-current@freebsd.org Subject: Re: bin/51619 Message-ID: <20030508124346.A42559@pcle2.cc.univie.ac.at> In-Reply-To: <200305072229.h47MTDTh024656@beastie.mckusick.com> References: <200305072229.h47MTDTh024656@beastie.mckusick.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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=093 May 2003 18:41:58 -0000=091.75 +++ sbin/newfs/mkfs.c=098 May 2003 10:42:15 -0000 @@ -113,6 +113,12 @@ =09quad_t sizepb; =09int width; =09char tmpbuf[100];=09/* XXX this will break in about 2,500 years */ +=09union { +=09=09struct fs fdummy; +=09=09char cdummy[SBLOCKSIZE]; +=09} dummy; +#define fsdummy dummy.fdummy +#define chdummy dummy.cdummy =09/* =09 * Our blocks =3D=3D sector size, and the version of UFS we are using i= s @@ -479,8 +485,22 @@ =09=09sblock.fs_old_cstotal.cs_nifree =3D sblock.fs_cstotal.cs_nifree; =09=09sblock.fs_old_cstotal.cs_nffree =3D sblock.fs_cstotal.cs_nffree; =09} -=09if (!Nflag) +=09if (!Nflag) { +=09=09/* +=09=09 * Wipe out old UFS1 superblock if necessary. +=09=09 */ +=09=09if (Oflag !=3D 1) { +=09=09=09i =3D bread(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZ= E); +=09=09=09if (i =3D=3D -1) +=09=09=09=09err(1, "can't bread: %s", disk.d_error); + +=09=09=09if (fsdummy.fs_magic =3D=3D FS_UFS1_MAGIC) { +=09=09=09=09fsdummy.fs_magic =3D 0; +=09=09=09=09bwrite(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE)= ; +=09=09=09} +=09=09} =09=09sbwrite(&disk, 0); +=09} =09for (i =3D 0; i < sblock.fs_cssize; i +=3D sblock.fs_bsize) =09=09wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), =09=09=09sblock.fs_cssize - i < sblock.fs_bsize ? ---8<--- regards, le --=20 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=E4t Wien http://mailbox.univie.ac.at/~le/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030508124346.A42559>