pid = fork();
if (pid < 0)
- log_emergency("Caught <%s>, cannot fork for core dump: %m", signal_to_string(sig));
+ log_emergency_errno(errno, "Caught <%s>, cannot fork for core dump: %m", signal_to_string(sig));
else if (pid == 0) {
struct rlimit rl = {};
pid = fork();
if (pid < 0)
- log_emergency("Failed to fork off crash shell: %m");
+ log_emergency_errno(errno, "Failed to fork off crash shell: %m");
else if (pid == 0) {
make_console_stdio();
execl("/bin/sh", "/bin/sh", NULL);
- log_emergency("execl() failed: %m");
+ log_emergency_errno(errno, "execl() failed: %m");
_exit(1);
}
int r;
tty_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
- if (tty_fd < 0) {
- log_error_errno(tty_fd, "Failed to open /dev/console: %m");
- return tty_fd;
- }
+ if (tty_fd < 0)
+ return log_error_errno(tty_fd, "Failed to open /dev/console: %m");
/* We don't want to force text mode. plymouth may be showing
* pictures already from initrd. */
r = reset_terminal_fd(tty_fd, false);
- if (r < 0) {
- log_error_errno(r, "Failed to reset /dev/console: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to reset /dev/console: %m");
return 0;
}
{}
};
- const char *fn;
+ const char *fn, *conf_dirs_nulstr;
fn = arg_running_as == SYSTEMD_SYSTEM ? PKGSYSCONFDIR "/system.conf" : PKGSYSCONFDIR "/user.conf";
- config_parse(NULL, fn, NULL,
- "Manager\0",
- config_item_table_lookup, items,
- false, false, true, NULL);
+ conf_dirs_nulstr = arg_running_as == SYSTEMD_SYSTEM ? CONF_DIRS_NULSTR("systemd/system.conf") : CONF_DIRS_NULSTR("systemd/user.conf");
+ config_parse_many(fn, conf_dirs_nulstr, "Manager\0",
+ config_item_table_lookup, items, false, NULL);
return 0;
}
case ARG_UNIT:
r = set_default_unit(optarg);
- if (r < 0) {
- log_error_errno(r, "Failed to set default unit %s: %m", optarg);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to set default unit %s: %m", optarg);
break;
fd_cloexec(fd, true);
f = fdopen(fd, "r");
- if (!f) {
- log_error("Failed to open serialization fd: %m");
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open serialization fd: %m");
if (arg_serialization)
fclose(arg_serialization);
}
if (fseeko(f, 0, SEEK_SET) < 0) {
- log_error("Failed to rewind serialization fd: %m");
+ log_error_errno(errno, "Failed to rewind serialization fd: %m");
goto fail;
}
/* Save the original RLIMIT_NOFILE so that we can reset it
* later when transitioning from the initrd to the main
* systemd or suchlike. */
- if (getrlimit(RLIMIT_NOFILE, saved_rlimit) < 0) {
- log_error("Reading RLIMIT_NOFILE failed: %m");
- return -errno;
- }
+ if (getrlimit(RLIMIT_NOFILE, saved_rlimit) < 0)
+ return log_error_errno(errno, "Reading RLIMIT_NOFILE failed: %m");
/* Make sure forked processes get the default kernel setting */
if (!arg_default_rlimit[RLIMIT_NOFILE]) {
/* Bump up the resource limit for ourselves substantially */
nl.rlim_cur = nl.rlim_max = 64*1024;
r = setrlimit_closest(RLIMIT_NOFILE, &nl);
- if (r < 0) {
- log_error_errno(r, "Setting RLIMIT_NOFILE failed: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Setting RLIMIT_NOFILE failed: %m");
return 0;
}
errno = -ENOENT;
execv(SYSTEMCTL_BINARY_PATH, argv);
- log_error("Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
+ log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
return 1;
}
#endif
if (arg_timer_slack_nsec != NSEC_INFINITY)
if (prctl(PR_SET_TIMERSLACK, arg_timer_slack_nsec) < 0)
- log_error("Failed to adjust timer slack: %m");
+ log_error_errno(errno, "Failed to adjust timer slack: %m");
if (arg_capability_bounding_set_drop) {
r = capability_bounding_set_drop_usermode(arg_capability_bounding_set_drop);
if (arg_running_as == SYSTEMD_USER) {
/* Become reaper of our children */
if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
- log_warning("Failed to make us a subreaper: %m");
+ log_warning_errno(errno, "Failed to make us a subreaper: %m");
if (errno == EINVAL)
log_info("Perhaps the kernel version is too old (< 3.4?)");
}
if (switch_root_init) {
args[0] = switch_root_init;
execv(args[0], (char* const*) args);
- log_warning("Failed to execute configured init, trying fallback: %m");
+ log_warning_errno(errno, "Failed to execute configured init, trying fallback: %m");
}
args[0] = "/sbin/init";
args[0] = "/bin/sh";
args[1] = NULL;
execv(args[0], (char* const*) args);
- log_error("Failed to execute /bin/sh, giving up: %m");
+ log_error_errno(errno, "Failed to execute /bin/sh, giving up: %m");
} else
- log_warning("Failed to execute /sbin/init, giving up: %m");
+ log_warning_errno(errno, "Failed to execute /sbin/init, giving up: %m");
}
if (arg_serialization) {
cg_uninstall_release_agent(SYSTEMD_CGROUP_CONTROLLER);
execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, env_block);
- log_error("Failed to execute shutdown binary, %s: %m",
+ log_error_errno(errno, "Failed to execute shutdown binary, %s: %m",
getpid() == 1 ? "freezing" : "quitting");
}