Subject: phasing out mfs; make init(8) use tmpfs?
To: None <tech-kern@netbsd.org>
From: David Young <dyoung@pobox.com>
List: tech-kern
Date: 02/15/2007 17:35:03
--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Is there anywhere TMPFS cannot replace MFS, and work at least as well?
If not, is it ok if we begin to phase MFS out?
I believe the only part of the system that depends on MFS is init(8).
If init(8) finds /dev/console missing, it creates /dev/ and runs MAKEDEV
in it. I have attached a patch that makes init(8) use TMPFS, instead.
I will commit this within the next couple weeks unless I hear serious
concerns.
Dave
--
David Young OJC Technologies
dyoung@ojctech.com Urbana, IL * (217) 278-3933
--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="init-tmpfs.patch"
Index: init.c
===================================================================
RCS file: /cvsroot/src/sbin/init/init.c,v
retrieving revision 1.88
diff -p -u -u -p -r1.88 init.c
--- init.c 15 Feb 2007 22:39:12 -0000 1.88
+++ init.c 15 Feb 2007 23:29:58 -0000
@@ -93,11 +93,11 @@ const struct timespec dtrtime = {.tv_sec
#if defined(RESCUEDIR)
#define INIT_BSHELL RESCUEDIR "/sh"
-#define INIT_MOUNT_MFS RESCUEDIR "/mount_mfs"
+#define INIT_MOUNT_TMPFS RESCUEDIR "/mount_tmpfs"
#define INIT_PATH RESCUEDIR ":" _PATH_STDPATH
#else
#define INIT_BSHELL _PATH_BSHELL
-#define INIT_MOUNT_MFS "/sbin/mount_mfs"
+#define INIT_MOUNT_TMPFS "/sbin/mount_tmpfs"
#define INIT_PATH _PATH_STDPATH
#endif
@@ -212,12 +212,7 @@ state_t requested_transition = single_us
#ifdef MFS_DEV_IF_NO_CONSOLE
#define NINODE 1280
-#define FSSIZE ((8192 /* boot area */ \
- + 2 * 8192 /* two copies of superblock */ \
- + 4096 /* cylinder group info */ \
- + NINODE * (128 + 18) /* inode and directory entry */ \
- + mfile[0].len /* size of MAKEDEV file */ \
- + 2 * 4096) / 512) /* some slack */
+#define FSSIZE (400 * NINODE)
struct mappedfile {
const char *path;
@@ -228,7 +223,7 @@ struct mappedfile {
{ "/dev/MAKEDEV.local", NULL, 0 }
};
-static int mfs_dev(void);
+static int tmpfs_dev(void);
static void mapfile(struct mappedfile *);
static void writefile(struct mappedfile *);
@@ -275,7 +270,7 @@ main(int argc, char **argv)
#ifdef MFS_DEV_IF_NO_CONSOLE
- if (mfs_dev() == -1)
+ if (tmpfs_dev() == -1)
requested_transition = single_user;
#endif
@@ -1671,7 +1666,7 @@ writefile(struct mappedfile *mf)
}
static int
-mfs_dev(void)
+tmpfs_dev(void)
{
/*
* We cannot print errors so we bail out silently...
@@ -1695,16 +1690,15 @@ mfs_dev(void)
/* Grab the contents of MAKEDEV.local */
mapfile(&mfile[1]);
- /* Mount an mfs over /dev so we can create devices */
+ /* Mount an tmpfs over /dev so we can create devices */
switch ((pid = fork())) {
case 0:
(void)asprintf(&fs_size, "%zu", FSSIZE);
if (fs_size == NULL)
return(-1);
- (void)execl(INIT_MOUNT_MFS, "mount_mfs",
- "-b", "4096", "-f", "512",
+ (void)execl(INIT_MOUNT_TMPFS, "mount_tmpfs",
"-s", fs_size, "-n", STR(NINODE),
- "-p", "0755",
+ "-m", "0755",
"swap", "/dev", NULL);
_exit(1);
/*NOTREACHED*/
@@ -1733,12 +1727,12 @@ mfs_dev(void)
(void)freopen(_PATH_CONSOLE, "a", stderr);
- warnx("Creating mfs /dev (%zu blocks, %d inodes)", FSSIZE, NINODE);
+ warnx("Creating tmpfs /dev (%zu blocks, %d inodes)", FSSIZE, NINODE);
- /* Create a MAKEDEV script in the mfs /dev */
+ /* Create a MAKEDEV script in the tmpfs /dev */
writefile(&mfile[0]);
- /* Create a MAKEDEV.local script in the mfs /dev */
+ /* Create a MAKEDEV.local script in the tmpfs /dev */
writefile(&mfile[1]);
/* Run the makedev script to create devices */
--IJpNTDwzlM2Ie8A6--