Subject: fix for bin/5680
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 10/15/2000 22:25:42
Folks,
The following patch works for me as fix for bin/5680 (Mounting and
using broken mfs results into kernel panic). My question is - should
the newfs fail for the non-MFS case as well? When I try to 'cd' to a
directory created with "newfs -s 100" I get the following:
euclid:~ 16# cd /mnt
/mnt: Not a directory.
At least it's not a panic case like a small MFS is (although the
filesystem is still mountable). Should such a small filesystem on a
physical disk have a zero'd superblock so that it isn't mountable at
all?
Simon.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Sales, Support and Service: http://www.wasabisystems.com/
Index: mkfs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/newfs/mkfs.c,v
retrieving revision 1.38
diff -d -p -u -r1.38 mkfs.c
--- mkfs.c 2000/05/22 10:33:45 1.38
+++ mkfs.c 2000/10/15 11:10:50
@@ -52,6 +52,7 @@ __RCSID("$NetBSD: mkfs.c,v 1.38 2000/05/
#include <ufs/ffs/ffs_extern.h>
#include <sys/disklabel.h>
+#include <err.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
@@ -65,7 +66,7 @@ __RCSID("$NetBSD: mkfs.c,v 1.38 2000/05/
static void initcg __P((int, time_t));
-static void fsinit __P((time_t));
+static int fsinit __P((time_t));
static int makedir __P((struct direct *, int));
static daddr_t alloc __P((int, int));
static void iput __P((struct dinode *, ino_t));
@@ -639,7 +640,8 @@ next:
* Now construct the initial file system,
* then write out the super-block.
*/
- fsinit(utime);
+ if (fsinit(utime) == 0 && mfs)
+ errx(1, "Error making filesystem");
sblock.fs_time = utime;
memcpy(writebuf, &sblock, sbsize);
if (needswap)
@@ -881,7 +883,7 @@ struct odirect olost_found_dir[] = {
char buf[MAXBSIZE];
static void copy_dir __P((struct direct *, struct direct *));
-void
+int
fsinit(utime)
time_t utime;
{
@@ -934,11 +936,14 @@ fsinit(utime)
else
node.di_size = makedir(root_dir, PREDEFDIR);
node.di_db[0] = alloc(sblock.fs_fsize, node.di_mode);
+ if (node.di_db[0] == 0)
+ return (0);
node.di_blocks = btodb(fragroundup(&sblock, node.di_size));
node.di_uid = geteuid();
node.di_gid = getegid();
wtfs(fsbtodb(&sblock, node.di_db[0]), sblock.fs_fsize, buf);
iput(&node, ROOTINO);
+ return (1);
}
/*