diff options
author | phk <phk@FreeBSD.org> | 1995-05-21 01:56:03 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-05-21 01:56:03 +0000 |
commit | b5bcdbe42d1517e353cf09a0d1a8f71dee1e0129 (patch) | |
tree | c025e5f4e78178a6d1cb37ffc7e4735933f97f28 | |
parent | 54abfae1de08bdacfb9127084986b7225f9345d9 (diff) | |
download | FreeBSD-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 !)
-rw-r--r-- | release/sysinstall/install.c | 4 | ||||
-rw-r--r-- | release/sysinstall/label.c | 17 | ||||
-rw-r--r-- | release/sysinstall/system.c | 89 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 4 | ||||
-rw-r--r-- | usr.sbin/sade/label.c | 17 | ||||
-rw-r--r-- | usr.sbin/sade/system.c | 89 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 4 | ||||
-rw-r--r-- | usr.sbin/sysinstall/label.c | 17 | ||||
-rw-r--r-- | usr.sbin/sysinstall/system.c | 89 |
9 files changed, 147 insertions, 183 deletions
diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index 03bea2b..ec1d092 100644 --- a/release/sysinstall/install.c +++ b/release/sysinstall/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.43 1995/05/20 20:30:08 jkh Exp $ + * $Id: install.c,v 1.44 1995/05/20 23:33:13 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -204,7 +204,7 @@ make_filesystems(void) sprintf(dname, "/dev/r%sa", disk->name); msgNotify("Making a new root filesystem on %s", dname); - i = vsystem("newfs %s", dname); + i = vsystem("%s %s", p->newfs_cmd,dname); if (i) { msgConfirm("Unable to make new root filesystem! Command returned status %d", i); return; diff --git a/release/sysinstall/label.c b/release/sysinstall/label.c index 3f1c18a..bd45853 100644 --- a/release/sysinstall/label.c +++ b/release/sysinstall/label.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: label.c,v 1.11 1995/05/20 10:33:04 jkh Exp $ + * $Id: label.c,v 1.12 1995/05/20 19:22:21 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -178,13 +178,19 @@ record_label_chunks() /* A new partition entry */ static PartInfo * -new_part(char *mpoint, Boolean newfs) +new_part(char *mpoint, Boolean newfs, u_long size) { PartInfo *ret; + u_long divisor; ret = (PartInfo *)safe_malloc(sizeof(PartInfo)); strncpy(ret->mountpoint, mpoint, FILENAME_MAX); strcpy(ret->newfs_cmd, "newfs"); + for(divisor = 4096 ; divisor > 17*4 ; divisor--) { + if (!(size % divisor)) { + sprintf(ret->newfs_cmd+strlen(ret->newfs_cmd)," -u %ld",divisor); + } + } ret->newfs = newfs; return ret; } @@ -217,7 +223,7 @@ get_mountpoint(struct chunk *old) else if (old) old->flags &= ~CHUNK_IS_ROOT; safe_free(old ? old->private : NULL); - tmp = new_part(val, TRUE); + tmp = new_part(val, TRUE, old->size); if (old) { old->private = tmp; old->private_free = safe_free; @@ -340,7 +346,8 @@ print_label_chunks(void) * Fill in a fake mountpoint and register it */ sprintf(foo, "/mnt%d", mnt++); - label_chunk_info[i].c->private = new_part(foo, FALSE); + label_chunk_info[i].c->private = + new_part(foo, FALSE,label_chunk_info[i].c->size); label_chunk_info[i].c->private_free = safe_free; } mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint; @@ -579,8 +586,8 @@ diskLabelEditor(char *str) if (devs[i]->enabled) slice_wizard(((Disk *)devs[i]->private)); } - dialog_clear(); DialogActive = TRUE; + dialog_clear(); record_label_chunks(); } else diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c index 4bdc8ca..3a75e9d 100644 --- a/release/sysinstall/system.c +++ b/release/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 } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 03bea2b..ec1d092 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.43 1995/05/20 20:30:08 jkh Exp $ + * $Id: install.c,v 1.44 1995/05/20 23:33:13 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -204,7 +204,7 @@ make_filesystems(void) sprintf(dname, "/dev/r%sa", disk->name); msgNotify("Making a new root filesystem on %s", dname); - i = vsystem("newfs %s", dname); + i = vsystem("%s %s", p->newfs_cmd,dname); if (i) { msgConfirm("Unable to make new root filesystem! Command returned status %d", i); return; diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c index 3f1c18a..bd45853 100644 --- a/usr.sbin/sade/label.c +++ b/usr.sbin/sade/label.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: label.c,v 1.11 1995/05/20 10:33:04 jkh Exp $ + * $Id: label.c,v 1.12 1995/05/20 19:22:21 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -178,13 +178,19 @@ record_label_chunks() /* A new partition entry */ static PartInfo * -new_part(char *mpoint, Boolean newfs) +new_part(char *mpoint, Boolean newfs, u_long size) { PartInfo *ret; + u_long divisor; ret = (PartInfo *)safe_malloc(sizeof(PartInfo)); strncpy(ret->mountpoint, mpoint, FILENAME_MAX); strcpy(ret->newfs_cmd, "newfs"); + for(divisor = 4096 ; divisor > 17*4 ; divisor--) { + if (!(size % divisor)) { + sprintf(ret->newfs_cmd+strlen(ret->newfs_cmd)," -u %ld",divisor); + } + } ret->newfs = newfs; return ret; } @@ -217,7 +223,7 @@ get_mountpoint(struct chunk *old) else if (old) old->flags &= ~CHUNK_IS_ROOT; safe_free(old ? old->private : NULL); - tmp = new_part(val, TRUE); + tmp = new_part(val, TRUE, old->size); if (old) { old->private = tmp; old->private_free = safe_free; @@ -340,7 +346,8 @@ print_label_chunks(void) * Fill in a fake mountpoint and register it */ sprintf(foo, "/mnt%d", mnt++); - label_chunk_info[i].c->private = new_part(foo, FALSE); + label_chunk_info[i].c->private = + new_part(foo, FALSE,label_chunk_info[i].c->size); label_chunk_info[i].c->private_free = safe_free; } mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint; @@ -579,8 +586,8 @@ diskLabelEditor(char *str) if (devs[i]->enabled) slice_wizard(((Disk *)devs[i]->private)); } - dialog_clear(); DialogActive = TRUE; + dialog_clear(); record_label_chunks(); } else diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index 4bdc8ca..3a75e9d 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/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 } diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index 03bea2b..ec1d092 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.43 1995/05/20 20:30:08 jkh Exp $ + * $Id: install.c,v 1.44 1995/05/20 23:33:13 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -204,7 +204,7 @@ make_filesystems(void) sprintf(dname, "/dev/r%sa", disk->name); msgNotify("Making a new root filesystem on %s", dname); - i = vsystem("newfs %s", dname); + i = vsystem("%s %s", p->newfs_cmd,dname); if (i) { msgConfirm("Unable to make new root filesystem! Command returned status %d", i); return; diff --git a/usr.sbin/sysinstall/label.c b/usr.sbin/sysinstall/label.c index 3f1c18a..bd45853 100644 --- a/usr.sbin/sysinstall/label.c +++ b/usr.sbin/sysinstall/label.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: label.c,v 1.11 1995/05/20 10:33:04 jkh Exp $ + * $Id: label.c,v 1.12 1995/05/20 19:22:21 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -178,13 +178,19 @@ record_label_chunks() /* A new partition entry */ static PartInfo * -new_part(char *mpoint, Boolean newfs) +new_part(char *mpoint, Boolean newfs, u_long size) { PartInfo *ret; + u_long divisor; ret = (PartInfo *)safe_malloc(sizeof(PartInfo)); strncpy(ret->mountpoint, mpoint, FILENAME_MAX); strcpy(ret->newfs_cmd, "newfs"); + for(divisor = 4096 ; divisor > 17*4 ; divisor--) { + if (!(size % divisor)) { + sprintf(ret->newfs_cmd+strlen(ret->newfs_cmd)," -u %ld",divisor); + } + } ret->newfs = newfs; return ret; } @@ -217,7 +223,7 @@ get_mountpoint(struct chunk *old) else if (old) old->flags &= ~CHUNK_IS_ROOT; safe_free(old ? old->private : NULL); - tmp = new_part(val, TRUE); + tmp = new_part(val, TRUE, old->size); if (old) { old->private = tmp; old->private_free = safe_free; @@ -340,7 +346,8 @@ print_label_chunks(void) * Fill in a fake mountpoint and register it */ sprintf(foo, "/mnt%d", mnt++); - label_chunk_info[i].c->private = new_part(foo, FALSE); + label_chunk_info[i].c->private = + new_part(foo, FALSE,label_chunk_info[i].c->size); label_chunk_info[i].c->private_free = safe_free; } mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint; @@ -579,8 +586,8 @@ diskLabelEditor(char *str) if (devs[i]->enabled) slice_wizard(((Disk *)devs[i]->private)); } - dialog_clear(); DialogActive = TRUE; + dialog_clear(); record_label_chunks(); } else 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 } |