[systemd-commits] 2 commits - src/main.c src/manager.c src/manager.h src/target.c src/util.c

Lennart Poettering lennart at kemper.freedesktop.org
Mon Feb 14 10:57:25 PST 2011


 src/main.c    |   25 -------------------------
 src/manager.c |   17 -----------------
 src/manager.h |    2 --
 src/target.c  |   44 ++++++++++++++++++++++++++++++--------------
 src/util.c    |    8 +++++++-
 5 files changed, 37 insertions(+), 59 deletions(-)

New commits:
commit 6a3b1508f7a9c8ecf712beb44baa13f252f0d3d8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 14 19:57:18 2011 +0100

    getty: don't parse console= anymore, use /sys/class/tty/console/active instead

diff --git a/src/main.c b/src/main.c
index d1eeffb..d9dd0ac 100644
--- a/src/main.c
+++ b/src/main.c
@@ -72,7 +72,6 @@ static bool arg_sysv_console = true;
 #endif
 static bool arg_mount_auto = true;
 static bool arg_swap_auto = true;
-static char *arg_console = NULL;
 static char **arg_default_controllers = NULL;
 
 static FILE* serialization = NULL;
@@ -329,26 +328,6 @@ static int parse_proc_cmdline_word(const char *word) {
                          "systemd.log_color=0|1                    Highlight important log messages\n"
                          "systemd.log_location=0|1                 Include code location in log messages\n");
 
-        } else if (startswith(word, "console=")) {
-                const char *k;
-                size_t l;
-                char *w = NULL;
-
-                k = word + 8;
-                l = strcspn(k, ",");
-
-                /* Ignore the console setting if set to a VT */
-                if (l < 4 ||
-                    !startswith(k, "tty") ||
-                    k[3+strspn(k+3, "0123456789")] != 0) {
-
-                        if (!(w = strndup(k, l)))
-                                return -ENOMEM;
-                }
-
-                free(arg_console);
-                arg_console = w;
-
         } else if (streq(word, "quiet")) {
                 arg_show_status = false;
 #ifdef HAVE_SYSV_COMPAT
@@ -1094,9 +1073,6 @@ int main(int argc, char *argv[]) {
         if (dual_timestamp_is_set(&initrd_timestamp))
                 m->initrd_timestamp = initrd_timestamp;
 
-        if (arg_console)
-                manager_set_console(m, arg_console);
-
         if (arg_default_controllers)
                 manager_set_default_controllers(m, arg_default_controllers);
 
@@ -1221,7 +1197,6 @@ finish:
                 manager_free(m);
 
         free(arg_default_unit);
-        free(arg_console);
         strv_free(arg_default_controllers);
 
         dbus_shutdown();
diff --git a/src/manager.c b/src/manager.c
index 4a84082..92b2745 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -461,7 +461,6 @@ void manager_free(Manager *m) {
 #endif
 
         free(m->notify_socket);
-        free(m->console);
 
         lookup_paths_free(&m->lookup_paths);
         strv_free(m->environment);
@@ -2783,22 +2782,6 @@ void manager_reset_failed(Manager *m) {
                 unit_reset_failed(u);
 }
 
-int manager_set_console(Manager *m, const char *console) {
-        char *c;
-
-        assert(m);
-
-        if (!(c = strdup(console)))
-                return -ENOMEM;
-
-        free(m->console);
-        m->console = c;
-
-        log_debug("Using kernel console %s", c);
-
-        return 0;
-}
-
 bool manager_unit_pending_inactive(Manager *m, const char *name) {
         Unit *u;
 
diff --git a/src/manager.h b/src/manager.h
index d8559f1..a329ee9 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -148,7 +148,6 @@ struct Manager {
         dual_timestamp startup_timestamp;
         dual_timestamp finish_timestamp;
 
-        char *console;
         char *generator_unit_path;
 
         /* Data specific to the device subsystem */
@@ -256,7 +255,6 @@ unsigned manager_dispatch_load_queue(Manager *m);
 unsigned manager_dispatch_run_queue(Manager *m);
 unsigned manager_dispatch_dbus_queue(Manager *m);
 
-int manager_set_console(Manager *m, const char *console);
 int manager_set_default_controllers(Manager *m, char **controllers);
 
 int manager_loop(Manager *m);
diff --git a/src/target.c b/src/target.c
index 7313007..27b54e3 100644
--- a/src/target.c
+++ b/src/target.c
@@ -81,7 +81,7 @@ static int target_add_default_dependencies(Target *t) {
 }
 
 static int target_add_getty_dependencies(Target *t) {
-        char *n;
+        char *n, *active;
         int r;
 
         assert(t);
@@ -89,23 +89,39 @@ static int target_add_getty_dependencies(Target *t) {
         if (!unit_has_name(UNIT(t), SPECIAL_GETTY_TARGET))
                 return 0;
 
-        /* Automatically add in a serial getty on the kernel
-         * console */
-        if (t->meta.manager->console && !tty_is_vc(t->meta.manager->console)) {
+        if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
+                const char *tty;
 
-                /* We assume that gettys on virtual terminals are
-                 * started via manual configuration and do this magic
-                 * only for non-VC terminals. */
+                truncate_nl(active);
+                if ((tty = strrchr(active, ' ')))
+                        tty ++;
+                else
+                        tty = active;
 
-                log_debug("Automatically adding serial getty for %s", t->meta.manager->console);
-                if (!(n = unit_name_replace_instance(SPECIAL_SERIAL_GETTY_SERVICE, t->meta.manager->console)))
-                        return -ENOMEM;
+                /* Automatically add in a serial getty on the kernel
+                 * console */
+                if (!tty_is_vc(tty)) {
 
-                r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_WANTS, n, NULL, true);
-                free(n);
+                        /* We assume that gettys on virtual terminals are
+                         * started via manual configuration and do this magic
+                         * only for non-VC terminals. */
 
-                if (r < 0)
-                        return r;
+                        log_debug("Automatically adding serial getty for /dev/%s", tty);
+                        if (!(n = unit_name_replace_instance(SPECIAL_SERIAL_GETTY_SERVICE, tty))) {
+                                free(active);
+                                return -ENOMEM;
+                        }
+
+                        r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_WANTS, n, NULL, true);
+                        free(n);
+
+                        if (r < 0) {
+                                free(active);
+                                return r;
+                        }
+                }
+
+                free(active);
         }
 
         /* Automatically add in a serial getty on the first

commit 079a09fbf79050c0794bac0f87d3600ffd5b9db2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 14 19:54:15 2011 +0100

    util: properly resolve /dev/console if more than once console= argument was passed on the kernel command line

diff --git a/src/util.c b/src/util.c
index d0c9039..80b88b0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3573,7 +3573,13 @@ const char *default_term_for_tty(const char *tty) {
         if (streq(tty, "console"))
                 if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
                         truncate_nl(active);
-                        tty = active;
+
+                        /* If multiple log outputs are configured the
+                         * last one is what /dev/console points to */
+                        if ((tty = strrchr(active, ' ')))
+                                tty++;
+                        else
+                                tty = active;
                 }
 
         term = tty_is_vc(tty) ? "TERM=linux" : "TERM=vt100";



More information about the systemd-commits mailing list