diff options
-rw-r--r-- | initscripts.spec | 5 | ||||
-rwxr-xr-x | rc.d/init.d/functions | 4 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 10 | ||||
-rw-r--r-- | src/Makefile | 4 | ||||
-rw-r--r-- | src/consoletype.1 | 28 | ||||
-rw-r--r-- | src/consoletype.c | 27 |
6 files changed, 73 insertions, 5 deletions
diff --git a/initscripts.spec b/initscripts.spec index 6ea0c53b..a5f21206 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -178,6 +178,7 @@ rm -rf $RPM_BUILD_ROOT /bin/ipcalc /bin/usleep %attr(4755,root,root) /usr/sbin/usernetctl +/sbin/consoletype /sbin/getkey /sbin/netreport /sbin/initlog @@ -194,6 +195,10 @@ rm -rf $RPM_BUILD_ROOT %ghost %attr(0664,root,utmp) /var/run/utmp %changelog +* Mon Oct 25 1999 Jakub Jelinek <jakub@redhat.com> +- fix check for serial console, don't use -C argument to fsck + on serial console. + * Mon Oct 18 1999 Bill Nottingham <notting@redhat.com> - do something useful with linuxconf 'any' static routes. diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 37b6ced7..18cdceef 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -31,8 +31,8 @@ if [ -z "$BOOTUP" ]; then SETCOLOR_NORMAL="echo -en \\033[0;39m" LOGLEVEL=1 fi - if [ -x /usr/bin/tty ]; then - if [ "`tty`" = "not a tty" ]; then + if [ -x /sbin/consoletype ]; then + if [ "`consoletype`" = "serial" ]; then BOOTUP=serial MOVE_TO_COL= SETCOLOR_SUCCESS= diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index eae3f79f..2726d2a8 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -168,11 +168,17 @@ if [ -f /forcefsck ]; then fsckoptions="-f $fsckoptions" fi +if [ "$BOOTUP" != "serial" ]; then + fsckoptions="-C $fsckoptions" +else + fsckoptions="-V $fsckoptions" +fi + _RUN_QUOTACHECK=0 if [ ! -f /fastboot ]; then STRING="Checking root filesystem" echo $STRING - initlog -c "fsck -C -T -a $fsckoptions /" + initlog -c "fsck -T -a $fsckoptions /" rc=$? if [ "$rc" = "0" ]; then @@ -368,7 +374,7 @@ fi if [ ! -f /fastboot ]; then STRING="Checking filesystems" echo $STRING - initlog -c "fsck -C -T -R -A -a $fsckoptions" + initlog -c "fsck -T -R -A -a $fsckoptions" rc=$? if [ "$rc" = "0" ]; then success "$STRING" diff --git a/src/Makefile b/src/Makefile index b312a08b..e21aa10e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ CFLAGS+=-Wall -D_GNU_SOURCE -g PROGS=usernetctl doexec netreport testd usleep ipcalc initlog minilogd \ - getkey ppp-watch + getkey ppp-watch consoletype PPPWATCH_OBJS=ppp-watch.o shvar.o INITLOG_OBJS=initlog.o process.o USLEEP_OBJS=usleep.o @@ -22,12 +22,14 @@ install: install -s -m 755 minilogd $(ROOT)/sbin/minilogd install -s -m 755 getkey $(ROOT)/sbin/getkey install -s -m 755 ppp-watch $(ROOT)/sbin/ppp-watch + install -s -m 755 consoletype $(ROOT)/sbin/consoletype install -m 644 initlog.1 $(ROOT)/usr/man/man1 install -m 644 doexec.1 $(ROOT)/usr/man/man1 install -m 644 netreport.1 $(ROOT)/usr/man/man1 install -m 644 usleep.1 $(ROOT)/usr/man/man1 install -m 644 usernetctl.1 $(ROOT)/usr/man/man1 install -m 644 ipcalc.1 $(ROOT)/usr/man/man1 + install -m 644 consoletype.1 $(ROOT)/usr/man/man1 install -m 644 initlog.conf $(ROOT)/etc # this daemon and initscript are useful for testing the up/down/status stuff diff --git a/src/consoletype.1 b/src/consoletype.1 new file mode 100644 index 00000000..b14b03b0 --- /dev/null +++ b/src/consoletype.1 @@ -0,0 +1,28 @@ +.TH CONSOLETYPE 1 "Red Hat Software" "RHS" \" -*- nroff -*- +.SH NAME +.B consoletype +\- print type of the console connected to standard input +.SH SYNOPSIS +.B consoletype +.SH DESCRIPTION +.B consoletype +prints the type of console connected to standard input. It prints +.I vt +if console is a virtual terminal (/dev/tty* or /dev/console device if not on +a serial console), +.I serial +if standard input is a serial console (/dev/console or /dev/ttyS*) and +.I pty +if standard input is a pseudo terminal. +.SH RETURN VALUE +.B consoletype +returns +.TP +.I 0 +if on virtual terminal +.TP +.I 1 +if on serial console +.TP +.I 2 +if on a pseudo terminal. diff --git a/src/consoletype.c b/src/consoletype.c new file mode 100644 index 00000000..6bfda4bd --- /dev/null +++ b/src/consoletype.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> + +int main(int argc, char **argv) +{ + unsigned char twelve = 12; + int maj; + struct stat sb; + + fstat(0, &sb); + maj = major(sb.st_rdev); + if (maj != 3 && (maj < 136 || maj > 143)) { + if (ioctl (0, TIOCLINUX, &twelve) < 0) { + printf ("serial\n"); + return 1; + } else { + printf ("vt\n"); + return 0; + } + } else { + printf ("pty\n"); + return 2; + } +} |