Hello community,

here is the log from the commit of package sysvinit for openSUSE:Factory
checked in at Mon Mar 28 10:27:33 CEST 2011.



--------
--- sysvinit/sysvinit.changes   2011-03-15 16:09:25.000000000 +0100
+++ /mounts/work_src_done/STABLE/sysvinit/sysvinit.changes      2011-03-25 
19:01:19.000000000 +0100
@@ -1,0 +2,14 @@
+Fri Mar 25 18:59:05 CET 2011 - [email protected]
+
+- New showconsole verion 1.14
+  * Use sysfs file as fallback if possible
+  * Add more sanity checks to avoid looping on tty0
+
+-------------------------------------------------------------------
+Fri Mar 25 12:13:30 CET 2011 - [email protected]
+
+- Fix triggered endless loop in blogd (bnc#642289)
+  * Writing on tty0 caused blogd to re-read its own messages
+  * The usage of ttyname(3) on /dev/console can fail
+
+-------------------------------------------------------------------

calling whatdependson for head-i586


Old:
----
  showconsole-1.13.dif
  showconsole-1.13.tar.bz2

New:
----
  showconsole-1.14.dif
  showconsole-1.14.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ sysvinit.spec ++++++
--- /var/tmp/diff_new_pack.tgGv9M/_old  2011-03-28 10:26:42.000000000 +0200
+++ /var/tmp/diff_new_pack.tgGv9M/_new  2011-03-28 10:26:42.000000000 +0200
@@ -22,14 +22,14 @@
 %define MGVER  0.9.6s
 %define PDVER  2.0.2
 %define KPVER  2.19
-%define SCVER  1.13
+%define SCVER  1.14
 %define SIVER  2.88+
 %define START  0.57
 License:        GPLv2+
 Group:          System/Base
 AutoReqProv:    on
 Version:        2.88+
-Release:        1
+Release:        2
 Summary:        SysV-Style init
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  audit-devel libselinux-devel libsepol-devel pam-devel
@@ -37,7 +37,7 @@
 Source:         
http://download.savannah.gnu.org/releases/sysvinit/sysvinit-2.88+dsf.tar.bz2
 Source2:        killproc-2.19.tar.bz2
 Source3:        powerd-2.0.2.tar.bz2
-Source4:        showconsole-1.13.tar.bz2
+Source4:        showconsole-1.14.tar.bz2
 Source5:        startpar-0.57.tar.bz2
 Source6:        rc.powerd
 Source7:        sysvinit-rpmlintrc
@@ -52,7 +52,7 @@
 Patch20:        powerd-2.0.2.dif
 Patch21:        powerd-2.0.2-getaddrinfo.patch
 Patch30:        killproc-2.19.dif
-Patch40:        showconsole-1.13.dif
+Patch40:        showconsole-1.14.dif
 Patch50:        startpar-0.57.dif
 Requires:       sysvinit-tools
 Provides:       sbin_init

++++++ showconsole-1.13.dif -> showconsole-1.14.dif ++++++
--- sysvinit/showconsole-1.13.dif       2011-03-03 14:56:36.000000000 +0100
+++ /mounts/work_src_done/STABLE/sysvinit/showconsole-1.14.dif  2011-03-25 
19:01:18.000000000 +0100
@@ -1,127 +1,4 @@
---- blogd.c
-+++ blogd.c    2011-03-02 11:25:01.151926991 +0000
-@@ -301,9 +301,16 @@ int main(int argc, char *argv[])
-     secondtty(cons, st.st_rdev);
- 
-     (void)ioctl(0, TIOCCONS, NULL);  /* Undo any current map if any */
-+    close(0);
-+
-     if (ioctl(pts, TIOCCONS, NULL) < 0)
-       error("can not set console device to %s: %s\n", ptsname, 
strerror(errno));
- 
-+    dup2(pts, 1);
-+    dup2(pts, 2);
-+    if (pts > 2)
-+      close(pts);
-+
-     for (c = cons; c; c = c->next) {
- #ifdef _PC_MAX_CANON
-       if ((c->max_canon = (ssize_t)fpathconf(c->fd, _PC_MAX_CANON)) <= 0)
-@@ -356,21 +363,16 @@ int main(int argc, char *argv[])
-           close(cons->fd);
-           cons->fd = 1;       /* Choose stdout */
-       }
--      close(pts);
-       close(ptm);
-       break;
-     case -1:
--      close(pts);
-       close(ptm);
-       warn("can not fork to become daemon: %s\n", strerror(errno));
-       goto err;
-     default:
-       time(&tt);
-       stt = ctime(&tt);
--      close(pts);
-       close(ptm);
--      close(cons->fd);
--      cons->fd = -1;
-       for (c = cons; c; c = c->next) {
-           if (c->fd > 0) {
-               close(c->fd);
---- libconsole.c
-+++ libconsole.c       2011-03-02 10:33:17.032457114 +0000
-@@ -707,11 +707,12 @@ static void parselog(unsigned char *buf,
- static void copylog(const unsigned char *buf, const size_t s)
- {
-     lock(&llock);
--    if (!nl) {
-+    if (!nl)
-       addlog('\n');
--      nl = 1;
--    }
-     storelog(buf, s);
-+    if (buf[s-1] != '\n')
-+      addlog('\n');
-+    nl = 1;
-     unlock(&llock);
- }
- 
-@@ -770,7 +771,7 @@ void prepareIO(void (*rfunc)(int), void
-           (void)mkfifo(fifo_name, 0600);
-       errno = 0;
-       if (!stat(fifo_name, &st) && S_ISFIFO(st.st_mode)) {
--          if ((fdfifo = open(fifo_name, O_RDONLY|O_NOCTTY|O_CLOEXEC)) < 0)
-+          if ((fdfifo = open(fifo_name, O_RDWR|O_NOCTTY|O_CLOEXEC)) < 0)
-               warn("can not open named fifo %s: %s\n", fifo_name, 
strerror(errno));
-       }
-     }
-@@ -1266,7 +1267,7 @@ char * fetchtty(const pid_t pid, const p
-       while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 
3)) {
-           if (!strchr(fbuf, 'E'))
-               continue;
--          if (strchr(fbuf, '*')) {
-+          if (strchr(fbuf, 'C')) {
-               dev = makedev(maj, min);
-               break;
-           }
-@@ -1327,8 +1328,9 @@ void secondtty(struct console *restrict
- 
-     tail = cons;
- 
--    if ((fc = fopen("/proc/tty/consoles", "r"))) {
--      int maj, min, flags;
-+    if ((fc = fopen("/proc/consoles", "r"))) {
-+      unsigned int maj, min;
-+      int flags;
-       struct stat st;
-       char fbuf[16];
- 
-@@ -1341,13 +1343,13 @@ void secondtty(struct console *restrict
-           error("can not opendir(/dev): %s\n", strerror(errno));
-       pushd("/dev");
- 
--      while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 
3)) {
-+      while ((fscanf(fc, "%*s %*s (%[^)]) %u:%u", &fbuf[0], &maj, &min) == 
3)) {
-           struct console *restrict newc;
-           dev_t dev;
- 
-           if (!strchr(fbuf, 'E'))
-               continue;
--          if (strchr(fbuf, '*'))
-+          if (strchr(fbuf, 'C'))
-               continue;
-           dev = makedev(maj, min);
- 
---- showconsole.8
-+++ showconsole.8      2010-11-09 15:26:29.038362757 +0000
-@@ -22,8 +22,7 @@ Setconsole \- redirect system console ou
- .SH DESCRIPTION
- .B showconsole
- determines the real character device of
--the current
--.BR stdin.
-+the current system console.
- This can be used on
- .I /dev/console
- as current character device to
---- showconsole.c
-+++ showconsole.c      2010-10-25 13:08:25.583937937 +0000
-@@ -19,6 +19,7 @@
- #include <fcntl.h>
- #include <unistd.h>
- #include <errno.h>
-+#include <signal.h>
- #include "libconsole.h"
- 
- /*
+--- .dummy
++++ .dummy     2011-03-25 17:58:16.867926297 +0000
+@@ -0,0 +1 @@
++Remove if real patch is required

++++++ showconsole-1.13.tar.bz2 -> showconsole-1.14.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/Makefile 
new/showconsole-1.14/Makefile
--- old/showconsole-1.13/Makefile       2010-10-21 11:57:34.000000000 +0200
+++ new/showconsole-1.14/Makefile       2010-11-09 17:01:00.000000000 +0100
@@ -13,7 +13,7 @@
 #DESTDIR =     /tmp/root
 DEBUG   =
 DESTDIR         =
-VERSION         =      1.13
+VERSION         =      1.14
 DATE    =      $(shell date +'%d%b%y' | tr '[:lower:]' '[:upper:]')
 COPTS    =
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/blogd.8 new/showconsole-1.14/blogd.8
--- old/showconsole-1.13/blogd.8        2010-05-04 11:57:15.000000000 +0200
+++ new/showconsole-1.14/blogd.8        2011-03-22 11:11:03.000000000 +0100
@@ -40,7 +40,7 @@
 .I /dev/console
 as its controlling tty (would hangup any running
 getty on that character device).
-\."
+.\"
 .SH SIGNALS
 .B blogd
 knows a few signal to contol its behavior.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/blogd.c new/showconsole-1.14/blogd.c
--- old/showconsole-1.13/blogd.c        2010-10-21 11:57:05.000000000 +0200
+++ new/showconsole-1.14/blogd.c        2011-03-25 18:52:49.000000000 +0100
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
+#include <stropts.h>
 #include <dirent.h>
 #include <fcntl.h>
 #include <termios.h>
@@ -41,6 +42,8 @@
 #endif
 extern volatile sig_atomic_t nsigsys;
 
+static const char console[] = "/dev/console";
+
 /*
  * Internal logger
  */
@@ -91,14 +94,14 @@
 /*
  * Write pidfile
  */
-static void pidfile()
+static void attribute((noinline)) pidfile()
 {
     char buf[strlen(_PATH_VARRUN)+strlen(myname)+1+3+1];
     FILE * fpid;
 
     strcat(strcat(strcpy(buf, _PATH_VARRUN), myname), ".pid");
     if ((fpid = fopen (buf, "w")) == NULL) {
-       warn("can not open %s: %s\n", buf, strerror(errno));
+       warn("can not open %s: %m\n", buf);
        goto out;
     }
     fprintf(fpid, "%d\n", (int)getpid());
@@ -198,7 +201,7 @@
            break;
        default:        /* IO of system consoles */
            if ((newfd = open(c->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0)
-               error("can not open %s: %s\n", c->tty, strerror(errno));
+               error("can not open %s: %m\n", c->tty);
            dup2(newfd, c->fd);
            if (newfd != c->fd)
                close(newfd);
@@ -207,26 +210,55 @@
     }
 }
 
+
+static volatile int cntrtty = 1;
+static volatile pid_t pid = -1;
+static volatile pid_t ppid;
+
+static void flush_handler (void) attribute((noinline));
+static void exit_handler (void) attribute((noinline));
+
 /*
  * Now do the job
  */
 int main(int argc, char *argv[])
 {
-    int fd, flags;
-    int ptm, pts, cntrtty = 1;
-    const pid_t ppid = getppid();
-    const pid_t pgrp = getpgid(ppid);
     char ptsname[NAME_MAX+1];
     struct console *c;
     struct termios o;
     struct winsize w;
     struct stat st;
-    pid_t pid;
+    speed_t ospeed;
+    speed_t ispeed;
+    int ptm, pts;
+    int flags;
+    pid_t pgrp;
     time_t tt;
-    char *tty, *stt, *name = ttyname(0);
+    char *tty, *stt;
 
+    ppid = getppid();
+    pgrp = getpgid(ppid);
     myname = basename(*argv);
 
+    if (stat(console, &st) < 0)
+       error("No system console %s: %m\n", console);
+    else {
+       dev_t sysconsole = st.st_rdev;
+       int fd0;
+
+       if (stat("/proc/self/fd/0", &st) < 0)
+           error("No standard input: %m\n");
+       if (sysconsole != st.st_rdev) {
+           close(0);
+           if ((fd0 = open(console, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0)
+               error("Can not open system console %s: %m\n", console);
+           if (fd0 > 0) {
+               dup2(fd0, 0);
+               close(fd0);
+           }
+       }
+    }
+
     if (argc > 2)
        error("Too many args; usage: %s [/dev/tty<X>]\n", myname);
 
@@ -238,38 +270,36 @@
     if (!tty || !*tty)
        error("can not discover real system console tty, boot logging 
disabled.\n");
 
-    if (!name || !*name) {
-       name = strdup("(no tty)");
-       if (!name)
-           error("strdup(): %s\n", strerror(errno));
-    }
-
-    if (strcmp(tty, name) == 0)
-       error("console=%s, stdin=%s, must differ, boot logging disabled\n", 
tty, name);
+    if (strcmp(tty, console) == 0)
+       error("console=%s, stdin=%s, must differ, boot logging disabled\n", 
tty, console);
 
     if (posix_memalign((void*)&cons, sizeof(void*), alignof(typeof(struct 
console))) != 0)
-       error("memory allocation: %s\n", strerror(errno));
+       error("memory allocation: %m\n");
 
     cons->next = (struct console*)0;
     cons->tty = tty;
     if ((cons->fd = open(cons->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0)
-       error("can not open %s: %s\n", tty, strerror(errno));
+       error("can not open %s: %m\n", tty);
 
     if ((flags = fcntl(cons->fd, F_GETFL)) < 0)
-       error("can not get terminal flags of %s: %s\n", tty, strerror(errno));
+       error("can not get terminal flags of %s: %m\n", tty);
 
     flags &= ~(O_NONBLOCK);
     flags |=   O_NOCTTY;
     if (fcntl(cons->fd, F_SETFL, flags) < 0)
-       error("can not set terminal flags of %s: %s\n", tty, strerror(errno));
+       error("can not set terminal flags of %s: %m\n", tty);
 
     if (tcgetattr(cons->fd, &cons->otio) < 0)
-       error("can not get terminal parameters of %s: %s\n", tty, 
strerror(errno));
+       error("can not get terminal parameters of %s: %m\n", tty);
 
-    if (fstat(cons->fd, &st) == 0 && major(st.st_rdev) == TTY_MAJOR) {
-       cfsetispeed(&cons->otio, B38400);
-       cfsetospeed(&cons->otio, B38400);
+    ispeed = B38400;
+    ospeed = B38400;
+    if (ioctl(cons->fd, TIOCMGET, &flags) == 0) {
+       ispeed = cfgetispeed(&cons->otio);
+       ospeed = cfgetospeed(&cons->otio);
     }
+    cfsetispeed(&cons->otio, ispeed);
+    cfsetospeed(&cons->otio, ospeed);
 
     if (tcgetpgrp(cons->fd) < 0)
        cntrtty = 0;
@@ -277,7 +307,7 @@
     w.ws_row = 0;
     w.ws_col = 0;
     if (ioctl(cons->fd, TIOCGWINSZ, &w) < 0)
-       error("can not get window size of %s: %s\n", tty, strerror(errno));
+       error("can not get window size of %s: %m\n", tty);
 
     if (!w.ws_row)
        w.ws_row = 24;
@@ -286,25 +316,36 @@
 
     memcpy(&o, &cons->otio, sizeof(o));
     cfmakeraw(&o);
+    cfsetispeed(&o, ispeed);
+    cfsetospeed(&o, ospeed);
 
     if (openpty(&ptm, &pts, ptsname, &o, &w) < 0)
-       error("can not open pty/tty pair: %s\n", strerror(errno));
+       error("can not open pty/tty pair: %m\n");
 
     if (fstat(pts, &st) < 0)
-       error("can not stat slave pty : %s\n", strerror(errno));
+       error("can not stat slave pty : %m\n");
     else {
        struct termios lock;
        memset(&lock, 0xff, sizeof(lock));
        (void)ioctl(pts, TIOCSLCKTRMIOS, &lock);
     }
 
-    secondtty(cons, st.st_rdev);
+    if (isastream(1) < 0 && errno == EBADF)
+       dup2(0, 1);
+    if (isastream(2) < 0 && errno == EBADF)
+       dup2(0, 2);
 
+    secondtty(cons, st.st_rdev);
+exit(0);
     (void)ioctl(0, TIOCCONS, NULL);  /* Undo any current map if any */
+    close(0);
+
     if (ioctl(pts, TIOCCONS, NULL) < 0)
-       error("can not set console device to %s: %s\n", ptsname, 
strerror(errno));
+       error("can not set console device to %s: %m\n", ptsname);
+    close(pts);
 
     for (c = cons; c; c = c->next) {
+       int iflag, oflag;
 #ifdef _PC_MAX_CANON
        if ((c->max_canon = (ssize_t)fpathconf(c->fd, _PC_MAX_CANON)) <= 0)
 #endif
@@ -313,6 +354,19 @@
        if (tcgetattr(cons->fd, &cons->otio) < 0)
            continue;
        c->tlock = 1;
+#if 1
+       iflag = c->otio.c_iflag;
+       oflag = c->otio.c_oflag;
+
+       c->otio.c_iflag |= (ICRNL | IGNBRK);
+       c->otio.c_iflag &= ~(INLCR | IGNCR | BRKINT);
+       c->otio.c_oflag |= (ONLCR | OPOST);
+       c->otio.c_oflag &= ~(OCRNL | ONLRET);
+       (void)tcsetattr(cons->fd, TCSADRAIN, &cons->otio);
+
+       c->otio.c_iflag = iflag;
+       c->otio.c_oflag = oflag;
+#endif
        if ((c->otio.c_lflag & ICANON) == 0) {
            c->otio.c_lflag |= ICANON | IEXTEN | ISIG | ECHO|ECHOE|ECHOK|ECHOKE;
            c->otio.c_oflag |= OPOST;
@@ -344,6 +398,8 @@
     (void)siginterrupt(SIGTERM, 0);
     (void)siginterrupt(SIGSYS,  0);
 
+    atexit(exit_handler);      /* Register main exit handler */
+
     switch ((pid = fork())) {
     case 0:
        /* Get our own session */
@@ -352,55 +408,56 @@
        dup2(ptm, 0);
        dup2(cons->fd,  1);
        dup2(cons->fd,  2);
-       if (cons->fd > 2) {
-           close(cons->fd);
-           cons->fd = 1;       /* Choose stdout */
-       }
-       close(pts);
+       if (cons->fd > 2)
+           dup2(1, cons->fd);  /* Choose stdout */
        close(ptm);
        break;
     case -1:
-       close(pts);
        close(ptm);
-       warn("can not fork to become daemon: %s\n", strerror(errno));
-       goto err;
+       error("can not fork to become daemon: %m\n");
     default:
        time(&tt);
        stt = ctime(&tt);
-       close(pts);
        close(ptm);
-       close(cons->fd);
-       cons->fd = -1;
        for (c = cons; c; c = c->next) {
            if (c->fd > 0) {
                close(c->fd);
                c->fd = -1;
            }
        }
-       fprintf(stdout, "\rBoot logging started on %s(%s) at %.24s\n", tty, 
name, stt);
+       fprintf(stdout, "\rBoot logging started on %s(%s) at %.24s\n", tty, 
console, stt);
        fflush(stdout);
-       exit(0);
+       _exit(0);               /* NEVER rise exit handlers here */
     }
 
+    atexit(flush_handler);     /* Register flush exit handler */
+
     prepareIO(reconnect, pidfile, pgrp, 0);
     while (!signaled)
        safeIO();
 
+    exit(0);                   /* Raise exit handlers */
+}
+
+static void flush_handler (void)
+{
     (void)tcdrain(1);
     (void)tcdrain(2);
 
-    if (!cntrtty)
-       kill(ppid, SIGSTOP);
+    if (!cntrtty) kill(ppid, SIGSTOP);
     closeIO();
-    if (!cntrtty)
-       kill(ppid, SIGCONT);
+    if (!cntrtty) kill(ppid, SIGCONT);
+}
+
+static void exit_handler (void)
+{
+    struct console *c;
+    int fd;
 
-    (void)ioctl(0, TIOCSLCKTRMIOS, &o);
-err:
     for (c = cons; c; c = c->next) {
        if (c->fd > 0) {
            if (c->tlock)       /* write back old setup  */
-               tcsetattr(c->fd, TCSANOW, &c->otio);
+               tcsetattr(c->fd, TCSADRAIN, &c->otio);
            if (c->tlock > 1)   /* write back lock if any */
                (void)ioctl(c->fd, TIOCSLCKTRMIOS, &c->ltio);
            c->tlock = 0;
@@ -410,20 +467,15 @@
     }
 
     errno = 0;
-    if ((fd = open("/dev/console", O_RDWR|O_NOCTTY)) >= 0) {
+    if ((fd = open(console, O_RDWR|O_NOCTTY)) >= 0) {
        (void)ioctl(fd, TIOCCONS, NULL);        /* Restore old console mapping 
*/
        close(fd);
     }
 
-    if (pid > 0) {
-       (void)tcflush(1, TCOFLUSH);
-       close(1);
-       (void)tcflush(2, TCOFLUSH);
-       close(2);
-       (void)tcflush(0, TCIFLUSH);
-       close(0);
-       rmfpid();
-    }
+    close(1);
+    close(2);
+    (void)tcflush(0, TCIFLUSH);
+    close(0);
 
     reset_signal(SIGTTIN, &saved_sigttin);
     reset_signal(SIGTTOU, &saved_sigttou);
@@ -433,6 +485,4 @@
     reset_signal(SIGQUIT, &saved_sigquit);
     reset_signal(SIGTERM, &saved_sigterm);
     reset_signal(SIGSYS,  &saved_sigsys);
-
-    return 0;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/libconsole.c 
new/showconsole-1.14/libconsole.c
--- old/showconsole-1.13/libconsole.c   2010-10-21 11:57:05.000000000 +0200
+++ new/showconsole-1.14/libconsole.c   2011-03-25 18:50:59.000000000 +0100
@@ -29,6 +29,12 @@
 #include <sys/types.h> /* Defines the macros major and minor */
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#ifndef TIOCGDEV
+# include <sys/vt.h>
+# include <sys/kd.h>
+# include <linux/serial.h>
+#endif
+#include <linux/major.h>
 #include <sys/mman.h>
 #include <sys/socket.h>
 #include <sys/param.h>
@@ -52,9 +58,6 @@
 #include "libconsole.h"
 #include "listing.h"
 
-extern void error (const char *fmt, ...);
-extern void warn  (const char *fmt, ...);
-
 /*
  * push and popd direcotry changes
  */
@@ -78,10 +81,10 @@
        goto out;
     }
 err:
-    error("%s", strerror(errno));
+    error("%m");
 out:
     if (chdir(path) < 0)
-       error ("pushd() can not change to directory %s: %s\n", path, 
strerror(errno));
+       error ("pushd() can not change to directory %s: %m\n", path);
 }
 
 void popd(void)
@@ -93,7 +96,7 @@
        goto out;
     dir = getpwd(tail);
     if (chdir(dir->pwd) < 0)
-       error ("popd() can not change directory %s: %s\n", dir->pwd, 
strerror(errno));
+       error ("popd() can not change directory %s: %m\n", dir->pwd);
     free(dir->pwd);
     delete(tail);
     free(dir);
@@ -110,12 +113,12 @@
 {
     int ret = -1;
     unsigned int deep = 0;
-    static ino_t iprev;                        // Recurive loop detection
+    static ino_t iprev;                        /* Recurive loop detection */
 
     if (lstat(*file, st) < 0)
        goto out;
 
-    if (iprev && iprev == st->st_ino)  // We're run on the previous
+    if (iprev && iprev == st->st_ino)  /* We're run on the previous */
        goto out;
     iprev = st->st_ino;
 
@@ -123,7 +126,7 @@
        const char *prev_file;
        ssize_t cnt;
 
-       if (!S_ISLNK(st->st_mode))      // Not a symlink
+       if (!S_ISLNK(st->st_mode))      /* Not a symlink */
            break;
 
        if (deep++ > MAXSYMLINKS) {
@@ -133,7 +136,7 @@
 
        prev_file = strdupa(*file);
        if (!prev_file)
-           error("strdupa(): %s\n", strerror(errno));
+           error("strdupa(): %m\n");
        if ((cnt = readlink(*file, lnk, sizeof(lnk) - 1)) < 0)
            goto out;
        lnk[cnt] = '\0';
@@ -175,10 +178,10 @@
     static int eiocount;
 
     while (s > 0) {
-       ssize_t p = write (fd, ptr, (max < 0) ? s : ((s < (size_t)max) ? s : 
(size_t)max));
+       ssize_t p = write (fd, ptr, (max < 1) ? 1 : ((s < (size_t)max) ? s : 
(size_t)max));
        if (p < 0) {
            if (errno == EPIPE) {
-               warn("error on writing to fd %d: %s\n", fd, strerror(errno));
+               warn("error on writing to fd %d: %m\n", fd);
                exit (0);
            }
            if (errno == EINTR) {
@@ -190,7 +193,7 @@
                fd_set check;
 
                if (repeated++ > 1000)
-                   error("repeated error on writing to fd %d: %s\n", fd, 
strerror(errno));
+                   error("repeated error on writing to fd %d: %m\n", fd);
 
                FD_ZERO (&check);
                FD_SET (fd, &check);
@@ -204,19 +207,19 @@
                } while ((ret < 0) && (errno == EINTR));
 
                if (ret < 0)
-                   error("can not write to fd %d: %s\n", fd, strerror(errno));
+                   error("can not write to fd %d: %m\n", fd);
 
                errno = 0;
                continue;
            }
            if (errno == EIO) {
                if ((eiocount++ > 10) || !vc_reconnect)
-                   error("can not write to fd %d: %s\n", fd, strerror(errno));
+                   error("can not write to fd %d: %m\n", fd);
                (*vc_reconnect)(fd);
                errno = 0;
                continue;
            }
-           error("can not write to fd %d: %s\n", fd, strerror(errno));
+           error("can not write to fd %d: %m\n", fd);
        }
        repeated = 0;
        ptr += p;
@@ -238,6 +241,7 @@
     if (s > SSIZE_MAX)
        s = SSIZE_MAX;
 
+    t=0;
     if ((ioctl(fd, FIONREAD, &t) < 0) || (t == 0)) {
        fd_set check;
        struct timeval zero = {0, 0};
@@ -258,7 +262,9 @@
        if (r < 0 && errno != EPIPE) {
            if (noerr)
                goto out;
-           error("Can not read from fd %d: %s\n", fd, strerror(errno));
+           if (fd == 0 && errno == EIO)
+               warn("\e[31m\e[1msystem console stolen at line %d!\e[m\n", 
__LINE__);
+           error("Can not read from fd %d: %m\n", fd);
        }
 
        goto out;
@@ -272,14 +278,16 @@
        ssize_t p = read (fd, ptr, t);
        if (p < 0) {
            if (repeated++ > 1000)
-               error("Repeated error on reading from fd %d: %s\n", fd, 
strerror(errno));
+               error("Repeated error on reading from fd %d: %m\n", fd);
            if (errno == EINTR || errno == EAGAIN) {
                errno = 0;
                continue;
            }
            if (noerr)
                goto out;
-           error("Can not read from fd %d: %s\n", fd, strerror(errno));
+           if (fd == 0 && errno == EIO)
+               warn("\e[31m\e[1msystem console stolen at line %d!\e[m\n", 
__LINE__);
+           error("Can not read from fd %d: %m\n", fd);
        }
        repeated = 0;
        ptr += p;
@@ -707,11 +715,12 @@
 static void copylog(const unsigned char *buf, const size_t s)
 {
     lock(&llock);
-    if (!nl) {
+    if (!nl)
        addlog('\n');
-       nl = 1;
-    }
     storelog(buf, s);
+    if (buf[s-1] != '\n')
+       addlog('\n');
+    nl = 1;
     unlock(&llock);
 }
 
@@ -770,8 +779,8 @@
            (void)mkfifo(fifo_name, 0600);
        errno = 0;
        if (!stat(fifo_name, &st) && S_ISFIFO(st.st_mode)) {
-           if ((fdfifo = open(fifo_name, O_RDONLY|O_NOCTTY|O_CLOEXEC)) < 0)
-               warn("can not open named fifo %s: %s\n", fifo_name, 
strerror(errno));
+           if ((fdfifo = open(fifo_name, O_RDWR|O_NOCTTY|O_CLOEXEC)) < 0)
+               warn("can not open named fifo %s: %m\n", fifo_name);
        }
     }
     (void)mlockall(MCL_FUTURE);
@@ -800,7 +809,7 @@
        timeout->tv_sec  = 0;
        timeout->tv_usec = 0;
        if (errno != EINTR)
-           error ("select(): %s\n", strerror(errno));
+           error ("select(): %m\n");
        goto nothing;
     }
 
@@ -877,12 +886,12 @@
 #endif
        if (access(BOOT_LOGFILE, W_OK) < 0) {
            if (errno != ENOENT && errno != EROFS)
-               error("Can not write to %s: %s\n", BOOT_LOGFILE, 
strerror(errno));
+               error("Can not write to %s: %m\n", BOOT_LOGFILE);
            goto skip;
        }
        if ((log = open(BOOT_LOGFILE, O_WRONLY|O_NOCTTY|O_APPEND)) < 0) {
            if (errno != ENOENT && errno != EROFS)
-               error("Can not open %s: %s\n", BOOT_LOGFILE, strerror(errno));
+               error("Can not open %s: %m\n", BOOT_LOGFILE);
            goto skip;
        }
        if (vr_access) {
@@ -890,7 +899,7 @@
            vr_access = NULL;
        }
        if ((flog = fdopen (log, "a")) == NULL)
-               error("Can not open %s: %s\n", BOOT_LOGFILE, strerror(errno));
+               error("Can not open %s: %m\n", BOOT_LOGFILE);
 
        nsigio = SIGIO; /* We do not need a signal handler */
        (void)signal(SIGIO, SIG_IGN);
@@ -1027,16 +1036,16 @@
 
     sprintf(fetched, "/proc/%d/stat", (int)pid);
     if ((fd = open(fetched, O_RDONLY|O_NOCTTY)) < 0)
-       error("can not open(%s): %s\n", fetched, strerror(errno));
+       error("can not open(%s): %m\n", fetched);
     cnt = safein(fd, fetched, sizeof(fetched), 0);
     close(fd);
 
     if (cnt <= 0)
-       error("can not read from proc: %s\n", strerror(errno));
+       error("can not read from proc: %m\n");
     else       
        /* format pid comm state ppid pgrp session tty tpgid */
        if (sscanf(fetched,"%*d %*s %*c %*d %*d %*d %u %u %*u", tty, ttypgrp) 
!= 2)
-           error("can not sscanf for my tty: %s\n", strerror(errno));
+           error("can not sscanf for my tty: %m\n");
 }
 
 /* fall back routine to fetch tty */
@@ -1054,7 +1063,7 @@
        pid_t pid = -1;  /* Inner pid */
 
        if (pipe(fdfrom) < 0)
-           error("can not create a pipe: %s\n", strerror(errno));
+           error("can not create a pipe: %m\n");
 
        switch ((pid = fork())) {
        case 0:
@@ -1080,7 +1089,7 @@
 
                /* Take stdin as our controlling tt< */
                if (ioctl(0, TIOCSCTTY, (void *)1) < 0)
-                   warn("can not set controlling tty: %s\n", strerror(errno));
+                   warn("can not set controlling tty: %m\n");
 
                ctty(pid, &tty, &ttypgrp);
 
@@ -1095,7 +1104,7 @@
                exit(0);
            } break;
        case -1:
-           error("can not execute: %s\n", strerror(errno));
+           error("can not execute: %m\n");
            break;
        default:
            {   int fd = dup(0);
@@ -1141,6 +1150,15 @@
            if (!strncmp(name, "ram", 3))
                continue;
 
+           if (!strncmp(name, "rtc", 3))
+               continue;
+
+           if (!strncmp(name, "card", 4))
+               continue;
+
+           if (!strncmp(name, "vboxguest", 9))
+               continue;
+
            if (!strcmp(name, "cciss"))
                continue;
 
@@ -1183,13 +1201,28 @@
            if (!strcmp(name, "block"))
                continue;
 
+           if (!strcmp(name, "cgroup"))
+               continue;
+
            if (!strcmp(name, "disk"))
                continue;
+
+           if (!strcmp(name, "bus"))
+               continue;
+
+           if (!strcmp(name, "bsg"))
+               continue;
+
+           if (!strcmp(name, "cpu"))
+               continue;
+
+           if (!strcmp(name, "char"))
+               continue;
        }
 
        if (rlstat(&name, &st) < 0) {
            if (errno != ENOENT)
-               warn("can not follow %s: %s\n", name, strerror(errno));
+               warn("can not follow %s: %m\n", name);
            continue;
        }
 
@@ -1199,7 +1232,7 @@
        if (S_ISDIR(st.st_mode)) {
            DIR * cur = opendir(name);
            if (!cur)
-               error("can not opendir(%s): %s\n", name, strerror(errno));
+               error("can not opendir(%s): %m\n", name);
            pushd(name);
            deep++;
            found = checkdev(retname, dev, cur);
@@ -1226,7 +1259,7 @@
        if (*name && *name != '/') {
            char * ptr = strdupa(name);
            if (!ptr)
-               error("checkdev(): %s\n", strerror(errno));
+               error("checkdev(): %m\n");
            getcwd(name, PATH_MAX - 1 - strlen(ptr));
            strcat(name, "/");
            strcat(name, ptr);
@@ -1240,7 +1273,7 @@
         */
        name = realpath(name, NULL);
        if (!name)
-           error("checkdev(): %s\n", strerror(errno));
+           error("checkdev(): %m\n");
        *retname = name;
        break;
     }
@@ -1248,11 +1281,79 @@
     return found;
 }
 
+/* Read and allocate one line from file */
+static char *oneline(const char *file)
+{
+    FILE *fp;
+    char *ret = (char*)0, *nl;
+    size_t len = 0;
+
+    if ((fp = fopen(file, "r")) == (FILE*)0)
+       goto err;
+    if (getline(&ret, &len, fp) < 0)
+       goto out;
+    if (len)
+       ret[len-1] = '\0';
+    if ((nl = strchr(ret, '\n')))
+       *nl = '\0';
+out:
+    fclose(fp);
+err:
+    return ret;
+}
+
+/* Read and determine active attribute for tty */
+static char *actattr(const char *tty)
+{
+    char *ret = (char*)0;
+    char *path;
+
+    if (!tty || *tty == '\0')
+       goto err;
+
+    if (asprintf(&path, "/sys/class/tty/%s/active", tty) < 0)
+       goto err;
+
+    if ((ret = oneline(path)) == (char*)0)
+       goto out;
+out:
+    free(path);
+err:
+    return ret;
+}
+
+/* Read and determine device attribute for tty */
+static dev_t devattr(const char *tty)
+{
+    unsigned int maj, min;
+    dev_t dev = 0;
+    char *path, *value;
+
+    if (!tty || *tty == '\0')
+       goto err;
+
+    if (asprintf(&path, "/sys/class/tty/%s/dev", tty) < 0)
+       goto err;
+
+    if ((value = oneline(path)) == (char*)0)
+       goto out;
+
+    if (sscanf(value, "%u:%u", &maj, &min) == 2)
+       dev = makedev(maj, min);
+    free(value);
+out:
+    free(path);
+err:
+    return dev;
+}
+
+#undef USE_SYSFS    /* Can not determine preferred console */
+
 /* main routine to fetch tty */
 char * fetchtty(const pid_t pid, const pid_t ppid, dev_t * tty)
 {
-#ifdef TIOCGDEV
-    unsigned int mjmi = 0;
+#ifdef USE_SYSFS
+    char * attrib;
 #endif
     char * name = NULL;
     dev_t dev = 0;
@@ -1260,42 +1361,74 @@
     DIR * ddev;
     FILE * fc;
 
-    if ((fc = fopen("/proc/tty/consoles", "r"))) {
+    if ((fc = fopen("/proc/consoles", "r"))) {
        char fbuf[16];
-       int maj, min;
-       while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 
3)) {
+       unsigned int maj, min;
+       while ((fscanf(fc, "%*s %*s (%[^)]) %u:%u", &fbuf[0], &maj, &min) == 
3)) {
            if (!strchr(fbuf, 'E'))
                continue;
-           if (strchr(fbuf, '*')) {
+           if (strchr(fbuf, 'C')) {
                dev = makedev(maj, min);
                break;
            }
        }
        fclose(fc);
-    }
+#ifdef USE_SYSFS
+    } else if ((attrib = actattr("console"))) {
+       char *words = attrib, *token;
+       while ((token = strsep(&words, " \t\n"))) {
+           if (*token)
+                name = token;  /* At least this takes the last (preferred 
console??) */
+       }
+       dev = devattr(name);
+       free(attrib);
+       if (dev == makedev(TTY_MAJOR, 0)) {
+           if ((attrib = actattr(name))) {
+               dev = devattr(attrib);
+               free(attrib);
+           }
+       }
+#endif
+    } else {
 #ifdef TIOCGDEV
-    else {
-       if (ioctl (0, TIOCGDEV, &mjmi) < 0) {
+       unsigned int devnum = 0;
+       if (ioctl (0, TIOCGDEV, &devnum) < 0) {
            if (errno == EINVAL && !getenv("NOTIOCGDEV"))
                warn("Warning: the ioctl TIOCGDEV is not known by the 
kernel\n");
        }
-       dev = (dev_t)mjmi;
-    }
+       dev = (dev_t)devnum;
+#else
+       struct stat st;
+       if (fstat(0, &st) == 0 && (major(st.st_rdev) == TTYAUX_MAJOR || 
st.st_rdev == makedev(TTY_MAJOR, 0))) {
+           unsigned int arg;
+           if (ioctl(0, TIOCMGET, &arg) == 0) {                /* serial line 
*/
+# if 0
+               dev = makedev(TTY_MAJOR, 64);                   /* 
8250/16450/16550(A) ports */
+# else
+               dev = 0;
+# endif
+           } else if (ioctl(0, KDGKBTYPE, &arg) == 0) {        /* virtual 
console */
+               struct vt_stat vt;
+               if (ioctl(0, VT_GETSTATE, &vt) == 0)
+                   dev = makedev(TTY_MAJOR, (int)vt.v_active);
+           }
+       }
 #endif
+    }
     if (!dev) {
        if (!(name = ttyname(0)) || !strcmp(name, "/dev/console"))
            dev = fallback(pid, ppid);
        else {
            name = strdup(name);
            if (!name)
-               error("fetchtty(): %s\n", strerror(errno));
+               error("fetchtty(): %m\n");
            goto out;
        }
     }
     if (tty) *tty = dev;
 
     if (!(ddev = opendir("/dev")))
-       error("can not opendir(/dev): %s\n", strerror(errno));
+       error("can not opendir(/dev): %m\n");
     pushd("/dev");
     found = checkdev(&name, dev, ddev);
     popd();
@@ -1312,48 +1445,79 @@
     return name;
 }
 
+/* Allocate a console */
+static void consalloc(struct console *restrict cons, char * name)
+{
+    struct console *restrict tail = cons;
+    struct console *restrict newc;
+    int flags;
+
+    if (posix_memalign((void*)&newc, sizeof(void*), alignof(typeof(struct 
console))) != 0)
+       error("memory allocation: %m\n");
+
+    newc->next = (struct console*)0;
+    newc->tty = name;
+    if ((newc->fd = open(newc->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
+       warn("can not open %s: %m\n", newc->tty);
+       free(newc);
+       return;
+    }
+    tail->next = newc;
+    tail = tail->next;
+
+    if ((flags = fcntl(newc->fd, F_GETFL)) < 0)
+       warn("can not get terminal flags of %s: %m\n", newc->tty);
+
+    flags &= ~(O_NONBLOCK);
+    flags |=   O_NOCTTY;
+    if (fcntl(newc->fd, F_SETFL, flags) < 0)
+       warn("can not set terminal flags of %s: %m\n", newc->tty);
+}
+
 /* Do we have some more system console around? */
 void secondtty(struct console *restrict cons, const dev_t tty)
 {
-    struct console *restrict tail;
     char buf[1024], *ptr, *shcmp;
-    char * name = (char*)0;
+    char *attrib;
+    char *name = (char*)0;
     int fd = -1, len;
+    struct stat st;
+    dev_t rdev;
     DIR * ddev;
     FILE * fc;
 
     if (!cons || !cons->tty)
        error("no primary console\n");
 
-    tail = cons;
+    if (stat(cons->tty, &st) < 0) {
+       warn("can not stat /dev/%s: %m\n", cons->tty);
+       st.st_rdev = 0;
+    }
+    rdev = st.st_rdev;
 
-    if ((fc = fopen("/proc/tty/consoles", "r"))) {
-       int maj, min, flags;
-       struct stat st;
+    if ((fc = fopen("/proc/consoles", "r"))) {
+       unsigned int maj, min;
        char fbuf[16];
 
-       if (stat(cons->tty, &st) < 0) {
-           warn("can not stat /dev/%s: %s\n", cons->tty, strerror(errno));
-           st.st_rdev = 0;
-       }
-
        if (!(ddev = opendir("/dev")))
-           error("can not opendir(/dev): %s\n", strerror(errno));
+           error("can not opendir(/dev): %m\n");
        pushd("/dev");
 
-       while ((fscanf(fc, "%*s %*s (%[^)]) %d:%d", &fbuf[0], &maj, &min) == 
3)) {
-           struct console *restrict newc;
+       while ((fscanf(fc, "%*s %*s (%[^)]) %u:%u", &fbuf[0], &maj, &min) == 
3)) {
            dev_t dev;
 
            if (!strchr(fbuf, 'E'))
                continue;
-           if (strchr(fbuf, '*'))
+           if (strchr(fbuf, 'C'))
                continue;
            dev = makedev(maj, min);
 
            if (dev == tty)
                continue;
-           if (dev == st.st_rdev)
+           if (dev == rdev)
+               continue;
+
+           if (dev == makedev(TTY_MAJOR, 0))   /* Avoid endless loop */
                continue;
 
            if (!checkdev(&name, dev, ddev) || !name) {
@@ -1364,35 +1528,61 @@
                continue;
            }
 
-           if (posix_memalign((void*)&newc, sizeof(void*), 
alignof(typeof(struct console))) != 0)
-               error("memory allocation: %s\n", strerror(errno));
+           consalloc(cons, name);
+       }
+
+       popd();
+       closedir(ddev);
 
-           newc->next = (struct console*)0;
-           newc->tty = name;
-           if ((newc->fd = open(newc->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0) 
{
-               warn("can not open %s: %s\n", newc->tty, strerror(errno));
-               free(newc);
+       fclose(fc);
+       return;
+    }
+
+    if ((attrib = actattr("console"))) {
+       char *words = attrib, *token;
+
+       if (!(ddev = opendir("/dev")))
+           error("can not opendir(/dev): %m\n");
+       pushd("/dev");
+
+       while ((token = strsep(&words, " \t\n"))) {
+           dev_t dev;
+
+           if (*token == '\0')
                continue;
+
+           dev = devattr(token);
+
+           if (dev == makedev(TTY_MAJOR, 0)) {
+               char *tmp = actattr(token);
+               if (!tmp)
+                   continue;
+               dev = devattr(tmp);
+               free(tmp);
            }
-           tail->next = newc;
-           tail = tail->next;
 
-           if ((flags = fcntl(newc->fd, F_GETFL)) < 0) {
-               warn("can not get terminal flags of %s: %s\n", newc->tty, 
strerror(errno));
+           if (dev == tty)
+               continue;
+           if (dev == rdev)
                continue;
-           }
 
-           flags &= ~(O_NONBLOCK);
-           flags |=   O_NOCTTY;
-           if (fcntl(newc->fd, F_SETFL, flags) < 0) {
-               warn("can not set terminal flags of %s: %s\n", newc->tty, 
strerror(errno));
+           if (dev == makedev(TTY_MAJOR, 0))   /* Avoid endless loop */
+               continue;
+
+           if (!checkdev(&name, dev, ddev) || !name) {
+               if (name) {
+                   free(name);
+                   name = (char*)0;
+               }
+               continue;
            }
-       }
 
+           consalloc(cons, name);
+       }
        popd();
        closedir(ddev);
+       free(attrib);
 
-       fclose(fc);
        return;
     }
 
@@ -1425,15 +1615,19 @@
     }
 
     if (!(ddev = opendir("/dev")))
-       error("can not opendir(/dev): %s\n", strerror(errno));
+       error("can not opendir(/dev): %m\n");
     pushd("/dev");
 
     ptr = &buf[len];
     while (ptr >= &buf[0]) {
-       struct console *restrict newc;
        char *res = (char*)0;
-       struct stat st;
-       int flags;
+#ifdef TIOCGDEV
+       unsigned int devnum;
+#else
+       struct vt_stat vt;
+#endif
+       dev_t dev;
+       int fd;
 
        if (*ptr == ',' || *ptr == ' ' || *ptr == '\t' || *ptr == '\r' || *ptr 
== '\n') {
            *ptr-- = 0;
@@ -1461,45 +1655,58 @@
        if (!res)
            continue;
 
-       if (stat(res, &st) < 0) {
-           warn("can not stat /dev/%s: %s\n", res, strerror(errno));
+       /* Open second console e.g. /dev/tty0 */
+       if ((fd = open(res, O_RDWR|O_NONBLOCK|O_NOCTTY)) < 0)
            continue;
-       }
 
-       if (st.st_rdev == tty)
+       /*
+        * We do this because if we would write out the buffered
+        * messages to e.g. /dev/tty0 after this we would (re)read
+        * those and buffer them again which leads to an endless loop.
+        */
+#ifdef TIOCGDEV
+       if (ioctl (fd, TIOCGDEV, &devnum) < 0) {
+           if (errno == EINVAL && !getenv("NOTIOCGDEV"))
+               warn("Warning: the ioctl TIOCGDEV is not known by the 
kernel\n");
+           close(fd);
            continue;
-
-       if (!checkdev(&name, st.st_rdev, ddev) || !name) {
-           if (name) {
-               free(name);
-               name = (char*)0;
-           }
+       }
+       dev = (dev_t)devnum;
+#else
+       if (fstat(fd, &st) < 0) {
+           close(fd);
            continue;
        }
+       dev = st.st_rdev;
+       if (dev == makedev(TTY_MAJOR, 0)) {
+           if (ioctl(fd, VT_GETSTATE, &vt) < 0) {
+               if (errno == EINVAL)
+                   warn("Warning: the ioctl VT_GETSTATE is not known by the 
kernel\n");
+               close(fd);
+               continue;
+           }
+           dev = makedev(TTY_MAJOR, (int)vt.v_active);
+       }
+#endif
+       close(fd);
 
-       if (posix_memalign((void*)&newc, sizeof(void*), alignof(typeof(struct 
console))) != 0)
-           error("memory allocation: %s\n", strerror(errno));
+       if (dev == tty)
+           continue;
+       if (dev == rdev)
+           continue;
 
-       newc->next = (struct console*)0;
-       newc->tty = name;
-       if ((newc->fd = open(newc->tty, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
-           warn("can not open %s: %s\n", newc->tty, strerror(errno));
-           free(newc);
+       if (dev == makedev(TTY_MAJOR, 0))       /* Avoid endless loop */
            continue;
-       }
-       tail->next = newc;
-       tail = tail->next;
 
-       if ((flags = fcntl(newc->fd, F_GETFL)) < 0) {
-           warn("can not get terminal flags of %s: %s\n", newc->tty, 
strerror(errno));
+       if (!checkdev(&name, dev, ddev) || !name) {
+           if (name) {
+               free(name);
+               name = (char*)0;
+           }
            continue;
        }
 
-       flags &= ~(O_NONBLOCK);
-       flags |=   O_NOCTTY;
-       if (fcntl(newc->fd, F_SETFL, flags) < 0) {
-           warn("can not set terminal flags of %s: %s\n", newc->tty, 
strerror(errno));
-       }
+       consalloc(cons, name);
     }
 
     popd();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/libconsole.h 
new/showconsole-1.14/libconsole.h
--- old/showconsole-1.13/libconsole.h   2010-09-23 11:25:03.000000000 +0200
+++ new/showconsole-1.14/libconsole.h   2011-03-25 09:37:16.000000000 +0100
@@ -27,6 +27,9 @@
 # ifndef  extension
 #  define extension            __extension__
 # endif
+# ifndef  typeof
+#  define typeof               __typeof__
+# endif
 #endif
 #ifndef  attribute
 # define attribute(attr)       __attribute__(attr)
@@ -38,6 +41,8 @@
     struct termios ltio, otio;
     struct console *restrict next;
 };
+extern void error (const char *fmt, ...) attribute((__noreturn__, 
__format__(__printf__, 1, 2)));
+extern void warn  (const char *fmt, ...) attribute((__format__(__printf__, 1, 
2)));
 extern void pushd(const char *);
 extern void popd(void);
 extern char * fetchtty(const pid_t, const pid_t, dev_t *);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/showconsole-1.13.lsm 
new/showconsole-1.14/showconsole-1.13.lsm
--- old/showconsole-1.13/showconsole-1.13.lsm   2010-10-21 11:57:37.000000000 
+0200
+++ new/showconsole-1.14/showconsole-1.13.lsm   1970-01-01 01:00:00.000000000 
+0100
@@ -1,15 +0,0 @@
-Begin3
-Title:         console tools for boot scripts
-Version:       1.13
-Entered-date:  21OCT10
-Description:   Used for fetch the real device in boot scripts
-               running on /dev/console.
-Keywords:      boot control
-Author:                Werner Fink <[email protected]>
-Maintained-by: Werner Fink <[email protected]>
-Primary-site:  sunsite.unc.edu /pub/Linux/system/daemons/init
-               @UNKNOWN showconsole-1.13.tar.gz
-Alternate-site:        ftp.suse.com /pub/projects/init
-Platforms:     Linux with System VR2 or higher boot scheme
-Copying-policy:        GPL
-End
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/showconsole-1.14.lsm 
new/showconsole-1.14/showconsole-1.14.lsm
--- old/showconsole-1.13/showconsole-1.14.lsm   1970-01-01 01:00:00.000000000 
+0100
+++ new/showconsole-1.14/showconsole-1.14.lsm   2011-03-25 18:55:24.000000000 
+0100
@@ -0,0 +1,15 @@
+Begin3
+Title:         console tools for boot scripts
+Version:       1.14
+Entered-date:  25MAR11
+Description:   Used for fetch the real device in boot scripts
+               running on /dev/console.
+Keywords:      boot control
+Author:                Werner Fink <[email protected]>
+Maintained-by: Werner Fink <[email protected]>
+Primary-site:  sunsite.unc.edu /pub/Linux/system/daemons/init
+               @UNKNOWN showconsole-1.14.tar.gz
+Alternate-site:        ftp.suse.com /pub/projects/init
+Platforms:     Linux with System VR2 or higher boot scheme
+Copying-policy:        GPL
+End
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/showconsole.8 
new/showconsole-1.14/showconsole.8
--- old/showconsole-1.13/showconsole.8  2010-08-26 13:36:11.000000000 +0200
+++ new/showconsole-1.14/showconsole.8  2010-11-09 17:00:14.000000000 +0100
@@ -22,8 +22,7 @@
 .SH DESCRIPTION
 .B showconsole
 determines the real character device of
-the current
-.BR stdin.
+the current system console.
 This can be used on
 .I /dev/console
 as current character device to
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/showconsole-1.13/showconsole.c 
new/showconsole-1.14/showconsole.c
--- old/showconsole-1.13/showconsole.c  2010-09-23 11:24:42.000000000 +0200
+++ new/showconsole-1.14/showconsole.c  2011-03-25 18:53:19.000000000 +0100
@@ -19,6 +19,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <signal.h>
 #include "libconsole.h"
 
 /*
@@ -76,7 +77,7 @@
            fd = open("/dev/console", O_RDWR|O_NOCTTY);
 
        if (fd < 0)
-           error("can not open console: %s\n", strerror(errno));
+           error("can not open console: %m\n");
 
        (void)ioctl(fd, TIOCCONS, NULL);        /* Undo any current map if any 
*/
        close(fd);
@@ -91,13 +92,13 @@
            goto out;
 
        if ((fd = open(argv[1], O_WRONLY|O_NOCTTY)) < 0)
-           error("can not open %s: %s\n", argv[1], strerror(errno));
+           error("can not open %s: %m\n", argv[1]);
 
        if (!isatty(fd))
            error("%s is not a tty.\n", argv[1]);
 
        if (ioctl(fd, TIOCCONS, NULL) < 0)
-           error("can not set console device: %s\n", strerror(errno));
+           error("can not set console device: %m\n");
 
        goto out;
     }


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to