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.
This commit is contained in:
tsutsui 2012-02-07 14:14:45 +00:00
parent b1f6316364
commit d42cbdf611
1 changed files with 10 additions and 2 deletions

View File

@ -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;