Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Jul 2000 14:36:51 -0700 (PDT)
From:      ambrisko@whistle.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   misc/19837: Run Fit it floppy from serial port
Message-ID:  <200007102136.OAA16146@whistle.com>

next in thread | raw e-mail | index | archive | help

>Number:         19837
>Category:       misc
>Synopsis:       Run Fit it floppy from serial port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 10 14:50:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Doug Ambrisko
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Whistle/IBM
>Environment:
The FixIt floppy doesn't work with a serial console since you can't
switch vty's.  So we have to do something else.

>Description:

>How-To-Repeat:
Try to use FixIt floppy from a serial port.  It will say switch to vtyx
which it can't do.

>Fix:

This patch comes from Joerg Wunsch (joerg_wunsch@uriah.heep.sax.de)
with some fixes/enhancements and testing by myself.  It exits
libdialog, spawns the shell as needed.  When the shell is exited
it then re-starts libdialog and continues.  It gets tricky due to the
forked shell.

Index: install.c
===================================================================
RCS file: /cvs/freebsd/src/release/sysinstall/install.c,v
retrieving revision 1.274
diff -c -r1.274 install.c
*** install.c	2000/05/31 00:57:48	1.274
--- install.c	2000/07/10 21:25:20
***************
*** 56,61 ****
--- 56,62 ----
   * Used by package.c
   */
  int _interactiveHack;
+ int FixItMode = 0;
  
  static void	create_termcap(void);
  static void	fixit_common(void);
***************
*** 248,255 ****
--- 249,258 ----
  int
  installFixitHoloShell(dialogMenuItem *self)
  {
+     FixItMode = 1;
      systemCreateHoloshell();
      return DITEM_SUCCESS;
+     FixItMode = 0;
  }
  
  int
***************
*** 397,402 ****
--- 400,407 ----
  	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;
Index: sysinstall.h
===================================================================
RCS file: /cvs/freebsd/src/release/sysinstall/sysinstall.h,v
retrieving revision 1.190
diff -c -r1.190 sysinstall.h
*** sysinstall.h	2000/06/05 13:17:23	1.190
--- sysinstall.h	2000/07/10 21:25:20
***************
*** 398,403 ****
--- 398,404 ----
  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);
***************
*** 707,712 ****
--- 708,715 ----
  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[]);
Index: system.c
===================================================================
RCS file: /cvs/freebsd/src/release/sysinstall/system.c,v
retrieving revision 1.104
diff -c -r1.104 system.c
*** system.c	2000/03/25 04:23:08	1.104
--- system.c	2000/07/10 21:25:20
***************
*** 217,222 ****
--- 217,244 ----
      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,361 ****
  void
  systemCreateHoloshell(void)
  {
!     if (OnVTY && RunningAsInit) {
  
  	if (ehs_pid != 0) {
  	    int pstat;
--- 377,385 ----
  void
  systemCreateHoloshell(void)
  {
!     int waitstatus;
! 
!     if ((FixItMode || OnVTY) && RunningAsInit) {
  
  	if (ehs_pid != 0) {
  	    int pstat;
***************
*** 377,382 ****
--- 401,408 ----
  	    (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,391 ****
  	    ioctl(0, TIOCNOTTY, NULL);
  	    for (i = getdtablesize(); i >= 0; --i)
  		close(i);
! 	    fd = open("/dev/ttyv3", O_RDWR);
  	    ioctl(0, TIOCSCTTY, &fd);
  	    dup2(0, 1);
  	    dup2(0, 2);
--- 411,420 ----
  	    ioctl(0, TIOCNOTTY, NULL);
  	    for (i = getdtablesize(); i >= 0; --i)
  		close(i);
! 	    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,415 ****
  	    }
  	    else
  		msgDebug("Doctor: I'm unable to get the terminal attributes!\n");
  	    execlp("sh", "-sh", 0);
  	    msgDebug("Was unable to execute sh for Holographic shell!\n");
  	    exit(1);
  	}
  	else {
! 	    WINDOW *w = savescr();
  
! 	    msgNotify("Starting an emergency holographic shell on VTY4");
! 	    sleep(2);
! 	    restorescr(w);
  	}
      }
  }
--- 429,454 ----
  	    }
  	    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 {
! 	    if (OnVTY) {
! 	        WINDOW *w = savescr();
  
! 	        msgNotify("Starting an emergency holographic shell on VTY4");
! 	        sleep(2);
! 	        restorescr(w);
! 	    }
! 	    if (!OnVTY){
! 	        (void)waitpid(ehs_pid, &waitstatus, 0);
! 	        systemResumeDialog();
! 	    }
  	}
      }
  }

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007102136.OAA16146>