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
This commit is contained in:
David E. O'Brien 2000-07-18 09:14:06 +00:00
parent 6a5be8627c
commit 7090abf525
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=63404
9 changed files with 159 additions and 18 deletions

View file

@ -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;

View file

@ -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[]);

View file

@ -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();
}
}
}
}

View file

@ -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;

View file

@ -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[]);

View file

@ -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();
}
}
}
}

View file

@ -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;

View file

@ -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[]);

View file

@ -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();
}
}
}
}