[systemd-commits] 2 commits - TODO src/getty-generator

Lennart Poettering lennart at kemper.freedesktop.org
Sun Feb 23 19:04:41 PST 2014


 TODO                                  |    3 ---
 src/getty-generator/getty-generator.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

New commits:
commit 46a96f43239a5bbbb9e2e440e8ae7f3964a33fc3
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 24 04:04:23 2014 +0100

    update TODO

diff --git a/TODO b/TODO
index a2ba0f5..29d9881 100644
--- a/TODO
+++ b/TODO
@@ -27,9 +27,6 @@ External:
 
 Features:
 
-* make eparis happy: in the getty generator open ttys to run gettys on
-  first with O_NDELAY and check isatty() to filter out invalid ttys.
-
 * MessageQueueMessageSize= and RLimitFSIZE= (and suchlike) should use parse_iec_size().
 
 * man: move .link, .network and .netdev documentation into their own

commit 543407517e05688915128cfc544c5d7f97f240ef
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 24 03:59:50 2014 +0100

    getty-generator: verify ttys before we make use of them
    
    The ttyS[0-3] devices are weird. They may be enumerated, but when one
    actually tries to open and use them they return EIO, because they don't
    actually exist. Because they may be enumerated they may be specified on
    the kernel command line as console=. And some people do that as default.
    As response to that we'll spawn a getty on the tty that will quickly
    fail, and we retry a couple of time before giving up. That is quite
    noisy.
    
    With this new change we will validate all serial terminals configured
    with console= on the kernel cmdline before adding gettys on them, and
    remove the invalid ones. THis should remove the noise later on.
    
    This should make Eric Paris happy!

diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
index f352a29..08b3b1e 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include "log.h"
 #include "util.h"
@@ -92,6 +93,30 @@ static int add_container_getty(const char *tty) {
         return add_symlink("container-getty at .service", n);
 }
 
+static int verify_tty(const char *name) {
+        _cleanup_close_ int fd = -1;
+        const char *p;
+
+        /* Some TTYs are weird and have been enumerated but don't work
+         * when you try to use them, such as classic ttyS0 and
+         * friends. Let's check that and open the device and run
+         * isatty() on it. */
+
+        p = strappenda("/dev/", name);
+
+        /* O_NONBLOCK is essential here, to make sure we don't wait
+         * for DCD */
+        fd = open(p, O_RDWR|O_NONBLOCK|O_NOCTTY|O_CLOEXEC|O_NOFOLLOW);
+        if (fd < 0)
+                return -errno;
+
+        errno = 0;
+        if (isatty(fd) <= 0)
+                return errno ? -errno : -EIO;
+
+        return 0;
+}
+
 int main(int argc, char *argv[]) {
 
         static const char virtualization_consoles[] =
@@ -180,6 +205,9 @@ int main(int argc, char *argv[]) {
                         if (isempty(tty) || tty_is_vc(tty))
                                 continue;
 
+                        if (verify_tty(tty) < 0)
+                                continue;
+
                         /* We assume that gettys on virtual terminals are
                          * started via manual configuration and do this magic
                          * only for non-VC terminals. */



More information about the systemd-commits mailing list