chiark / gitweb /
getty: don't parse console= anymore, use /sys/class/tty/console/active instead
authorLennart Poettering <lennart@poettering.net>
Mon, 14 Feb 2011 18:57:18 +0000 (19:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 14 Feb 2011 18:57:18 +0000 (19:57 +0100)
src/main.c
src/manager.c
src/manager.h
src/target.c

index d1eeffb12ee0b23f70d1af1686bed0e22f3e7bf1..d9dd0ac4924ba028e9448faba34e24260ff6ae54 100644 (file)
@@ -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();
index 4a8408212a645cb2c33e6ee38989c439de5108b6..92b274590bacacfe1a68574811d94085795b7599 100644 (file)
@@ -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;
 
index d8559f1bec40a7ccf580215e0929801606ca60a9..a329ee925f5ce698de59ef3725e3648de45f9838 100644 (file)
@@ -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);
index 73130078d991f57e5547c000f5a7ffef5dea281d..27b54e380891c907c91d5d9b5b694c685697e84f 100644 (file)
@@ -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