summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/audit-fd.c2
-rw-r--r--src/core/automount.c4
-rw-r--r--src/core/cgroup.c8
-rw-r--r--src/core/dbus.c8
-rw-r--r--src/core/device.c2
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/hostname-setup.c2
-rw-r--r--src/core/ima-setup.c17
-rw-r--r--src/core/killall.c10
-rw-r--r--src/core/load-dropin.c2
-rw-r--r--src/core/machine-id-setup.c8
-rw-r--r--src/core/main.c26
-rw-r--r--src/core/manager.c38
-rw-r--r--src/core/mount-setup.c6
-rw-r--r--src/core/namespace.c10
-rw-r--r--src/core/path.c6
-rw-r--r--src/core/selinux-access.c2
-rw-r--r--src/core/shutdown.c10
-rw-r--r--src/core/smack-setup.c12
-rw-r--r--src/core/umount.c8
20 files changed, 91 insertions, 92 deletions
diff --git a/src/core/audit-fd.c b/src/core/audit-fd.c
index 4326d17360..5a18e263a8 100644
--- a/src/core/audit-fd.c
+++ b/src/core/audit-fd.c
@@ -41,7 +41,7 @@ int get_audit_fd(void) {
if (audit_fd < 0) {
if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
- log_error("Failed to connect to audit log: %m");
+ log_error_errno(errno, "Failed to connect to audit log: %m");
audit_fd = errno ? -errno : -EINVAL;
}
diff --git a/src/core/automount.c b/src/core/automount.c
index bc2834334e..8814d4c4fe 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -75,7 +75,7 @@ static void repeat_unmount(const char *path) {
continue;
if (errno != EINVAL)
- log_error("Failed to unmount: %m");
+ log_error_errno(errno, "Failed to unmount: %m");
break;
}
@@ -301,7 +301,7 @@ static int open_dev_autofs(Manager *m) {
m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
if (m->dev_autofs_fd < 0) {
- log_error("Failed to open /dev/autofs: %m");
+ log_error_errno(errno, "Failed to open /dev/autofs: %m");
return -errno;
}
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index c24bfc8d33..382e6a6ccc 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -154,7 +154,7 @@ static int lookup_blkio_device(const char *p, dev_t *dev) {
r = stat(p, &st);
if (r < 0) {
- log_warning("Couldn't stat device %s: %m", p);
+ log_warning_errno(errno, "Couldn't stat device %s: %m", p);
return -errno;
}
@@ -219,7 +219,7 @@ static int whitelist_major(const char *path, const char *name, char type, const
f = fopen("/proc/devices", "re");
if (!f) {
- log_warning("Cannot open /proc/devices to resolve %s (%c): %m", name, type);
+ log_warning_errno(errno, "Cannot open /proc/devices to resolve %s (%c): %m", name, type);
return -errno;
}
@@ -280,7 +280,7 @@ static int whitelist_major(const char *path, const char *name, char type, const
return 0;
fail:
- log_warning("Failed to read /proc/devices: %m");
+ log_warning_errno(errno, "Failed to read /proc/devices: %m");
return -errno;
}
@@ -906,7 +906,7 @@ int manager_setup_cgroup(Manager *m) {
m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
if (m->pin_cgroupfs_fd < 0) {
- log_error("Failed to open pin file: %m");
+ log_error_errno(errno, "Failed to open pin file: %m");
return -errno;
}
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 7291bdc3f3..925fac96b4 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -624,7 +624,7 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (nfd < 0) {
- log_warning("Failed to accept private connection, ignoring: %m");
+ log_warning_errno(errno, "Failed to accept private connection, ignoring: %m");
return 0;
}
@@ -959,19 +959,19 @@ static int bus_init_private(Manager *m) {
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (fd < 0) {
- log_error("Failed to allocate private socket: %m");
+ log_error_errno(errno, "Failed to allocate private socket: %m");
return -errno;
}
r = bind(fd, &sa.sa, salen);
if (r < 0) {
- log_error("Failed to bind private socket: %m");
+ log_error_errno(errno, "Failed to bind private socket: %m");
return -errno;
}
r = listen(fd, SOMAXCONN);
if (r < 0) {
- log_error("Failed to make private socket listening: %m");
+ log_error_errno(errno, "Failed to make private socket listening: %m");
return -errno;
}
diff --git a/src/core/device.c b/src/core/device.c
index 61dbebd37b..b254e45b33 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -628,7 +628,7 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
static RATELIMIT_DEFINE(limit, 10*USEC_PER_SEC, 5);
if (!ratelimit_test(&limit))
- log_error("Failed to get udev event: %m");
+ log_error_errno(errno, "Failed to get udev event: %m");
if (!(revents & EPOLLIN))
return 0;
}
diff --git a/src/core/execute.c b/src/core/execute.c
index f9011cfef5..c19f613641 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -885,7 +885,7 @@ fail:
log_error("PAM failed: %s", pam_strerror(handle, pam_code));
err = -EPERM; /* PAM errors do not map to errno */
} else {
- log_error("PAM failed: %m");
+ log_error_errno(errno, "PAM failed: %m");
err = -errno;
}
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index f81103a810..72e4c539ef 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -83,7 +83,7 @@ int hostname_setup(void) {
}
if (sethostname_idempotent(hn) < 0) {
- log_warning("Failed to set hostname to <%s>: %m", hn);
+ log_warning_errno(errno, "Failed to set hostname to <%s>: %m", hn);
return -errno;
}
diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c
index 7bffd8d9dd..3416802bcb 100644
--- a/src/core/ima-setup.c
+++ b/src/core/ima-setup.c
@@ -60,36 +60,35 @@ int ima_setup(void) {
}
if (stat(IMA_SECFS_POLICY, &st) < 0) {
- log_error("Another IMA custom policy has already been loaded, "
- "ignoring.");
+ log_error("Another IMA custom policy has already been loaded, ignoring.");
return 0;
}
policyfd = open(IMA_POLICY_PATH, O_RDONLY|O_CLOEXEC);
if (policyfd < 0) {
- log_error("Failed to open the IMA custom policy file %s (%m), "
- "ignoring.", IMA_POLICY_PATH);
+ log_error_errno(errno, "Failed to open the IMA custom policy file %s (%m), ignoring.",
+ IMA_POLICY_PATH);
return 0;
}
imafd = open(IMA_SECFS_POLICY, O_WRONLY|O_CLOEXEC);
if (imafd < 0) {
- log_error("Failed to open the IMA kernel interface %s (%m), "
- "ignoring.", IMA_SECFS_POLICY);
+ log_error_errno(errno, "Failed to open the IMA kernel interface %s (%m), ignoring.",
+ IMA_SECFS_POLICY);
goto out;
}
policy = mmap(NULL, policy_size, PROT_READ, MAP_PRIVATE, policyfd, 0);
if (policy == MAP_FAILED) {
- log_error("mmap() failed (%m), freezing");
+ log_error_errno(errno, "mmap() failed (%m), freezing");
result = -errno;
goto out;
}
written = loop_write(imafd, policy, (size_t)policy_size, false);
if (written != policy_size) {
- log_error("Failed to load the IMA custom policy file %s (%m), "
- "ignoring.", IMA_POLICY_PATH);
+ log_error_errno(errno, "Failed to load the IMA custom policy file %s (%m), ignoring.",
+ IMA_POLICY_PATH);
goto out_mmap;
}
diff --git a/src/core/killall.c b/src/core/killall.c
index a6ff50a5a4..5a50ae6f04 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -102,7 +102,7 @@ static void wait_for_children(Set *pids, sigset_t *mask) {
if (errno == ECHILD)
break;
- log_error("waitpid() failed: %m");
+ log_error_errno(errno, "waitpid() failed: %m");
return;
}
@@ -136,7 +136,7 @@ static void wait_for_children(Set *pids, sigset_t *mask) {
if (k != SIGCHLD) {
if (k < 0 && errno != EAGAIN) {
- log_error("sigtimedwait() failed: %m");
+ log_error_errno(errno, "sigtimedwait() failed: %m");
return;
}
@@ -178,7 +178,7 @@ static int killall(int sig, Set *pids, bool send_sighup) {
if (pids)
set_put(pids, ULONG_TO_PTR(pid));
} else if (errno != ENOENT)
- log_warning("Could not kill %d: %m", pid);
+ log_warning_errno(errno, "Could not kill %d: %m", pid);
if (send_sighup) {
/* Optionally, also send a SIGHUP signal, but
@@ -212,12 +212,12 @@ void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) == 0);
if (kill(-1, SIGSTOP) < 0 && errno != ESRCH)
- log_warning("kill(-1, SIGSTOP) failed: %m");
+ log_warning_errno(errno, "kill(-1, SIGSTOP) failed: %m");
killall(sig, pids, send_sighup);
if (kill(-1, SIGCONT) < 0 && errno != ESRCH)
- log_warning("kill(-1, SIGCONT) failed: %m");
+ log_warning_errno(errno, "kill(-1, SIGCONT) failed: %m");
if (wait_for_exit)
wait_for_children(pids, &mask);
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index 7a17baaf89..8afaf45fe6 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -58,7 +58,7 @@ static int iterate_dir(
if (errno == ENOENT)
return 0;
- log_error("Failed to open directory %s: %m", path);
+ log_error_errno(errno, "Failed to open directory %s: %m", path);
return -errno;
}
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index 10965df623..f31e357f15 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -196,7 +196,7 @@ int machine_id_setup(const char *root) {
"2) /etc/machine-id exists and is empty.\n"
"3) /etc/machine-id is missing and /etc is writable.\n");
else
- log_error("Cannot open %s: %m", etc_machine_id);
+ log_error_errno(errno, "Cannot open %s: %m", etc_machine_id);
return -errno;
}
@@ -205,7 +205,7 @@ int machine_id_setup(const char *root) {
}
if (fstat(fd, &st) < 0) {
- log_error("fstat() failed: %m");
+ log_error_errno(errno, "fstat() failed: %m");
return -errno;
}
@@ -248,7 +248,7 @@ int machine_id_setup(const char *root) {
/* And now, let's mount it over */
r = mount(run_machine_id, etc_machine_id, NULL, MS_BIND, NULL);
if (r < 0) {
- log_error("Failed to mount %s: %m", etc_machine_id);
+ log_error_errno(errno, "Failed to mount %s: %m", etc_machine_id);
unlink_noerrno(run_machine_id);
return -errno;
}
@@ -257,7 +257,7 @@ int machine_id_setup(const char *root) {
/* Mark the mount read-only */
if (mount(NULL, etc_machine_id, NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL) < 0)
- log_warning("Failed to make transient %s read-only: %m", etc_machine_id);
+ log_warning_errno(errno, "Failed to make transient %s read-only: %m", etc_machine_id);
return 0;
}
diff --git a/src/core/main.c b/src/core/main.c
index 4acf3f1882..d8a1ab9d43 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -144,7 +144,7 @@ noreturn static void crash(int sig) {
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 = {};
@@ -201,12 +201,12 @@ noreturn static void crash(int sig) {
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);
}
@@ -885,7 +885,7 @@ static int parse_argv(int argc, char *argv[]) {
f = fdopen(fd, "r");
if (!f) {
- log_error("Failed to open serialization fd: %m");
+ log_error_errno(errno, "Failed to open serialization fd: %m");
return -errno;
}
@@ -1006,7 +1006,7 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
}
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;
}
@@ -1046,7 +1046,7 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) {
* 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");
+ log_error_errno(errno, "Reading RLIMIT_NOFILE failed: %m");
return -errno;
}
@@ -1234,7 +1234,7 @@ int main(int argc, char *argv[]) {
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
@@ -1578,7 +1578,7 @@ int main(int argc, char *argv[]) {
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);
@@ -1606,7 +1606,7 @@ int main(int argc, char *argv[]) {
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?)");
}
@@ -1937,7 +1937,7 @@ finish:
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";
@@ -1949,9 +1949,9 @@ finish:
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) {
@@ -2032,7 +2032,7 @@ finish:
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");
}
diff --git a/src/core/manager.c b/src/core/manager.c
index a84272c905..3798ab2d57 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -263,12 +263,12 @@ static int manager_check_ask_password(Manager *m) {
m->ask_password_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
if (m->ask_password_inotify_fd < 0) {
- log_error("inotify_init1() failed: %m");
+ log_error_errno(errno, "inotify_init1() failed: %m");
return -errno;
}
if (inotify_add_watch(m->ask_password_inotify_fd, "/run/systemd/ask-password", IN_CREATE|IN_DELETE|IN_MOVE) < 0) {
- log_error("Failed to add watch on /run/systemd/ask-password: %m");
+ log_error_errno(errno, "Failed to add watch on /run/systemd/ask-password: %m");
manager_close_ask_password(m);
return -errno;
}
@@ -277,7 +277,7 @@ static int manager_check_ask_password(Manager *m) {
m->ask_password_inotify_fd, EPOLLIN,
manager_dispatch_ask_password_fd, m);
if (r < 0) {
- log_error("Failed to add event source for /run/systemd/ask-password: %m");
+ log_error_errno(errno, "Failed to add event source for /run/systemd/ask-password: %m");
manager_close_ask_password(m);
return -errno;
}
@@ -335,12 +335,12 @@ static int manager_setup_time_change(Manager *m) {
m->time_change_fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK|TFD_CLOEXEC);
if (m->time_change_fd < 0) {
- log_error("Failed to create timerfd: %m");
+ log_error_errno(errno, "Failed to create timerfd: %m");
return -errno;
}
if (timerfd_settime(m->time_change_fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0) {
- log_debug("Failed to set up TFD_TIMER_CANCEL_ON_SET, ignoring: %m");
+ log_debug_errno(errno, "Failed to set up TFD_TIMER_CANCEL_ON_SET, ignoring: %m");
m->time_change_fd = safe_close(m->time_change_fd);
return 0;
}
@@ -363,17 +363,17 @@ static int enable_special_signals(Manager *m) {
* this will fail with EPERM (older) or EINVAL (newer), so
* ignore that. */
if (reboot(RB_DISABLE_CAD) < 0 && errno != EPERM && errno != EINVAL)
- log_warning("Failed to enable ctrl-alt-del handling: %m");
+ log_warning_errno(errno, "Failed to enable ctrl-alt-del handling: %m");
fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0) {
/* Support systems without virtual console */
if (fd != -ENOENT)
- log_warning("Failed to open /dev/tty0: %m");
+ log_warning_errno(errno, "Failed to open /dev/tty0: %m");
} else {
/* Enable that we get SIGWINCH on kbrequest */
if (ioctl(fd, KDSIGACCEPT, SIGWINCH) < 0)
- log_warning("Failed to enable kbrequest handling: %m");
+ log_warning_errno(errno, "Failed to enable kbrequest handling: %m");
}
return 0;
@@ -648,7 +648,7 @@ static int manager_setup_notify(Manager *m) {
fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (fd < 0) {
- log_error("Failed to allocate notification socket: %m");
+ log_error_errno(errno, "Failed to allocate notification socket: %m");
return -errno;
}
@@ -659,7 +659,7 @@ static int manager_setup_notify(Manager *m) {
e = getenv("XDG_RUNTIME_DIR");
if (!e) {
- log_error("XDG_RUNTIME_DIR is not set: %m");
+ log_error_errno(errno, "XDG_RUNTIME_DIR is not set: %m");
return -EINVAL;
}
@@ -674,13 +674,13 @@ static int manager_setup_notify(Manager *m) {
strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
if (r < 0) {
- log_error("bind(%s) failed: %m", sa.un.sun_path);
+ log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
return -errno;
}
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
if (r < 0) {
- log_error("SO_PASSCRED failed: %m");
+ log_error_errno(errno, "SO_PASSCRED failed: %m");
return -errno;
}
@@ -1022,7 +1022,7 @@ static void manager_build_unit_path_cache(Manager *m) {
d = opendir(*i);
if (!d) {
if (errno != ENOENT)
- log_error("Failed to open directory %s: %m", *i);
+ log_error_errno(errno, "Failed to open directory %s: %m", *i);
continue;
}
@@ -2070,7 +2070,7 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
* Then let's not retry again. */
close_audit_fd();
else
- log_warning("Failed to send audit message: %m");
+ log_warning_errno(errno, "Failed to send audit message: %m");
}
#endif
@@ -2103,14 +2103,14 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
* message then wait for plymouth */
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (fd < 0) {
- log_error("socket() failed: %m");
+ log_error_errno(errno, "socket() failed: %m");
return;
}
if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1)) < 0) {
if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
- log_error("connect() failed: %m");
+ log_error_errno(errno, "connect() failed: %m");
return;
}
@@ -2122,7 +2122,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
errno = 0;
if (write(fd, message, n + 1) != n + 1)
if (!IN_SET(errno, EPIPE, EAGAIN, ENOENT, ECONNREFUSED, ECONNRESET, ECONNABORTED))
- log_error("Failed to write Plymouth message: %m");
+ log_error_errno(errno, "Failed to write Plymouth message: %m");
}
void manager_dispatch_bus_name_owner_changed(
@@ -2715,7 +2715,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
return log_oom();
if (!mkdtemp(p)) {
- log_error("Failed to create generator directory %s: %m",
+ log_error_errno(errno, "Failed to create generator directory %s: %m",
p);
free(p);
return -errno;
@@ -2758,7 +2758,7 @@ void manager_run_generators(Manager *m) {
if (errno == ENOENT)
return;
- log_error("Failed to enumerate generator directory %s: %m",
+ log_error_errno(errno, "Failed to enumerate generator directory %s: %m",
generator_path);
return;
}
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index fc538d0aa4..d319a15187 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -235,7 +235,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
f = fopen("/proc/cgroups", "re");
if (!f) {
- log_error("Failed to enumerate cgroup controllers: %m");
+ log_error_errno(errno, "Failed to enumerate cgroup controllers: %m");
return 0;
}
@@ -341,7 +341,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
r = symlink(options, t);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create symlink %s: %m", t);
+ log_error_errno(errno, "Failed to create symlink %s: %m", t);
return -errno;
}
}
@@ -428,7 +428,7 @@ int mount_setup(bool loaded_policy) {
* propagation mode to private if needed. */
if (detect_container(NULL) <= 0)
if (mount(NULL, "/", NULL, MS_REC|MS_SHARED, NULL) < 0)
- log_warning("Failed to set up the root directory for shared mount propagation: %m");
+ log_warning_errno(errno, "Failed to set up the root directory for shared mount propagation: %m");
/* Create a few directories we always want around, Note that
* sd_booted() checks for /run/systemd/system, so this mkdir
diff --git a/src/core/namespace.c b/src/core/namespace.c
index a2025459f1..32338cdc60 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -277,7 +277,7 @@ static int mount_kdbus(BindMount *m) {
u = umask(0000);
if (!mkdtemp(temporary_mount)) {
- log_error("Failed create temp dir: %m");
+ log_error_errno(errno, "Failed create temp dir: %m");
return -errno;
}
@@ -291,21 +291,21 @@ static int mount_kdbus(BindMount *m) {
/* create a new /dev/null dev node copy so we have some fodder to
* bind-mount the custom endpoint over. */
if (stat("/dev/null", &st) < 0) {
- log_error("Failed to stat /dev/null: %m");
+ log_error_errno(errno, "Failed to stat /dev/null: %m");
r = -errno;
goto fail;
}
busnode = strappenda(root, "/bus");
if (mknod(busnode, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0) {
- log_error("mknod() for %s failed: %m", busnode);
+ log_error_errno(errno, "mknod() for %s failed: %m", busnode);
r = -errno;
goto fail;
}
r = mount(m->path, busnode, "bind", MS_BIND, NULL);
if (r < 0) {
- log_error("bind mount of %s failed: %m", m->path);
+ log_error_errno(errno, "bind mount of %s failed: %m", m->path);
r = -errno;
goto fail;
}
@@ -317,7 +317,7 @@ static int mount_kdbus(BindMount *m) {
}
if (mount(root, basepath, NULL, MS_MOVE, NULL) < 0) {
- log_error("bind mount of %s failed: %m", basepath);
+ log_error_errno(errno, "bind mount of %s failed: %m", basepath);
r = -errno;
goto fail;
}
diff --git a/src/core/path.c b/src/core/path.c
index 202cba5d31..ed03635a46 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -136,7 +136,7 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) {
}
if (!exists) {
- log_error("Failed to add watch on any of the components of %s: %m",
+ log_error_errno(errno, "Failed to add watch on any of the components of %s: %m",
s->path);
r = -errno; /* either EACCESS or ENOENT */
goto fail;
@@ -169,7 +169,7 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
}
if (ioctl(s->inotify_fd, FIONREAD, &l) < 0) {
- log_error("FIONREAD failed: %m");
+ log_error_errno(errno, "FIONREAD failed: %m");
return -errno;
}
@@ -181,7 +181,7 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
k = read(s->inotify_fd, buf, l);
if (k < 0) {
- log_error("Failed to read inotify event: %m");
+ log_error_errno(errno, "Failed to read inotify event: %m");
return -errno;
}
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index 0160d4f639..0ec80a1b33 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -127,7 +127,7 @@ static int access_init(void) {
int r = 0;
if (avc_open(NULL, 0)) {
- log_error("avc_open() failed: %m");
+ log_error_errno(errno, "avc_open() failed: %m");
return -errno;
}
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 923cd3b16c..10455fa309 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -139,12 +139,12 @@ static int parse_argv(int argc, char *argv[]) {
static int switch_root_initramfs(void) {
if (mount("/run/initramfs", "/run/initramfs", NULL, MS_BIND, NULL) < 0) {
- log_error("Failed to mount bind /run/initramfs on /run/initramfs: %m");
+ log_error_errno(errno, "Failed to mount bind /run/initramfs on /run/initramfs: %m");
return -errno;
}
if (mount(NULL, "/run/initramfs", NULL, MS_PRIVATE, NULL) < 0) {
- log_error("Failed to make /run/initramfs private mount: %m");
+ log_error_errno(errno, "Failed to make /run/initramfs private mount: %m");
return -errno;
}
@@ -327,7 +327,7 @@ int main(int argc, char *argv[]) {
"Returning to initrd...");
execv("/shutdown", argv);
- log_error("Failed to execute shutdown binary: %m");
+ log_error_errno(errno, "Failed to execute shutdown binary: %m");
} else
log_error_errno(r, "Failed to switch root to \"/run/initramfs\": %m");
@@ -359,7 +359,7 @@ int main(int argc, char *argv[]) {
pid = fork();
if (pid < 0)
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
else if (pid == 0) {
const char * const args[] = {
@@ -412,7 +412,7 @@ int main(int argc, char *argv[]) {
exit(0);
}
- log_error("Failed to invoke reboot(): %m");
+ log_error_errno(errno, "Failed to invoke reboot(): %m");
r = -errno;
error:
diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c
index d0fd1809f9..59f6832bc2 100644
--- a/src/core/smack-setup.c
+++ b/src/core/smack-setup.c
@@ -56,7 +56,7 @@ static int write_rules(const char* dstpath, const char* srcdir) {
dst = fopen(dstpath, "we");
if (!dst) {
if (errno != ENOENT)
- log_warning("Failed to open %s: %m", dstpath);
+ log_warning_errno(errno, "Failed to open %s: %m", dstpath);
return -errno; /* negative error */
}
@@ -64,7 +64,7 @@ static int write_rules(const char* dstpath, const char* srcdir) {
dir = opendir(srcdir);
if (!dir) {
if (errno != ENOENT)
- log_warning("Failed to opendir %s: %m", srcdir);
+ log_warning_errno(errno, "Failed to opendir %s: %m", srcdir);
return errno; /* positive on purpose */
}
@@ -79,7 +79,7 @@ static int write_rules(const char* dstpath, const char* srcdir) {
if (fd < 0) {
if (r == 0)
r = -errno;
- log_warning("Failed to open %s: %m", entry->d_name);
+ log_warning_errno(errno, "Failed to open %s: %m", entry->d_name);
continue;
}
@@ -88,13 +88,13 @@ static int write_rules(const char* dstpath, const char* srcdir) {
if (r == 0)
r = -errno;
safe_close(fd);
- log_error("Failed to open %s: %m", entry->d_name);
+ log_error_errno(errno, "Failed to open %s: %m", entry->d_name);
continue;
}
/* load2 write rules in the kernel require a line buffered stream */
FOREACH_LINE(buf, policy,
- log_error("Failed to read line from %s: %m",
+ log_error_errno(errno, "Failed to read line from %s: %m",
entry->d_name)) {
if (!fputs(buf, dst)) {
if (r == 0)
@@ -105,7 +105,7 @@ static int write_rules(const char* dstpath, const char* srcdir) {
if (fflush(dst)) {
if (r == 0)
r = -errno;
- log_error("Failed to flush writes to %s: %m", dstpath);
+ log_error_errno(errno, "Failed to flush writes to %s: %m", dstpath);
break;
}
}
diff --git a/src/core/umount.c b/src/core/umount.c
index cffa45327b..e38851dc12 100644
--- a/src/core/umount.c
+++ b/src/core/umount.c
@@ -401,7 +401,7 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e
mount_point_free(head, m);
} else if (log_error) {
- log_warning("Could not unmount %s: %m", m->path);
+ log_warning_errno(errno, "Could not unmount %s: %m", m->path);
n_failed++;
}
}
@@ -423,7 +423,7 @@ static int swap_points_list_off(MountPoint **head, bool *changed) {
mount_point_free(head, m);
} else {
- log_warning("Could not deactivate swap %s: %m", m->path);
+ log_warning_errno(errno, "Could not deactivate swap %s: %m", m->path);
n_failed++;
}
}
@@ -460,7 +460,7 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed) {
mount_point_free(head, m);
} else {
- log_warning("Could not detach loopback %s: %m", m->path);
+ log_warning_errno(errno, "Could not detach loopback %s: %m", m->path);
n_failed++;
}
}
@@ -495,7 +495,7 @@ static int dm_points_list_detach(MountPoint **head, bool *changed) {
mount_point_free(head, m);
} else {
- log_warning("Could not detach DM %s: %m", m->path);
+ log_warning_errno(errno, "Could not detach DM %s: %m", m->path);
n_failed++;
}
}