summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade/install.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-12-03 22:25:47 +0000
committerrwatson <rwatson@FreeBSD.org>2002-12-03 22:25:47 +0000
commit7df36e7050d668954254dfbc385eabcb706e1e34 (patch)
treea476abe9eff91a0f04e8f6b23f1bca03960ea984 /usr.sbin/sade/install.c
parent1d704c21dc2b4a5dac9c13d406a91876f3c63e70 (diff)
downloadFreeBSD-src-7df36e7050d668954254dfbc385eabcb706e1e34.zip
FreeBSD-src-7df36e7050d668954254dfbc385eabcb706e1e34.tar.gz
Reformulate how sysinstall handles file system options in the label
editor, in order to support specifying UFS2 as a newfs option. (1) Support three different newfs types: NEWFS_UFS, NEWFS_MSDOS, and NEWFS_CUSTOM. Don't mix up the arguments to them: you can't use soft updates on an msdos file system. (2) Distinguish adding new arguments to the newfs command line from replacing it. Permit the addition of new arguments by the user for NEWFS_UFS. If we entirely replace the command line provided by sysinstall, call it NEWFS_CUSTOM. 'N' will now add additional arguments; 'Z' will opt to replace the newfs command line entirely, but will prompt the user with their current command line as a starting point. (3) Construct the newfs command line dynamically based on the options provided by the user at label-time. Right now, this means selecting UFS1 vs. UFS2, and the soft updates flag. Drop in some variables to support ACLs and MAC Multilabel in the future also, but don't expose them now. This provides sysinstall with the ability to do more "in band" editing of the newfs command line, so we can provide more support for the user, but doesn't sacrifice the ability to entirely specify the newfs command line of the user is willing to give up on the cushiness factor. It also makes it easier for us to specify defaults in the future, and define conditional behavior based on user configuration selections. For now, we default to UFS1, and permit UFS2 to be used as the root only on non-i386 systems. While I was there, I dropped the default fragment and block sizes, since newfs has much more sensible defaults now. Reviewed by: jhb, marcel Approved by: re ia64 bits from: marcel
Diffstat (limited to 'usr.sbin/sade/install.c')
-rw-r--r--usr.sbin/sade/install.c91
1 files changed, 78 insertions, 13 deletions
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c
index 9862e56..e1763ec 100644
--- a/usr.sbin/sade/install.c
+++ b/usr.sbin/sade/install.c
@@ -50,6 +50,7 @@
#undef MSDOSFS
#include <sys/stat.h>
#include <sys/sysctl.h>
+#include <limits.h>
#include <unistd.h>
#include <termios.h>
@@ -878,6 +879,44 @@ installFixupXFree(dialogMenuItem *self)
return DITEM_SUCCESS | DITEM_RESTORE;
}
+#define QUEUE_YES 1
+#define QUEUE_NO 0
+static int
+performNewfs(PartInfo *pi, char *dname, int queue)
+{
+ char buffer[LINE_MAX];
+
+ if (pi->do_newfs) {
+ switch(pi->newfs_type) {
+ case NEWFS_UFS:
+ snprintf(buffer, LINE_MAX, "%s %s %s %s %s",
+ NEWFS_UFS_CMD,
+ pi->newfs_data.newfs_ufs.softupdates ? "-U" : "",
+ pi->newfs_data.newfs_ufs.ufs2 ? "-O2" : "-O1",
+ pi->newfs_data.newfs_ufs.user_options,
+ dname);
+ break;
+
+ case NEWFS_MSDOS:
+ snprintf(buffer, LINE_MAX, "%s %s", NEWFS_MSDOS_CMD,
+ dname);
+ break;
+
+ case NEWFS_CUSTOM:
+ snprintf(buffer, LINE_MAX, "%s %s",
+ pi->newfs_data.newfs_custom.command, dname);
+ break;
+ }
+
+ if (queue == QUEUE_YES) {
+ command_shell_add(pi->mountpoint, buffer);
+ return (0);
+ } else
+ return (vsystem(buffer));
+ }
+ return (0);
+}
+
/* Go newfs and/or mount all the filesystems we've been asked to */
int
installFilesystems(dialogMenuItem *self)
@@ -940,12 +979,14 @@ installFilesystems(dialogMenuItem *self)
if (strcmp(root->mountpoint, "/"))
msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint);
- if (root->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs the root partition?"))) {
+ if (root->do_newfs && (!upgrade ||
+ !msgNoYes("You are upgrading - are you SURE you want to newfs "
+ "the root partition?"))) {
int i;
dialog_clear_norefresh();
msgNotify("Making a new root filesystem on %s", dname);
- i = vsystem("%s %s", root->newfs_cmd, dname);
+ i = performNewfs(root, dname, QUEUE_NO);
if (i) {
msgConfirm("Unable to make new root filesystem on %s!\n"
"Command returned status %d", dname, i);
@@ -964,10 +1005,17 @@ installFilesystems(dialogMenuItem *self)
msgConfirm("Warning: fsck returned status of %d for %s.\n"
"This partition may be unsafe to use.", i, dname);
}
- if (root->soft) {
- i = vsystem("tunefs -n enable %s", dname);
- if (i)
- msgConfirm("Warning: Unable to enable softupdates for root filesystem on %s", dname);
+
+ /*
+ * If soft updates was enabled in the editor but we didn't newfs,
+ * use tunefs to update the soft updates flag on the file system.
+ */
+ if (!root->do_newfs && root->newfs_type == NEWFS_UFS &&
+ root->newfs_data.newfs_ufs.softupdates) {
+ i = vsystem("tunefs -n enable %s", dname);
+ if (i)
+ msgConfirm("Warning: Unable to enable soft updates"
+ " for root file system on %s", dname);
}
/* Switch to block device */
@@ -1021,12 +1069,23 @@ installFilesystems(dialogMenuItem *self)
if (c2 == rootdev)
continue;
- if (tmp->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name)))
- command_shell_add(tmp->mountpoint, "%s %s/dev/%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name);
+ sprintf(dname, "%s/dev/%s",
+ RunningAsInit ? "/mnt" : "", c2->name);
+
+ if (tmp->do_newfs && (!upgrade ||
+ !msgNoYes("You are upgrading - are you SURE you"
+ " want to newfs /dev/%s?", c2->name)))
+ performNewfs(tmp, dname, QUEUE_YES);
else
- command_shell_add(tmp->mountpoint, "fsck_ffs -y %s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
+ command_shell_add(tmp->mountpoint,
+ "fsck_ffs -y %s/dev/%s", RunningAsInit ?
+ "/mnt" : "", c2->name);
+#if 0
if (tmp->soft)
- command_shell_add(tmp->mountpoint, "tunefs -n enable %s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
+ command_shell_add(tmp->mountpoint,
+ "tunefs -n enable %s/dev/%s", RunningAsInit ?
+ "/mnt" : "", c2->name);
+#endif
command_func_add(tmp->mountpoint, Mount, c2->name);
}
else if (c2->type == part && c2->subtype == FS_SWAP) {
@@ -1047,7 +1106,8 @@ installFilesystems(dialogMenuItem *self)
}
}
}
- else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) {
+ else if (c1->type == fat && c1->private_data &&
+ (root->do_newfs || upgrade)) {
char name[FILENAME_MAX];
sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint);
@@ -1059,8 +1119,13 @@ installFilesystems(dialogMenuItem *self)
PartInfo *pi = (PartInfo *)c1->private_data;
char *p;
- if (pi->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs /dev/%s?", c1->name)))
- command_shell_add(pi->mountpoint, "%s %s/dev/%s", pi->newfs_cmd, RunningAsInit ? "/mnt" : "", c1->name);
+ sprintf(dname, "%s/dev/%s", RunningAsInit ? "/mnt" : "",
+ c1->name);
+
+ if (pi->do_newfs && (!upgrade ||
+ !msgNoYes("You are upgrading - are you SURE you want to "
+ "newfs /dev/%s?", c1->name)))
+ performNewfs(pi, dname, QUEUE_YES);
command_func_add(pi->mountpoint, Mount_msdosfs, c1->name);
OpenPOWER on IntegriCloud