Module Name: src Committed By: tsutsui Date: Tue Feb 7 14:14:46 UTC 2012
Modified Files: src/sbin/newfs: mkfs.c Log Message: Explicitly zap possible Ext2fs magic leftover to prevent kernel vfs_mountroot() and bootloaders from mis-recognizing the newfs(8)'ed file system as still Ext2fs. The problem is reported and the fix is tested by Frank Wille on current-users@. Also approved by releng. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sbin/newfs/mkfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/newfs/mkfs.c diff -u src/sbin/newfs/mkfs.c:1.110 src/sbin/newfs/mkfs.c:1.111 --- src/sbin/newfs/mkfs.c:1.110 Thu Aug 25 16:17:58 2011 +++ src/sbin/newfs/mkfs.c Tue Feb 7 14:14:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs.c,v 1.110 2011/08/25 16:17:58 joerg Exp $ */ +/* $NetBSD: mkfs.c,v 1.111 2012/02/07 14:14:45 tsutsui Exp $ */ /* * Copyright (c) 1980, 1989, 1993 @@ -73,7 +73,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: mkfs.c,v 1.110 2011/08/25 16:17:58 joerg Exp $"); +__RCSID("$NetBSD: mkfs.c,v 1.111 2012/02/07 14:14:45 tsutsui Exp $"); #endif #endif /* not lint */ @@ -152,6 +152,8 @@ union { ((sblock.fs_magic == FS_UFS1_MAGIC) ? \ (dp)->dp1.di_##field : (dp)->dp2.di_##field) +#define EXT2FS_SBOFF 1024 /* XXX: SBOFF in <ufs/ext2fs/ext2fs.h> */ + char *iobuf; int iobufsize; /* size to end of 2nd inode block */ int iobuf_memsize; /* Actual buffer size */ @@ -615,6 +617,12 @@ mkfs(const char *fsys, int fi, int fo, for (sz = SBLOCKSIZE; sz <= 0x10000; sz <<= 1) zap_old_sblock(roundup(sblkoff, sz)); } + /* + * Also zap possible Ext2fs magic leftover to prevent + * kernel vfs_mountroot() and bootloaders from mis-recognizing + * this file system as Ext2fs. + */ + zap_old_sblock(EXT2FS_SBOFF); if (isappleufs) { struct appleufslabel appleufs;