Better handling of PFS within in HAMMER part of the installer.
authorMatthias Schmidt <matthias@dragonflybsd.org>
Fri, 9 Jan 2009 18:10:33 +0000 (19:10 +0100)
committerMatthias Schmidt <matthias@dragonflybsd.org>
Tue, 13 Jan 2009 17:58:29 +0000 (18:58 +0100)
contrib/bsdinstaller-1.1.6/src/backend/installer/fn_install.c
share/installer/cmdnames.conf

index 62dfe43..f2ffead 100644 (file)
 #include "pathnames.h"
 #include "fn.h"
 
-static const char *pfs_mountpt[5] = {"/var", "/tmp", "/usr", "/home", NULL};
+static const char *pfs_mountpt[8] = {"/var", "/tmp", "/usr", "/home",
+       "/usr/obj", "/var/crash", "/var/tmp", NULL};
+
+static const int pfs_nohistory[8] = {0, 0, 0, 0, 1, 1, 1};
+
+static void
+handle_pfs(struct i_fn_args *a, struct commands *cmds)
+{
+       int j;
+
+       /*
+        * Create PFS root directory.
+        */
+       command_add(cmds, "%s%s -p %smnt/pfs",
+           a->os_root, cmd_name(a, "MKDIR"),
+           a->os_root);
+
+       for (j = 0; pfs_mountpt[j] != NULL; j++) {
+               /*
+                * We have a PFS for a subdirectory, e.g. /var/crash, so we
+                * need to create /pfs/var.crash
+                */
+               if (rindex(pfs_mountpt[j]+1, '/') != NULL) {
+                       command_add(cmds, "%s%s pfs-master %smnt/pfs%s.%s",
+                           a->os_root, cmd_name(a, "HAMMER"),
+                           a->os_root, dirname(pfs_mountpt[j]),
+                           basename(pfs_mountpt[j]));
+                       command_add(cmds, "%s%s -p %smnt%s",
+                           a->os_root, cmd_name(a, "MKDIR"),
+                           a->os_root, pfs_mountpt[j]);
+                       command_add(cmds, "%s%s %smnt/pfs%s.%s %smnt%s",
+                           a->os_root, cmd_name(a, "MOUNT_NULL"),
+                           a->os_root, dirname(pfs_mountpt[j]),
+                           basename(pfs_mountpt[j]),
+                           a->os_root, pfs_mountpt[j]);
+                       if (pfs_nohistory[j] == 1)
+                               command_add(cmds, "%s%s nohistory %smnt%s",
+                                   a->os_root, cmd_name(a, "CHFLAGS"),
+                                   a->os_root, pfs_mountpt[j]);
+               }
+               else {
+                       command_add(cmds, "%s%s pfs-master %smnt/pfs%s",
+                           a->os_root, cmd_name(a, "HAMMER"),
+                           a->os_root, pfs_mountpt[j]);
+                       command_add(cmds, "%s%s -p %smnt%s",
+                           a->os_root, cmd_name(a, "MKDIR"),
+                           a->os_root, pfs_mountpt[j]);
+                       command_add(cmds, "%s%s %smnt/pfs%s %smnt%s",
+                           a->os_root, cmd_name(a, "MOUNT_NULL"),
+                           a->os_root, pfs_mountpt[j],
+                           a->os_root, pfs_mountpt[j]);
+               }
+       }
+}
 
 /*
  * fn_install_os: actually put DragonFly on a disk.
@@ -236,26 +289,11 @@ fn_install_os(struct i_fn_args *a)
                }
        }
 
-       if (use_hammer == 1) {
-               /* Create PFS dir */
-               command_add(cmds, "%s%s -p %smnt/pfs",
-                   a->os_root, cmd_name(a, "MKDIR"),
-                   a->os_root);
-
-               /* mount null pfs */
-               for (j = 0; pfs_mountpt[j] != NULL; j++) {
-                       command_add(cmds, "%s%s pfs-master %smnt/pfs%s",
-                           a->os_root, cmd_name(a, "HAMMER"),
-                           a->os_root, pfs_mountpt[j]);
-                       command_add(cmds, "%s%s -p %smnt%s",
-                           a->os_root, cmd_name(a, "MKDIR"),
-                           a->os_root, pfs_mountpt[j]);
-                       command_add(cmds, "%s%s %smnt/pfs%s %smnt%s",
-                           a->os_root, cmd_name(a, "MOUNT_NULL"),
-                           a->os_root, pfs_mountpt[j],
-                           a->os_root, pfs_mountpt[j]);
-               }
-       }
+       /*
+        * Take care of HAMMER PFS.
+        */
+       if (use_hammer == 1)
+               handle_pfs(a, cmds);
 
        /*
         * Actually copy files now.
@@ -550,13 +588,25 @@ fn_install_os(struct i_fn_args *a)
                        }
                }
        }
+
+       /*
+        * Take care of HAMMER PFS null mounts.
+        */
        if (use_hammer == 1) {
                for (j = 0; pfs_mountpt[j] != NULL; j++) {
-                       command_add(cmds, "%s%s '/pfs%s\t\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
-                           a->os_root, cmd_name(a, "ECHO"),
-                           pfs_mountpt[j],
-                           pfs_mountpt[j],
-                           a->os_root);
+                       if (rindex(pfs_mountpt[j]+1, '/') != NULL)
+                               command_add(cmds, "%s%s '/pfs%s.%s\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
+                                   a->os_root, cmd_name(a, "ECHO"),
+                                   dirname(pfs_mountpt[j]),
+                                   basename(pfs_mountpt[j]),
+                                   pfs_mountpt[j],
+                                   a->os_root);
+                       else
+                               command_add(cmds, "%s%s '/pfs%s\t\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
+                                   a->os_root, cmd_name(a, "ECHO"),
+                                   pfs_mountpt[j],
+                                   pfs_mountpt[j],
+                                   a->os_root);
                }
        }
 
index d285d2b..2702d45 100644 (file)
@@ -23,6 +23,7 @@ RM=bin/rm
 SH=bin/sh
 TEST=bin/test
 
+CHFLAGS=usr/bin/chflags
 DHCLIENT=sbin/dhclient
 DISKLABEL64=sbin/disklabel64
 DISKLABEL=sbin/disklabel