X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmain.c;h=d5d1ee2b0ceff67aeb66dce923d525d3b41dd34d;hb=6d313367d9ef780560e117e886502a99fa220eac;hp=cc876efa9c2c0377464c070b7e20c29774040bf2;hpb=92f2f92edcad46ce4098ee26504edca0a1dad68e;p=elogind.git diff --git a/src/core/main.c b/src/core/main.c index cc876efa9..d5d1ee2b0 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -61,7 +61,7 @@ #include "capability.h" #include "killall.h" #include "env-util.h" -#include "hwclock.h" +#include "clock-util.h" #include "fileio.h" #include "dbus-manager.h" #include "bus-error.h" @@ -108,6 +108,7 @@ static char **arg_default_environment = NULL; static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {}; static uint64_t arg_capability_bounding_set_drop = 0; static nsec_t arg_timer_slack_nsec = (nsec_t) -1; +static usec_t arg_default_timer_accuracy_usec = 1 * USEC_PER_MINUTE; static Set* arg_syscall_archs = NULL; static FILE* arg_serialization = NULL; static bool arg_default_cpu_accounting = false; @@ -240,7 +241,7 @@ static int console_setup(bool do_reset) { if (r < 0) log_error("Failed to reset /dev/console: %s", strerror(-r)); - close_nointr_nofail(tty_fd); + safe_close(tty_fd); return r; } @@ -411,18 +412,13 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { } } else if (streq(key, "quiet") && !value) { - if (arg_show_status == _SHOW_STATUS_UNSET) arg_show_status = SHOW_STATUS_AUTO; } else if (streq(key, "debug") && !value) { - - /* Log to kmsg, the journal socket will fill up before the - * journal is started and tools running during that time - * will block with every log message for for 60 seconds, - * before they give up. */ log_set_max_level(LOG_DEBUG); - log_set_target(detect_container(NULL) > 0 ? LOG_TARGET_CONSOLE : LOG_TARGET_KMSG); + if (detect_container(NULL) > 0) + log_set_target(LOG_TARGET_CONSOLE); } else if (!in_initrd() && !value) { unsigned i; @@ -686,6 +682,7 @@ static int parse_config_file(void) { { "Manager", "SystemCallArchitectures", config_parse_syscall_archs, 0, &arg_syscall_archs }, #endif { "Manager", "TimerSlackNSec", config_parse_nsec, 0, &arg_timer_slack_nsec }, + { "Manager", "DefaultTimerAccuracySec", config_parse_sec, 0, &arg_default_timer_accuracy_usec }, { "Manager", "DefaultStandardOutput", config_parse_output, 0, &arg_default_std_output }, { "Manager", "DefaultStandardError", config_parse_output, 0, &arg_default_std_error }, { "Manager", "DefaultTimeoutStartSec", config_parse_sec, 0, &arg_default_timeout_start_usec }, @@ -1185,21 +1182,6 @@ static void test_usr(void) { "Consult http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken for more information."); } -static void test_cgroups(void) { - - if (access("/proc/cgroups", F_OK) >= 0) - return; - - log_warning("CONFIG_CGROUPS was not set when your kernel was compiled. " - "Systems without control groups are not supported. " - "We will now sleep for 10s, and then continue boot-up. " - "Expect breakage and please do not file bugs. " - "Instead fix your kernel and enable CONFIG_CGROUPS. " - "Consult http://0pointer.de/blog/projects/cgroups-vs-cgroups.html for more information."); - - sleep(10); -} - static int initialize_join_controllers(void) { /* By default, mount "cpu" + "cpuacct" together, and "net_cls" * + "net_prio". We'd like to add "cpuset" to the mix, but @@ -1279,6 +1261,16 @@ static int status_welcome(void) { isempty(pretty_name) ? "Linux" : pretty_name); } +static int write_container_id(void) { + const char *c; + + c = getenv("container"); + if (isempty(c)) + return 0; + + return write_string_file("/run/systemd/container", c); +} + int main(int argc, char *argv[]) { Manager *m = NULL; int r, retval = EXIT_FAILURE; @@ -1370,11 +1362,11 @@ int main(int argc, char *argv[]) { goto finish; if (!skip_setup) { - if (hwclock_is_localtime() > 0) { + if (clock_is_localtime() > 0) { int min; /* The first-time call to settimeofday() does a time warp in the kernel */ - r = hwclock_set_timezone(&min); + r = clock_set_timezone(&min); if (r < 0) log_error("Failed to apply local time delta, ignoring: %s", strerror(-r)); else @@ -1388,10 +1380,10 @@ int main(int argc, char *argv[]) { * that way. In such case, we need to delay the time-warp or the sealing * until we reach the real system. */ - hwclock_reset_timezone(); + clock_reset_timezone(); /* Tell the kernel our timezone */ - r = hwclock_set_timezone(NULL); + r = clock_set_timezone(NULL); if (r < 0) log_error("Failed to set the kernel's timezone, ignoring: %s", strerror(-r)); } @@ -1562,6 +1554,8 @@ int main(int argc, char *argv[]) { if (virtualization) log_info("Detected virtualization '%s'.", virtualization); + write_container_id(); + log_info("Detected architecture '%s'.", architecture_to_string(uname_architecture())); if (in_initrd()) @@ -1587,7 +1581,6 @@ int main(int argc, char *argv[]) { test_mtab(); test_usr(); - test_cgroups(); } if (arg_running_as == SYSTEMD_SYSTEM && arg_runtime_watchdog > 0) @@ -1635,6 +1628,7 @@ int main(int argc, char *argv[]) { } m->confirm_spawn = arg_confirm_spawn; + m->default_timer_accuracy_usec = arg_default_timer_accuracy_usec; m->default_std_output = arg_default_std_output; m->default_std_error = arg_default_std_error; m->default_restart_usec = arg_default_restart_usec;