diff options
-rw-r--r-- | src/main.c | 25 | ||||
-rw-r--r-- | src/manager.c | 17 | ||||
-rw-r--r-- | src/manager.h | 2 | ||||
-rw-r--r-- | src/target.c | 44 |
4 files changed, 30 insertions, 58 deletions
diff --git a/src/main.c b/src/main.c index d1eeffb12e..d9dd0ac492 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 4a8408212a..92b274590b 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 d8559f1bec..a329ee925f 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 73130078d9..27b54e3808 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 |