diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-29 11:01:42 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-29 11:01:42 +0000 |
commit | 4bc5a2dda3322237aff9d99c18e2080f78559ba4 (patch) | |
tree | f98b313f289088a0f9384387c68ec7516031cc7e /usr.sbin/sade | |
parent | 56df30b7c63bbeceb73f75bc2eb45c0e1c271e5e (diff) | |
download | FreeBSD-src-4bc5a2dda3322237aff9d99c18e2080f78559ba4.zip FreeBSD-src-4bc5a2dda3322237aff9d99c18e2080f78559ba4.tar.gz |
Sync up my work for the night. This should implement ALL possible
installation methods and provide a fairly robust set of menu options.
This should also fix a few more bugs on Poul-Henning's latest gripe
list.
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r-- | usr.sbin/sade/command.c | 8 | ||||
-rw-r--r-- | usr.sbin/sade/config.c | 6 | ||||
-rw-r--r-- | usr.sbin/sade/devices.c | 19 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 24 | ||||
-rw-r--r-- | usr.sbin/sade/menus.c | 40 | ||||
-rw-r--r-- | usr.sbin/sade/misc.c | 12 | ||||
-rw-r--r-- | usr.sbin/sade/msg.c | 25 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 18 | ||||
-rw-r--r-- | usr.sbin/sade/system.c | 92 |
9 files changed, 160 insertions, 84 deletions
diff --git a/usr.sbin/sade/command.c b/usr.sbin/sade/command.c index 1728964..57f6213 100644 --- a/usr.sbin/sade/command.c +++ b/usr.sbin/sade/command.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: command.c,v 1.8 1995/05/19 21:30:32 jkh Exp $ + * $Id: command.c,v 1.9 1995/05/20 13:24:33 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -167,14 +167,16 @@ command_execute(void) if (commandStack[i]->cmds[j].type == CMD_SHELL) { msgNotify("Doing %s", commandStack[i]->cmds[j].ptr); ret = vsystem((char *)commandStack[i]->cmds[j].ptr); - msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } else { /* It's a function pointer - call it with the key and the data */ func = (commandFunc)commandStack[i]->cmds[j].ptr; msgNotify("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data); ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data); - msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } } } diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index c791550..a51f996 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.11 1995/05/28 09:31:29 jkh Exp $ + * $Id: config.c,v 1.12 1995/05/28 20:28:07 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -174,7 +174,7 @@ configFstab(void) } /* Go for the burn */ - msgDebug("Generating /etc/fstab file"); + msgDebug("Generating /etc/fstab file\n"); for (i = 0; i < nchunks; i++) { fprintf(fstab, "/dev/%s\t\t\t%s\t\t%s %s %d %d\n", nameof(chunk_list[i]), mount_point(chunk_list[i]), fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), @@ -351,7 +351,7 @@ configPackages(char *str) i = (pid == -1) ? -1 : WEXITSTATUS(pstat); } } - if (i != 0) + if (i != 0 && isDebug()) msgDebug("pkg_manage returns status of %d\n", i); return 0; } diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c index 77dd090..48c10e4 100644 --- a/usr.sbin/sade/devices.c +++ b/usr.sbin/sade/devices.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: devices.c,v 1.32 1995/05/27 23:52:55 jkh Exp $ + * $Id: devices.c,v 1.33 1995/05/28 09:31:31 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,15 +183,28 @@ deviceGetAll(void) int i; for (i = 0; names[i]; i++) { + Chunk *c1; Disk *d; d = Open_Disk(names[i]); if (!d) msgFatal("Unable to open disk %s", names[i]); - (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, - mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d); + (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, NULL, d); msgDebug("Found a device of type disk named: %s\n", names[i]); + + /* Look for existing DOS partitions to register */ + for (c1 = d->chunks->part; c1; c1 = c1->next) { + if (c1->type == fat) { + Device *dev; + + /* Got one! */ + dev = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE, + mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL); + dev->private = c1; + msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); + } + } } free(names); } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 6f94a83..f501494 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.65 1995/05/28 23:12:05 jkh Exp $ + * $Id: install.c,v 1.66 1995/05/29 00:50:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -254,6 +254,10 @@ installCommit(char *str) fclose(fp); hostsModified = TRUE; } + /* If there's no kernel but there is a kernel.GENERIC, link it over */ + if (access("/kernel", R_OK)) + vsystem("ln -f /kernel.GENERIC /kernel"); + msgConfirm("Installation completed successfully.\nHit return now to go back to the main menu."); SystemWasInstalled = TRUE; return 0; @@ -379,7 +383,7 @@ copy_self(void) msgConfirm("Copy returned error status of %d!", i); /* Copy the /etc files into their rightful place */ - (void)vsystem("(cd /stand; find etc) | cpio -pdmv /mnt"); + (void)vsystem("cd /mnt/stand; find etc | cpio -pdmv /mnt"); } static void loop_on_root_floppy(); @@ -391,7 +395,7 @@ root_extract(void) if (OnCDROM) { fd = open("/floppies/root.flp", O_RDONLY); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); return; } if (mediaDevice) { @@ -408,7 +412,7 @@ root_extract(void) fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -416,12 +420,14 @@ root_extract(void) if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); } else { + msgConfirm("Couldn't get root floppy image from %s\n, falling back to floppy.", mediaDevice->name); if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); loop_on_root_floppy(); } break; + case DEVICE_TYPE_TAPE: case DEVICE_TYPE_FLOPPY: default: loop_on_root_floppy(); @@ -437,7 +443,11 @@ loop_on_root_floppy(void) { int fd; - fd = getRootFloppy(); - if (fd != -1) - mediaExtractDist("root.flp", "/", fd); + while (1) { + fd = getRootFloppy(); + if (fd != -1) { + mediaExtractDist("/", fd); + break; + } + } } diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c index 83b47c2..a2cd6c3 100644 --- a/usr.sbin/sade/menus.c +++ b/usr.sbin/sade/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.36 1995/05/28 23:12:07 jkh Exp $ + * $Id: menus.c,v 1.37 1995/05/29 01:43:17 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -302,12 +302,14 @@ method.", DMENU_CALL, mediaSetCDROM, 0, 0 }, { "DOS", "Install from a DOS partition", DMENU_CALL, mediaSetDOS, 0, 0 }, - { "File System", "Install from a UFS or NFS mounted distribution", - DMENU_CALL, mediaSetFS, 0, 0 }, + { "File System", "Install from a mounted filesystem", + DMENU_CALL, mediaSetUFS, 0, 0 }, { "Floppy", "Install from a floppy disk set", DMENU_CALL, mediaSetFloppy, 0, 0 }, { "FTP", "Install from an Internet FTP server", DMENU_CALL, mediaSetFTP, 0, 0 }, + { "NFS", "Install over NFS", + DMENU_CALL, mediaSetNFS, 0, 0 }, { "Tape", "Install from SCSI or QIC tape", DMENU_CALL, mediaSetTape, 0, 0 }, { NULL } }, @@ -642,7 +644,7 @@ When you're done, select Cancel", "Press F1 for more information on these options", "configure.hlp", { { "Add User", "Add users to the system", - DMENU_SYSTEM_COMMAND, "adduser", 0, 0 }, + DMENU_SYSTEM_COMMAND, "adduser -silent", 0, 0 }, { "Console", "Customize system console behavior", DMENU_SUBMENU, &MenuSyscons, 0, 0 }, { "Networking", "Configure additional network services", @@ -700,11 +702,11 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=canon.inria.fr", 0, 0 }, { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.uni-erlangen.de", 0, 0 }, - { "Germany", "ntps1-0.cs.tu-berlin.de (GPS)", + { "Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.cs.tu-berlin.de", 0, 0 }, { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.nc.fukuoka-u.ac.jp", 0, 0}, - { "Japan", "clock.tl.fukuoka-u.ac.jp (GPS clock)", + { "Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.tl.fukuoka-u.ac.jp", 0, 0}, { "Netherlands", "ntp0.nl.net (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=ntp0.nl.net", 0, 0 }, @@ -716,20 +718,20 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=swisstime.ethz.ch", 0, 0 }, { "U.S. East Coast", "bitsy.mit.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=bitsy.mit.edu", 0, 0 }, - { "U.S. East Coast", "otc1.psu.edu (WWV clock)", + { "U.S. East Coast #2", "otc1.psu.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=otc1.psu.edu", 0, 0 }, { "U.S. West Coast", "apple.com (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=apple.com", 0, 0 }, - { "U.S. West Coast", "clepsydra.dec.com (GOES clock)", + { "U.S. West Coast #2", "clepsydra.dec.com (GOES clock)", DMENU_SET_VARIABLE, "ntpdate=clepsydra.dec.com", 0, 0 }, - { "U.S. West Coast", "clock.llnl.gov (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, + { "U.S. West Coast #3", "clock.llnl.gov (WWVB clock)", + DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, { "U.S. Midwest", "ncar.ucar.edu (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, { "U.S. Pacific", "chantry.hawaii.net (WWV/H clock)", DMENU_SET_VARIABLE, "ntpdate=chantry.hawaii.net", 0, 0 }, { "U.S. Southwest", "shorty.chpc.utexas.edu (WWV clock)", - DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, { NULL } }, }; @@ -738,9 +740,9 @@ DMenu MenuSyscons = { "System Console Configuration", "The default system console driver for FreeBSD (syscons) has a\n\ number of configuration options which may be set according to\n\ -your preference. When you are done setting configuration options,\n\ -select Cancel.", - "Configure your screen saver settings", +your preference.\n\n\ +When you are done setting configuration options, select Cancel.", + "Configure your system console settings", NULL, { { "Keymap", "Choose an alternate keyboard map", DMENU_SUBMENU, &MenuSysconsKeymap, 0, 0 }, @@ -798,9 +800,9 @@ when held down.", NULL, { { "Slow", "Slow keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=slow", 0, 0 }, - { "Normal", "\"normal\" keyboard repeat rate", + { "Normal", "\"Normal\" keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=normal", 0, 0 }, - { "Fast", "fast keyboard repeat rate", + { "Fast", "Fast keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=fast", 0, 0 }, { "Default", "Use default keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=NO", 0, 0 }, @@ -818,11 +820,11 @@ probably enable one of these screen savers to prevent phosphor burn-in.", NULL, { { "blank", "Simply blank the screen", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, - { "Green", "\"green\" power saving mode (if supported by monitor)", + { "Green", "\"Green\" power saving mode (if supported by monitor)", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, { "Snake", "Draw a FreeBSD \"snake\" on your screen", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, - { "Star", "\"twinkling stars\" effect", + { "Star", "A \"twinkling stars\" effect", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, { "Timeout", "Set the screen saver timeout interval", DMENU_CALL, configSaverTimeout, 0, 0 }, diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c index a2ab20f..f1b8066 100644 --- a/usr.sbin/sade/misc.c +++ b/usr.sbin/sade/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.8 1995/05/23 18:06:15 jkh Exp $ + * $Id: misc.c,v 1.9 1995/05/25 01:22:19 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,7 +183,8 @@ Mkdir(char *ipath, void *data) return 0; path = strdup(ipath); - msgDebug("mkdir(%s)\n", path); + if (isDebug()) + msgDebug("mkdir(%s)\n", path); p = path; if (p[0] == '/') /* Skip leading '/'. */ ++p; @@ -198,7 +199,8 @@ Mkdir(char *ipath, void *data) msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); return 1; } - msgDebug("mkdir(%s..)\n", path); + if (isDebug()) + msgDebug("mkdir(%s..)\n", path); if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); return 1; @@ -231,7 +233,9 @@ Mount(char *mountp, void *dev) msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); return 1; } - msgDebug("mount %s %s\n", device, mountpoint); + if (isDebug()) + msgDebug("mount %s %s\n", device, mountpoint); + bzero(&ufsargs, sizeof(ufsargs)); ufsargs.fspec = device; if (mount(MOUNT_UFS, mountpoint, 0, (caddr_t)&ufsargs) == -1) { msgConfirm("Error mounting %s on %s : %s\n", device, mountpoint, strerror(errno)); diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c index e9b2ae6..5930d14 100644 --- a/usr.sbin/sade/msg.c +++ b/usr.sbin/sade/msg.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: msg.c,v 1.25 1995/05/29 00:50:04 jkh Exp $ + * $Id: msg.c,v 1.26 1995/05/29 01:43:18 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,6 +49,17 @@ #define VTY_STATLINE 24 #define TTY_STATLINE 23 +Boolean +isDebug(void) +{ + char *cp; + + cp = getenv("debug"); + if (cp && !strcmp(cp, "yes")) + return TRUE; + return FALSE; +} + /* Whack up an informational message on the status line, in stand-out */ void msgYap(char *fmt, ...) @@ -105,7 +116,8 @@ msgInfo(char *fmt, ...) move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79); refresh(); if (OnVTY) { - msgDebug("Information: `%s'\n", errstr); + if (isDebug()) + msgDebug("Information: `%s'\n", errstr); msgInfo(NULL); } free(errstr); @@ -130,7 +142,7 @@ msgWarn(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Warning message `%s'\n", errstr); free(errstr); } @@ -154,7 +166,7 @@ msgError(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Error message `%s'\n", errstr); free(errstr); } @@ -231,7 +243,8 @@ msgNotify(char *fmt, ...) va_end(args); use_helpline(NULL); use_helpfile(NULL); - msgDebug("Notify: %s\n", errstr); + if (isDebug()) + msgDebug("Notify: %s\n", errstr); dialog_clear(); dialog_msgbox("Information Dialog", errstr, -1, -1, 0); free(errstr); @@ -254,8 +267,8 @@ msgYesNo(char *fmt, ...) use_helpfile(NULL); w = dupwin(newscr); if (OnVTY) { + msgDebug("Switching back to VTY 0\n"); ioctl(0, VT_RELDISP, 1); /* Switch back */ - msgDebug("User decision requested (type ALT-F1)\n"); msgInfo(NULL); } ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index a9466f0..42da9c4 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.38 1995/05/28 03:05:03 jkh Exp $ + * $Id: sysinstall.h,v 1.39 1995/05/28 09:31:39 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -160,6 +160,8 @@ typedef enum { DEVICE_TYPE_CDROM, DEVICE_TYPE_TAPE, DEVICE_TYPE_DOS, + DEVICE_TYPE_UFS, + DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, } DeviceType; @@ -378,10 +380,11 @@ extern int mediaSetFloppy(char *str); extern int mediaSetDOS(char *str); extern int mediaSetTape(char *str); extern int mediaSetFTP(char *str); -extern int mediaSetFS(char *str); +extern int mediaSetUFS(char *str); +extern int mediaSetNFS(char *str); extern Boolean mediaGetType(void); -extern Boolean mediaExtractDist(char *distname, char *dir, int fd); -extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDist(char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); @@ -403,6 +406,7 @@ extern int Mount(char *, void *data); extern int Mount_DOS(char *, void *data); /* msg.c */ +extern Boolean isDebug(void); extern void msgInfo(char *fmt, ...); extern void msgYap(char *fmt, ...); extern void msgWarn(char *fmt, ...); @@ -420,6 +424,11 @@ extern Boolean mediaInitNetwork(Device *dev); extern void mediaShutdownNetwork(Device *dev); extern int configRoutedFlags(char *str); +/* nfs.c */ +extern Boolean mediaInitNFS(Device *dev); +extern int mediaGetNFS(char *file); +extern void mediaShutdownNFS(Device *dev); + /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); @@ -448,6 +457,7 @@ extern int tcpDeviceSelect(char *str); extern int set_termcap(void); /* ufs.c */ +extern void mediaShutdownUFS(Device *dev); extern Boolean mediaInitUFS(Device *dev); extern int mediaGetUFS(char *file); diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index 6aaea42..2e55385 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.40 1995/05/29 00:50:05 jkh Exp $ + * $Id: system.c,v 1.41 1995/05/29 02:13:31 phk Exp $ * * Jordan Hubbard * @@ -102,10 +102,8 @@ systemShutdown(void) } /* REALLY exit! */ if (RunningAsInit) { - int fd, on = 1; - /* Put the console back */ - ioctl(0, VT_RELDISP, 1); + ioctl(DebugFD, VT_RELDISP, 1); reboot(RB_HALT); } else @@ -187,7 +185,6 @@ systemDisplayFile(char *file) use_helpline(NULL); w = dupwin(newscr); dialog_textbox(file, fname, LINES, COLS); - unlink(fname); touchwin(w); wrefresh(w); delwin(w); @@ -199,24 +196,45 @@ char * systemHelpFile(char *file, char *buf) { char *cp; + static char oldfile[64]; /* Should be FILENAME_MAX but I don't feel like wasting that much space */ if (!file) return NULL; if ((cp = getenv("LANG")) != NULL) { snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } } /* Fall back to normal imperialistic mode :-) */ cp = "en_US.ISO8859-1"; snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } return NULL; } @@ -290,11 +308,14 @@ vsystem(char *fmt, ...) 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++; + if (strchr(cmd, *p)) + magic++; omask = sigblock(sigmask(SIGCHLD)); - msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); + if (isDebug()) + msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); switch(pid = fork()) { case -1: /* error */ (void)sigsetmask(omask); @@ -303,7 +324,7 @@ vsystem(char *fmt, ...) case 0: /* child */ (void)sigsetmask(omask); if (DebugFD != -1) { - if (OnVTY) + if (OnVTY && isDebug()) msgInfo("Command output is on debugging screen - type ALT-F2 to see it"); dup2(DebugFD, 0); dup2(DebugFD, 1); @@ -311,29 +332,29 @@ vsystem(char *fmt, ...) } #ifdef NOT_A_GOOD_IDEA_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)); + 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); + 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); @@ -347,7 +368,8 @@ vsystem(char *fmt, ...) (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); i = (pid == -1) ? -1 : WEXITSTATUS(pstat); - msgDebug("Command `%s' returns status of %d\n", cmd, i); + if (isDebug()) + msgDebug("Command `%s' returns status of %d\n", cmd, i); free(cmd); return i; } |