From 38a274114d5c542a650db6d80b7e673be2cee6e3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 14 Oct 2017 13:14:48 +0200 Subject: [PATCH] Allow registering TTYs that are not yet available This patch removes the following very annoying warning for TTY devices not yet available, i.e. plugged-in to the system. Loading configuration ............................................................................. [ OK ] [ 11.097414] finit[1]:tty_register():Incomplete or non-existing TTY device given, cannot register. [ 11.101457] finit[1]:tty_register():Incomplete or non-existing TTY device given, cannot register. Mounting filesystems .............................................................................. [ OK ] Finit will not start a getty (built-in or external) if the TTY does not exist, but having the configuration enabled makes it possible to do a simple `initctl reload` to activate a plugged in TTY. Signed-off-by: Joachim Nilsson --- src/tty.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tty.c b/src/tty.c index 19766939..9b3e44a9 100644 --- a/src/tty.c +++ b/src/tty.c @@ -53,9 +53,15 @@ static char *canonicalize(char *tty) strlcpy(path, tty, sizeof(path)); if (stat(path, &st)) { + if (!strncmp(path, _PATH_DEV, strlen(_PATH_DEV))) { + unavailable: + _d("TTY %s not available at the moment, registering anyway.", path); + return path; + } + snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty); if (stat(path, &st)) - return NULL; + goto unavailable; } if (!S_ISCHR(st.st_mode))