summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-11-06 08:53:59 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-11-06 08:53:59 +0000
commitbcca745153e079c445a922e334fe660ad7085a16 (patch)
tree3ccef49726b8f78235d535fdfee25bbf6bdb3dc2 /sbin
parent66af668d7ad938e7865a44f40b3af60aa1ec8d30 (diff)
don't write magic until the file system is really done. prevents
fsck/mount unhappiness. hint from freebsd-arch ml. ok deraadt@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/newfs/mkfs.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 2b5c6e5c184..3bbe69101bb 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkfs.c,v 1.35 2003/11/03 05:40:09 tedu Exp $ */
+/* $OpenBSD: mkfs.c,v 1.36 2003/11/06 08:53:58 tedu Exp $ */
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94";
#else
-static char rcsid[] = "$OpenBSD: mkfs.c,v 1.35 2003/11/03 05:40:09 tedu Exp $";
+static char rcsid[] = "$OpenBSD: mkfs.c,v 1.36 2003/11/06 08:53:58 tedu Exp $";
#endif
#endif /* not lint */
@@ -640,7 +640,10 @@ next:
*/
fsinit(utime);
sblock.fs_time = utime;
+ /* don't write magic until we are done */
+ sblock.fs_magic = 0;
wtfs((int)SBOFF / sectorsize, sbsize, (char *)&sblock);
+ sblock.fs_magic = FS_MAGIC;
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 ?
@@ -652,6 +655,8 @@ next:
for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
wtfs(fsbtodb(&sblock, cgsblock(&sblock, cylno)),
sbsize, (char *)&sblock);
+ /* done, can write with magic now */
+ wtfs((int)SBOFF / sectorsize, sbsize, (char *)&sblock);
/*
* Update information about this partion in pack
* label, to that it may be updated on disk.