summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall/system.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1997-07-31 11:08:47 +0000
committerjkh <jkh@FreeBSD.org>1997-07-31 11:08:47 +0000
commit0c6d177de60f3da08196544c58ec36b1e34c2e84 (patch)
treeb456c51cea6c5b05810342463733621e0d601c02 /usr.sbin/sysinstall/system.c
parentd9570c1f69e582d758470f6f2dd312d1458a7bef (diff)
downloadFreeBSD-src-0c6d177de60f3da08196544c58ec36b1e34c2e84.zip
FreeBSD-src-0c6d177de60f3da08196544c58ec36b1e34c2e84.tar.gz
Make serial console based installs actually work by:
1. Detecting the split /dev/ttyv0 / /dev/console case, e.g. you've booted with the -h flag and you have a VGA card also. 2. Adding an extra "menu" for selecting terminal type and adding ANSI to the list of compiled-in terms. 3. Opening the proper file descriptors before disowning ourselves. Requested by: pst
Diffstat (limited to 'usr.sbin/sysinstall/system.c')
-rw-r--r--usr.sbin/sysinstall/system.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c
index 22a7052..61a27c4e 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.80 1997/04/28 10:31:14 jkh Exp $
+ * $Id: system.c,v 1.81 1997/05/27 18:56:03 jkh Exp $
*
* Jordan Hubbard
*
@@ -69,16 +69,37 @@ systemInitialize(int argc, char **argv)
/* Are we running as init? */
if (getpid() == 1) {
+ int fd, type;
+
+ RunningAsInit = 1;
setsid();
close(0);
- if (open("/dev/ttyv0", O_RDWR) < 0)
- open("/dev/console", O_RDWR);
+ fd = open("/dev/ttyv0", O_RDWR);
+ if (fd == -1)
+ fd = open("/dev/console", O_RDWR); /* fallback */
else
OnVTY = TRUE;
+ /*
+ * To make _sure_ we're on a VTY and don't have /dev/console switched
+ * away to a serial port or something, attempt to set the cursor appearance.
+ */
+ type = 0; /* normal */
+ if (OnVTY) {
+ int fd2;
+
+ if ((fd2 = open("/dev/console", O_RDWR)) != -1) {
+ if (ioctl(fd2, CONS_CURSORTYPE, &type) == -1) {
+ OnVTY = FALSE;
+ close(fd); close(fd2);
+ open("/dev/console", O_RDWR);
+ }
+ else
+ close(fd2);
+ }
+ }
close(1); dup(0);
close(2); dup(0);
- printf("%s running as init\n", argv[0]);
- RunningAsInit = 1;
+ printf("%s running as init on %s\n", argv[0], OnVTY ? "vty0" : "serial console");
i = ioctl(0, TIOCSCTTY, (char *)NULL);
setlogin("root");
setenv("PATH", "/stand:/bin:/sbin:/usr/sbin:/usr/bin:/mnt/bin:/mnt/sbin:/mnt/usr/sbin:/mnt/usr/bin:/usr/X11R6/bin", 1);
OpenPOWER on IntegriCloud