diff options
author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-07-31 11:08:47 +0000 |
---|---|---|
committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-07-31 11:08:47 +0000 |
commit | b6aad04900158c760fe31cec2750fed3bd9dd78a (patch) | |
tree | b97c10c5eda517067266718333051a1cadfe3e04 /usr.sbin/sade/system.c | |
parent | ad8eb2f9de22c8a65fe6c1e987c134bf6b79f334 (diff) | |
download | src-b6aad04900158c760fe31cec2750fed3bd9dd78a.tar.gz src-b6aad04900158c760fe31cec2750fed3bd9dd78a.zip |
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
Notes
Notes:
svn path=/head/; revision=27798
Diffstat (limited to 'usr.sbin/sade/system.c')
-rw-r--r-- | usr.sbin/sade/system.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index 22a705299318..61a27c4ef294 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.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); |