summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall/system.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-05-21 01:56:03 +0000
committerphk <phk@FreeBSD.org>1995-05-21 01:56:03 +0000
commitb5bcdbe42d1517e353cf09a0d1a8f71dee1e0129 (patch)
treec025e5f4e78178a6d1cb37ffc7e4735933f97f28 /usr.sbin/sysinstall/system.c
parent54abfae1de08bdacfb9127084986b7225f9345d9 (diff)
downloadFreeBSD-src-b5bcdbe42d1517e353cf09a0d1a8f71dee1e0129.zip
FreeBSD-src-b5bcdbe42d1517e353cf09a0d1a8f71dee1e0129.tar.gz
Make newfs options work on rootfs.
Add size argument to new_part, so it can come up with a good default for newfs. Fix (possibly) a dialog botch after label.c's wizard mode. Make vsystem even smarter abour crunched binaries (what a speedup!) (You need to recompile crunchgen !)
Diffstat (limited to 'usr.sbin/sysinstall/system.c')
-rw-r--r--usr.sbin/sysinstall/system.c89
1 files changed, 35 insertions, 54 deletions
diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c
index 4bdc8ca..3a75e9d 100644
--- a/usr.sbin/sysinstall/system.c
+++ b/usr.sbin/sysinstall/system.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: system.c,v 1.23 1995/05/20 19:12:13 phk Exp $
+ * $Id: system.c,v 1.25 1995/05/20 23:33:14 phk Exp $
*
* Jordan Hubbard
*
@@ -279,22 +279,24 @@ systemChangeScreenmap(const u_char newmap[])
int
vsystem(char *fmt, ...)
{
-#ifdef CRUNCHED_BINARY
va_list args;
union wait pstat;
pid_t pid;
int omask;
sig_t intsave, quitsave;
- char *cmd,*argv[100];
- int i;
+ char *cmd,*p;
+ int i,magic=0;
cmd = (char *)malloc(FILENAME_MAX);
cmd[0] = '\0';
va_start(args, fmt);
vsnprintf(cmd, FILENAME_MAX, fmt, args);
va_end(args);
+ /* Find out if this command needs the wizardry of the shell */
+ for (p="<>|'`=\"()" ; *p; p++)
+ if (strchr(cmd,*p)) magic++;
omask = sigblock(sigmask(SIGCHLD));
- msgDebug("Executing command `%s'\n", cmd);
+ msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic);
switch(pid = fork()) {
case -1: /* error */
(void)sigsetmask(omask);
@@ -309,56 +311,36 @@ vsystem(char *fmt, ...)
dup2(DebugFD, 1);
dup2(DebugFD, 2);
}
- i = 0;
- argv[i++] = "crunch";
- argv[i++] = "sh";
- argv[i++] = "-c";
- argv[i++] = cmd;
- argv[i] = 0;
- exit(crunched_main(i,argv));
- }
- intsave = signal(SIGINT, SIG_IGN);
- quitsave = signal(SIGQUIT, SIG_IGN);
- pid = waitpid(pid, (int *)&pstat, 0);
- (void)sigsetmask(omask);
- (void)signal(SIGINT, intsave);
- (void)signal(SIGQUIT, quitsave);
- i = (pid == -1) ? -1 : pstat.w_status;
- msgDebug("Command `%s' returns status of %d\n", cmd, i);
- free(cmd);
- return i;
-#else /* Not crunched */
- va_list args;
- union wait pstat;
- pid_t pid;
- int omask;
- sig_t intsave, quitsave;
- char *cmd;
- int i;
-
- cmd = (char *)malloc(FILENAME_MAX);
- cmd[0] = '\0';
- va_start(args, fmt);
- vsnprintf(cmd, FILENAME_MAX, fmt, args);
- va_end(args);
- omask = sigblock(sigmask(SIGCHLD));
- msgDebug("Executing command `%s'\n", cmd);
- switch(pid = vfork()) {
- case -1: /* error */
- (void)sigsetmask(omask);
- i = 127;
-
- case 0: /* child */
- (void)sigsetmask(omask);
- if (DebugFD != -1) {
- if (OnVTY)
- msgInfo("Command output is on debugging screen - type ALT-F2 to see it");
- dup2(DebugFD, 0);
- dup2(DebugFD, 1);
- dup2(DebugFD, 2);
+#ifdef CRUNCHED_BINARY
+ if (magic) {
+ char *argv[100];
+ i = 0;
+ argv[i++] = "crunch";
+ argv[i++] = "sh";
+ argv[i++] = "-c";
+ argv[i++] = cmd;
+ argv[i] = 0;
+ exit(crunched_main(i,argv));
+ } else {
+ char *argv[100];
+ i = 0;
+ argv[i++] = "crunch";
+ while (cmd && *cmd) {
+ argv[i] = strsep(&cmd," \t");
+ if (*argv[i])
+ i++;
+ }
+ argv[i] = 0;
+ if (crunched_here(argv[1]))
+ exit(crunched_main(i,argv));
+ else
+ execvp(argv[1],argv+1);
+ kill(getpid(),9);
}
+#else /* !CRUNCHED_BINARY */
execl("/stand/sh", "sh", "-c", cmd, (char *)NULL);
- i = 127;
+ kill(getpid(),9);
+#endif /* CRUNCHED_BINARY */
}
intsave = signal(SIGINT, SIG_IGN);
quitsave = signal(SIGQUIT, SIG_IGN);
@@ -370,5 +352,4 @@ vsystem(char *fmt, ...)
msgDebug("Command `%s' returns status of %d\n", cmd, i);
free(cmd);
return i;
-#endif
}
OpenPOWER on IntegriCloud