X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fmain.c;h=2d393deb9eec87f31534f275f6d56e34f07b5839;hp=0df1f6423a8f09d191efca6d65a1794ebee7c314;hb=e62d9b81926e22f7a1d8a117fd85bb735d3cead2;hpb=81f5fc2d43800c23a4440ed94cfe38d579e896fe diff --git a/src/core/main.c b/src/core/main.c index 0df1f6423..2d393deb9 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -23,11 +23,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -40,14 +38,12 @@ #endif #include "sd-daemon.h" -#include "sd-messages.h" #include "sd-bus.h" #include "log.h" #include "fdset.h" #include "special.h" #include "conf-parser.h" #include "missing.h" -#include "label.h" #include "pager.h" #include "build.h" #include "strv.h" @@ -55,7 +51,6 @@ #include "virt.h" #include "architecture.h" #include "watchdog.h" -#include "path-util.h" #include "switch-root.h" #include "capability.h" #include "killall.h" @@ -161,7 +156,7 @@ noreturn static void crash(int sig) { setrlimit(RLIMIT_CORE, &rl); /* Just to be sure... */ - chdir("/"); + (void) chdir("/"); /* Raise the signal again */ pid = raw_getpid(); @@ -280,10 +275,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { "s", SPECIAL_RESCUE_TARGET, "S", SPECIAL_RESCUE_TARGET, "1", SPECIAL_RESCUE_TARGET, - "2", SPECIAL_RUNLEVEL2_TARGET, - "3", SPECIAL_RUNLEVEL3_TARGET, - "4", SPECIAL_RUNLEVEL4_TARGET, - "5", SPECIAL_RUNLEVEL5_TARGET, + "2", SPECIAL_MULTI_USER_TARGET, + "3", SPECIAL_MULTI_USER_TARGET, + "4", SPECIAL_MULTI_USER_TARGET, + "5", SPECIAL_GRAPHICAL_TARGET, }; int r; @@ -367,8 +362,6 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { } else if (streq(key, "quiet") && !value) { - log_set_max_level(LOG_NOTICE); - if (arg_show_status == _SHOW_STATUS_UNSET) arg_show_status = SHOW_STATUS_AUTO; @@ -1217,11 +1210,11 @@ int main(int argc, char *argv[]) { FDSet *fds = NULL; bool reexecute = false; const char *shutdown_verb = NULL; - dual_timestamp initrd_timestamp = { 0ULL, 0ULL }; - dual_timestamp userspace_timestamp = { 0ULL, 0ULL }; - dual_timestamp kernel_timestamp = { 0ULL, 0ULL }; - dual_timestamp security_start_timestamp = { 0ULL, 0ULL }; - dual_timestamp security_finish_timestamp = { 0ULL, 0ULL }; + dual_timestamp initrd_timestamp = DUAL_TIMESTAMP_NULL; + dual_timestamp userspace_timestamp = DUAL_TIMESTAMP_NULL; + dual_timestamp kernel_timestamp = DUAL_TIMESTAMP_NULL; + dual_timestamp security_start_timestamp = DUAL_TIMESTAMP_NULL; + dual_timestamp security_finish_timestamp = DUAL_TIMESTAMP_NULL; static char systemd[] = "systemd"; bool skip_setup = false; unsigned j; @@ -1230,7 +1223,7 @@ int main(int argc, char *argv[]) { bool queue_default_job = false; bool empty_etc = false; char *switch_root_dir = NULL, *switch_root_init = NULL; - static struct rlimit saved_rlimit_nofile = { 0, 0 }; + struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0); const char *error_message = NULL; #ifdef HAVE_SYSV_COMPAT @@ -1539,11 +1532,11 @@ int main(int argc, char *argv[]) { detect_virtualization(&virtualization); if (virtualization) - log_info("Detected virtualization '%s'.", virtualization); + log_info("Detected virtualization %s.", virtualization); write_container_id(); - log_info("Detected architecture '%s'.", architecture_to_string(uname_architecture())); + log_info("Detected architecture %s.", architecture_to_string(uname_architecture())); if (in_initrd()) log_info("Running in initial RAM disk."); @@ -1883,7 +1876,7 @@ finish: args = newa(const char*, args_size); if (!switch_root_init) { - char sfd[16]; + char sfd[DECIMAL_STR_MAX(int) + 1]; /* First try to spawn ourselves with the right * path, and with full serialization. We do @@ -1893,8 +1886,7 @@ finish: assert(arg_serialization); assert(fds); - snprintf(sfd, sizeof(sfd), "%i", fileno(arg_serialization)); - char_array_0(sfd); + xsprintf(sfd, "%i", fileno(arg_serialization)); i = 0; args[i++] = SYSTEMD_BINARY_PATH; @@ -1995,7 +1987,7 @@ finish: assert(command_line[pos] == NULL); env_block = strv_copy(environ); - snprintf(log_level, sizeof(log_level), "%d", log_get_max_level()); + xsprintf(log_level, "%d", log_get_max_level()); switch (log_get_target()) { case LOG_TARGET_KMSG: @@ -2024,8 +2016,8 @@ finish: /* If we reboot let's set the shutdown * watchdog and tell the shutdown binary to * repeatedly ping it */ - watchdog_set_timeout(&arg_shutdown_watchdog); - watchdog_close(false); + r = watchdog_set_timeout(&arg_shutdown_watchdog); + watchdog_close(r < 0); /* Tell the binary how often to ping, ignore failure */ if (asprintf(&e, "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog) > 0)