]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
initscripts: Remove console_check.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 25 Sep 2011 11:39:40 +0000 (13:39 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 25 Sep 2011 11:39:40 +0000 (13:39 +0200)
We don't need this binary anymore, because systemd is able to detect serial consoles and start a getty on it.

initscripts/initscripts.nm
initscripts/src/Makefile
initscripts/src/console_check.c [deleted file]

index c4fe57285cd572ddfcc047b66afba6d1505e7d79..ca0e7af051dd1dc19497248f8cf0065e3c56cfcf 100644 (file)
@@ -6,7 +6,7 @@
 name       = initscripts
 epoch      = 1
 version    = 2.99
-release    = 5
+release    = 6
 
 groups     = Base System/Boot
 url        =
index 92fc67057af6e03ac32291be386c7704b634cabe..9a979e40666489fddbafc3b7fafed84113ac8e41 100644 (file)
@@ -1,5 +1,5 @@
 
-PROGS = console_check console_init ipcalc securetty
+PROGS = console_init ipcalc securetty
 
 CC = gcc
 CFLAGS += -D_GNU_SOURCE $(shell pkg-config --cflags glib-2.0)
@@ -15,7 +15,6 @@ test: ipcalc
 install: $(PROGS)
        # Install binaries
        -mkdir -pv $(DESTDIR)/lib/udev $(DESTDIR)/{,s}bin
-       install -v -m 755 console_check $(DESTDIR)/lib/udev/
        install -v -m 755 console_init $(DESTDIR)/lib/udev/
        install -v -m 755 ipcalc $(DESTDIR)/bin
        install -v -m 755 securetty $(DESTDIR)/sbin
@@ -26,9 +25,6 @@ install: $(PROGS)
        install -v -m 644 ipcalc.1 $(DESTDIR)/usr/share/man/man1
        install -v -m 644 securetty.8 $(DESTDIR)/usr/share/man/man8
 
-console_check: console_check.o
-       $(CC) $(LDFLAGS) -o $@ $<
-
 console_init: console_init.o shvar.o
        $(CC) $(LDFLAGS) $(shell pkg-config --libs glib-2.0) -o $@ $?
 
diff --git a/initscripts/src/console_check.c b/initscripts/src/console_check.c
deleted file mode 100644 (file)
index 740f2a8..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include <sys/ioctl.h>
-
-#include <linux/serial.h>
-#include <linux/serial_core.h>
-
-struct speeds
-{
-       speed_t speed;
-       unsigned long value;
-};
-
-struct speeds speed_map[] =
-{
-       {B50, 50},
-       {B75, 75},
-       {B110, 110},
-        {B134, 134},
-        {B150, 150},
-        {B200, 200},
-        {B300, 300},
-        {B600, 600},
-        {B1200, 1200},
-        {B1800, 1800},
-        {B2400, 2400},
-        {B4800, 4800},
-        {B9600, 9600},
-        {B19200, 19200},
-        {B38400, 38400},
-#ifdef B57600
-       {B57600, 57600},
-#endif
-#ifdef B115200
-       {B115200, 115200},
-#endif
-#ifdef B230400
-       {B230400, 230400},
-#endif
-#ifdef B460800
-       {B460800, 460800},
-#endif
-       {0, 0}
-};
-
-int termcmp(struct termios *a, struct termios *b) {
-       if (a->c_iflag != b->c_iflag || a->c_oflag != b->c_oflag ||
-           a->c_cflag != b->c_cflag || a->c_lflag != b->c_lflag ||
-           cfgetispeed(a) != cfgetispeed(b) || cfgetospeed(a) != cfgetospeed(b))
-               return 1;
-       return memcmp(a->c_cc, b->c_cc, sizeof(a->c_cc));
-}
-
-int get_serial_speed(int fd) {
-       struct termios mode;
-
-       if (!tcgetattr(fd, &mode)) {
-               int i;
-               speed_t speed;
-
-               speed = cfgetospeed(&mode);
-               for (i = 0; speed_map[i].value != 0; i++)
-                       if (speed_map[i].speed == speed)
-                               return speed_map[i].value;
-       }
-       return 0;
-}
-
-int compare_termios_to_console(char *dev, int *speed) {
-       struct termios cmode, mode;
-       int fd, cfd;
-
-       cfd = open ("/dev/console", O_RDONLY);
-       tcgetattr(cfd, &cmode);
-       close(cfd);
-
-       fd = open(dev, O_RDONLY|O_NONBLOCK);
-       tcgetattr(fd, &mode);
-
-       if (!termcmp(&cmode, &mode)) {
-               *speed = get_serial_speed(fd);
-               close(fd);
-               return 1;
-       }
-       close(fd);
-       return 0;
-}
-
-char *serial_tty_name(int type) {
-       switch (type) {
-               case PORT_8250...PORT_MAX_8250:
-                       return "ttyS";
-               case PORT_PMAC_ZILOG:
-                       return "ttyPZ";
-               case PORT_MPSC:
-                       return "ttyMM";
-               case PORT_CPM:
-                       return "ttyCPM";
-               case PORT_MPC52xx:
-                       return "ttyPSC";
-               default:
-                       return NULL;
-       }
-}
-
-char *check_serial_console(int *speed) {
-       int fd;
-       char *ret = NULL, *device;
-       char twelve = 12;
-       struct serial_struct si, si2;
-       char *tty_name;
-
-       memset(&si, 0, sizeof(si));
-       memset(&si2, 0, sizeof(si));
-
-       fd = open("/dev/console", O_RDWR);
-       if (ioctl (fd, TIOCLINUX, &twelve) >= 0)
-               goto out;
-
-       if (ioctl(fd, TIOCGSERIAL, &si) < 0)
-               goto out;
-       close(fd);
-
-       tty_name = serial_tty_name(si.type);
-       if (!tty_name)
-               goto out;
-
-       asprintf(&device, "%s%d", tty_name, si.line);
-       fd = open(device, O_RDWR|O_NONBLOCK);
-       if (fd == -1)
-               goto out;
-
-       if (ioctl(fd, TIOCGSERIAL, &si2) < 0)
-               goto out;
-
-       if (memcmp(&si,&si2, sizeof(si)))
-               goto out;
-
-       *speed = get_serial_speed(fd);
-       ret = device;
-out:
-       close(fd);
-       return ret;
-}
-
-int emit_console_event(char *dev, int speed) {
-       char *args[] = { "initctl", "emit", "--no-wait", "serial-console-available", NULL, NULL, NULL };
-
-       asprintf(&args[4],"DEV=%s", dev);
-       if (speed)
-               asprintf(&args[5],"SPEED=%d", speed);
-       execv("/sbin/initctl", args);
-       return 1;
-}
-
-int main(int argc, char **argv) {
-       char *device;
-       int speed;
-
-       if (argc < 2) {
-               printf("usage: console_check <device>\n");
-               exit(1);
-       }
-       chdir("/dev");
-       device = argv[1];
-       if (!strcmp(device, "console")) {
-               device = check_serial_console(&speed);
-               if (device)
-                       return emit_console_event(device, speed);
-       } else if (compare_termios_to_console(device, &speed)) {
-               return emit_console_event(device, speed);
-       }
-       return 0;
-}