diff options
author | obrien <obrien@FreeBSD.org> | 2000-07-18 09:14:06 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2000-07-18 09:14:06 +0000 |
commit | 1edbe25abe98370f9a5ed50bc0727205228878bf (patch) | |
tree | be84b7c280952ca644ac2b3fc65f818bbcf754cf /usr.sbin/sysinstall | |
parent | 5aef58d7b9d8523da7d5c51472067b91b09bd239 (diff) | |
download | FreeBSD-src-1edbe25abe98370f9a5ed50bc0727205228878bf.zip FreeBSD-src-1edbe25abe98370f9a5ed50bc0727205228878bf.tar.gz |
Allow the Fix-it functionality to detect that we are on a serial console,
and DTRT rather than start the fixit shell on a non-existant vty.
PR: 19837
Submitted by: Doug Ambrisko <ambrisko@whistle.com>
Approved by: JKH
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r-- | usr.sbin/sysinstall/install.c | 5 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 3 | ||||
-rw-r--r-- | usr.sbin/sysinstall/system.c | 51 |
3 files changed, 53 insertions, 6 deletions
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index ac3b013..209c210 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -56,6 +56,7 @@ * Used by package.c */ int _interactiveHack; +int FixItMode = 0; static void create_termcap(void); static void fixit_common(void); @@ -248,8 +249,10 @@ installInitial(void) int installFixitHoloShell(dialogMenuItem *self) { + FixItMode = 1; systemCreateHoloshell(); return DITEM_SUCCESS; + FixItMode = 0; } int @@ -397,6 +400,8 @@ fixit_common(void) msgConfirm("Couldn't symlink the /etc/ files! I'm not sure I like this.."); if (!file_readable(TERMCAP_FILE)) create_termcap(); + if (!OnVTY) + systemSuspendDialog(); /* must be before the fork() */ if (!(child = fork())) { int i, fd, fdstop; struct termios foo; diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index e34735a..abb2b8e 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -402,6 +402,7 @@ extern DMenu MenuHTMLDoc; /* HTML Documentation menu */ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ extern DMenu MenuXF86Config; /* Select XFree86 configuration type */ +extern int FixItMode; /* FixItMode starts shell onc urrent device (ie Serial port) */ /* Stuff from libdialog which isn't properly declared outside */ extern void display_helpfile(void); @@ -711,6 +712,8 @@ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(int status); extern int execExecute(char *cmd, char *name); extern int systemExecute(char *cmd); +extern void systemSuspendDialog(void); +extern void systemResumeDialog(void); extern int systemDisplayHelp(char *file); extern char *systemHelpFile(char *file, char *buf); extern void systemChangeFont(const u_char font[]); diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index d0daba3..6010e7a 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -217,6 +217,28 @@ systemExecute(char *command) return status; } +/* suspend/resume libdialog/curses screen */ +static WINDOW *oldW; + +void +systemSuspendDialog(void) +{ + + oldW = savescr(); + dialog_clear(); + dialog_update(); + end_dialog(); + DialogActive = FALSE; +} + +void +systemResumeDialog(void) +{ + + DialogActive = TRUE; + restorescr(oldW); +} + /* Display a help file in a filebox */ int systemDisplayHelp(char *file) @@ -355,7 +377,9 @@ vsystem(char *fmt, ...) void systemCreateHoloshell(void) { - if (OnVTY && RunningAsInit) { + int waitstatus; + + if ((FixItMode || OnVTY) && RunningAsInit) { if (ehs_pid != 0) { int pstat; @@ -377,6 +401,8 @@ systemCreateHoloshell(void) (void) waitpid(ehs_pid, &pstat, WNOHANG); } + if (!OnVTY) + systemSuspendDialog(); /* must be before the fork() */ if ((ehs_pid = fork()) == 0) { int i, fd; struct termios foo; @@ -385,7 +411,10 @@ systemCreateHoloshell(void) ioctl(0, TIOCNOTTY, NULL); for (i = getdtablesize(); i >= 0; --i) close(i); - fd = open("/dev/ttyv3", O_RDWR); + if (OnVTY) + fd = open("/dev/ttyv3", O_RDWR); + else + fd = open("/dev/console", O_RDWR); ioctl(0, TIOCSCTTY, &fd); dup2(0, 1); dup2(0, 2); @@ -400,16 +429,26 @@ systemCreateHoloshell(void) } else msgDebug("Doctor: I'm unable to get the terminal attributes!\n"); + if (!OnVTY){ + printf("Type ``exit'' in this fixit shell to resume sysinstall.\n\n"); + fflush(stdout); + } execlp("sh", "-sh", 0); msgDebug("Was unable to execute sh for Holographic shell!\n"); exit(1); } else { - WINDOW *w = savescr(); + if (OnVTY) { + WINDOW *w = savescr(); - msgNotify("Starting an emergency holographic shell on VTY4"); - sleep(2); - restorescr(w); + msgNotify("Starting an emergency holographic shell on VTY4"); + sleep(2); + restorescr(w); + } + if (!OnVTY){ + (void)waitpid(ehs_pid, &waitstatus, 0); + systemResumeDialog(); + } } } } |