tech-embed archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: problem with MFS and init



On Tue, Nov 01, 2005 at 08:54:06PM +0100, Jachym Holecek wrote:
> Hello,
> 
> > If you don't have /dev populated, init is supposed to "make one" in an 
> > MFS filesystem.
> 
> Yup, there's a compile-time option for this.
> 
> > I probably should file this as a PR, but I wanted to inquire before I 
> > did that.  FWIW my unit has ~192MB, so its not RAM that is exhausted -- 
> > just inodes in the MFS.
> 
> Bump NINODE in sbin/init/init.c (1024 currently). IMO, the right solution
> here is to teach init(8) to create /dev on tmpfs instead of mfs
> (tmpfs can grow and shrink as needed, unlike mfs). This is somewhere
> deep down on my TODO list...

I did that last night.  It's pretty simple.  Here is a patch.

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933
? .init.c.swp
Index: init.c
===================================================================
RCS file: /cvsroot/src/sbin/init/init.c,v
retrieving revision 1.70
diff -u -u -r1.70 init.c
--- init.c      27 Jun 2005 01:00:05 -0000      1.70
+++ init.c      1 Nov 2005 23:17:23 -0000
@@ -94,11 +94,11 @@
 
 #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
 
@@ -187,12 +187,7 @@
 #ifdef MFS_DEV_IF_NO_CONSOLE
 
 #define NINODE 1024
-#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 * 1024)
 
 struct mappedfile {
        const char *path;
@@ -203,7 +198,7 @@
        { "/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 *);
 
@@ -246,7 +241,7 @@
 
 
 #ifdef MFS_DEV_IF_NO_CONSOLE
-       if (mfs_dev() == -1)
+       if (tmpfs_dev() == -1)
                requested_transition = single_user;
 #endif
 
@@ -1415,7 +1410,7 @@
 }
 
 static int
-mfs_dev(void)
+tmpfs_dev(void)
 {
        /*
         * We cannot print errors so we bail out silently...
@@ -1439,14 +1434,13 @@
        /* 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:
                asprintf(&fs_size, "%d", FSSIZE);
-               (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*/
@@ -1475,12 +1469,12 @@
 
        (void)freopen(_PATH_CONSOLE, "a", stderr);
 
-       warnx("Creating mfs /dev (%d blocks, %d inodes)", FSSIZE, NINODE);
+       warnx("Creating tmpfs /dev (%d bytes, %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 */


Home | Main Index | Thread Index | Old Index