summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/activate/activate.c22
-rw-r--r--src/backlight/backlight.c2
-rw-r--r--src/binfmt/binfmt.c2
-rw-r--r--src/bootchart/bootchart.c4
-rw-r--r--src/bootchart/store.c4
-rw-r--r--src/bus-proxyd/bus-proxyd.c2
-rw-r--r--src/cgls/cgls.c2
-rw-r--r--src/console/consoled-terminal.c2
-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
-rw-r--r--src/cryptsetup/cryptsetup-generator.c14
-rw-r--r--src/dbus1-generator/dbus1-generator.c18
-rw-r--r--src/debug-generator/debug-generator.c4
-rw-r--r--src/delta/delta.c6
-rw-r--r--src/efi-boot-generator/efi-boot-generator.c10
-rw-r--r--src/firstboot/firstboot.c8
-rw-r--r--src/fsck/fsck.c8
-rw-r--r--src/fstab-generator/fstab-generator.c18
-rw-r--r--src/getty-generator/getty-generator.c2
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c34
-rw-r--r--src/hibernate-resume/hibernate-resume-generator.c2
-rw-r--r--src/hibernate-resume/hibernate-resume.c2
-rw-r--r--src/initctl/initctl.c14
-rw-r--r--src/journal-remote/journal-gatewayd.c12
-rw-r--r--src/journal-remote/journal-remote-parse.c4
-rw-r--r--src/journal-remote/journal-remote.c18
-rw-r--r--src/journal-remote/journal-upload.c4
-rw-r--r--src/journal/cat.c2
-rw-r--r--src/journal/catalog.c8
-rw-r--r--src/journal/coredump-vacuum.c8
-rw-r--r--src/journal/coredump.c26
-rw-r--r--src/journal/coredumpctl.c14
-rw-r--r--src/journal/journal-authenticate.c2
-rw-r--r--src/journal/journal-file.c2
-rw-r--r--src/journal/journal-vacuum.c4
-rw-r--r--src/journal/journal-verify.c6
-rw-r--r--src/journal/journalctl.c22
-rw-r--r--src/journal/journald-audit.c6
-rw-r--r--src/journal/journald-console.c4
-rw-r--r--src/journal/journald-kmsg.c10
-rw-r--r--src/journal/journald-native.c16
-rw-r--r--src/journal/journald-server.c12
-rw-r--r--src/journal/journald-stream.c16
-rw-r--r--src/journal/journald-syslog.c12
-rw-r--r--src/journal/sd-journal.c6
-rw-r--r--src/libsystemd-terminal/evcat.c4
-rw-r--r--src/libsystemd-terminal/grdev-drm.c106
-rw-r--r--src/libsystemd-terminal/idev-evdev.c14
-rw-r--r--src/libsystemd-terminal/modeset.c2
-rw-r--r--src/libsystemd-terminal/subterm.c10
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c4
-rw-r--r--src/libudev/libudev-device-private.c2
-rw-r--r--src/libudev/libudev-device.c2
-rw-r--r--src/libudev/libudev-hwdb.c6
-rw-r--r--src/libudev/libudev-monitor.c8
-rw-r--r--src/locale/localectl.c2
-rw-r--r--src/login/inhibit.c4
-rw-r--r--src/login/logind-button.c4
-rw-r--r--src/login/logind-dbus.c4
-rw-r--r--src/login/logind-session.c12
-rw-r--r--src/login/logind-user.c2
-rw-r--r--src/login/logind.c14
-rw-r--r--src/login/user-sessions.c4
-rw-r--r--src/machine/machinectl.c4
-rw-r--r--src/machine/machined.c2
-rw-r--r--src/modules-load/modules-load.c2
-rw-r--r--src/network/networkctl.c4
-rw-r--r--src/nspawn/nspawn.c192
-rw-r--r--src/quotacheck/quotacheck.c2
-rw-r--r--src/random-seed/random-seed.c10
-rw-r--r--src/rc-local-generator/rc-local-generator.c2
-rw-r--r--src/remount-fs/remount-fs.c8
-rw-r--r--src/reply-password/reply-password.c6
-rw-r--r--src/resolve-host/resolve-host.c2
-rw-r--r--src/resolve/resolved-dns-stream.c4
-rw-r--r--src/resolve/resolved-manager.c8
-rw-r--r--src/rfkill/rfkill.c2
-rw-r--r--src/run/run.c10
-rw-r--r--src/shared/ask-password-api.c20
-rw-r--r--src/shared/base-filesystem.c6
-rw-r--r--src/shared/capability.c14
-rw-r--r--src/shared/clean-ipc.c38
-rw-r--r--src/shared/conf-parser.c2
-rw-r--r--src/shared/generator.c2
-rw-r--r--src/shared/pager.c12
-rw-r--r--src/shared/ptyfwd.c8
-rw-r--r--src/shared/smack-util.c2
-rw-r--r--src/shared/socket-label.c4
-rw-r--r--src/shared/socket-util.c2
-rw-r--r--src/shared/switch-root.c26
-rw-r--r--src/shared/util.c10
-rw-r--r--src/shared/watchdog.c14
-rw-r--r--src/shutdownd/shutdownd.c18
-rw-r--r--src/sleep/sleep.c4
-rw-r--r--src/socket-proxy/socket-proxyd.c16
-rw-r--r--src/sysctl/sysctl.c2
-rw-r--r--src/system-update-generator/system-update-generator.c4
-rw-r--r--src/systemctl/systemctl.c8
-rw-r--r--src/sysusers/sysusers.c14
-rw-r--r--src/sysv-generator/sysv-generator.c6
-rw-r--r--src/test/test-capability.c2
-rw-r--r--src/test/test-ns.c2
-rw-r--r--src/timedate/timedated.c2
-rw-r--r--src/timesync/timesyncd-manager.c8
-rw-r--r--src/timesync/timesyncd.c2
-rw-r--r--src/tmpfiles/tmpfiles.c48
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c8
-rw-r--r--src/udev/ata_id/ata_id.c2
-rw-r--r--src/udev/scsi_id/scsi_id.c2
-rw-r--r--src/udev/scsi_id/scsi_serial.c6
-rw-r--r--src/udev/udev-builtin-keyboard.c4
-rw-r--r--src/udev/udev-ctrl.c16
-rw-r--r--src/udev/udev-event.c24
-rw-r--r--src/udev/udev-node.c10
-rw-r--r--src/udev/udev-rules.c6
-rw-r--r--src/udev/udev-watch.c10
-rw-r--r--src/udev/udevadm-monitor.c6
-rw-r--r--src/udev/udevadm-trigger.c2
-rw-r--r--src/udev/udevd.c24
-rw-r--r--src/update-utmp/update-utmp.c8
-rw-r--r--src/vconsole/vconsole-setup.c6
139 files changed, 741 insertions, 728 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c
index 909ea24cc0..3b4cb1e7f5 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -52,7 +52,7 @@ static int add_epoll(int epoll_fd, int fd) {
ev.data.fd = fd;
r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev);
if (r < 0) {
- log_error("Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
+ log_error_errno(errno, "Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
return -errno;
}
@@ -112,7 +112,7 @@ static int open_sockets(int *epoll_fd, bool accept) {
*epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (*epoll_fd < 0) {
- log_error("Failed to create epoll object: %m");
+ log_error_errno(errno, "Failed to create epoll object: %m");
return -errno;
}
@@ -175,7 +175,7 @@ static int launch(char* name, char **argv, char **env, int fds) {
log_info("Execing %s (%s)", name, tmp);
execvpe(name, argv, envp);
- log_error("Failed to execp %s (%s): %m", name, tmp);
+ log_error_errno(errno, "Failed to execp %s (%s): %m", name, tmp);
return -errno;
}
@@ -193,7 +193,7 @@ static int launch1(const char* child, char** argv, char **env, int fd) {
child_pid = fork();
if (child_pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return -errno;
}
@@ -201,19 +201,19 @@ static int launch1(const char* child, char** argv, char **env, int fd) {
if (child_pid == 0) {
r = dup2(fd, STDIN_FILENO);
if (r < 0) {
- log_error("Failed to dup connection to stdin: %m");
+ log_error_errno(errno, "Failed to dup connection to stdin: %m");
_exit(EXIT_FAILURE);
}
r = dup2(fd, STDOUT_FILENO);
if (r < 0) {
- log_error("Failed to dup connection to stdout: %m");
+ log_error_errno(errno, "Failed to dup connection to stdout: %m");
_exit(EXIT_FAILURE);
}
r = close(fd);
if (r < 0) {
- log_error("Failed to close dupped connection: %m");
+ log_error_errno(errno, "Failed to close dupped connection: %m");
_exit(EXIT_FAILURE);
}
@@ -227,7 +227,7 @@ static int launch1(const char* child, char** argv, char **env, int fd) {
_exit(EXIT_SUCCESS);
execvp(child, argv);
- log_error("Failed to exec child %s: %m", child);
+ log_error_errno(errno, "Failed to exec child %s: %m", child);
_exit(EXIT_FAILURE);
}
@@ -242,7 +242,7 @@ static int do_accept(const char* name, char **argv, char **envp, int fd) {
fd2 = accept(fd, NULL, NULL);
if (fd2 < 0) {
- log_error("Failed to accept connection on fd:%d: %m", fd);
+ log_error_errno(errno, "Failed to accept connection on fd:%d: %m", fd);
return fd2;
}
@@ -271,7 +271,7 @@ static int install_chld_handler(void) {
r = sigaction(SIGCHLD, &act, 0);
if (r < 0)
- log_error("Failed to install SIGCHLD handler: %m");
+ log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
return r;
}
@@ -389,7 +389,7 @@ int main(int argc, char **argv, char **envp) {
if (errno == EINTR)
continue;
- log_error("epoll_wait() failed: %m");
+ log_error_errno(errno, "epoll_wait() failed: %m");
return EXIT_FAILURE;
}
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 218dc0d8cd..1271a66983 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -318,7 +318,7 @@ int main(int argc, char *argv[]) {
device = udev_device_new_from_subsystem_sysname(udev, ss, sysname);
if (!device) {
if (errno != 0)
- log_error("Failed to get backlight or LED device '%s:%s': %m", ss, sysname);
+ log_error_errno(errno, "Failed to get backlight or LED device '%s:%s': %m", ss, sysname);
else
log_oom();
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index cbba42f6dc..089b7754a4 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -93,7 +93,7 @@ static int apply_file(const char *path, bool ignore_enoent) {
if (feof(f))
break;
- log_error("Failed to read file '%s', ignoring: %m", path);
+ log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
return -errno;
}
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 35c15ab12e..5bb4247c8c 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -285,7 +285,7 @@ static void do_journal_append(char *file) {
f = open(file, O_RDONLY|O_CLOEXEC);
if (f < 0) {
- log_error("Failed to read bootchart data: %m");
+ log_error_errno(errno, "Failed to read bootchart data: %m");
return;
}
n = loop_read(f, p + 10, BOOTCHART_MAX, false);
@@ -434,7 +434,7 @@ int main(int argc, char *argv[]) {
/* caught signal, probably HUP! */
break;
}
- log_error("nanosleep() failed: %m");
+ log_error_errno(errno, "nanosleep() failed: %m");
exit(EXIT_FAILURE);
}
} else {
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index 9ea1b27de4..a66387c304 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -146,7 +146,7 @@ void log_sample(int sample, struct list_sample_data **ptr) {
/* block stuff */
vmstat = openat(procfd, "vmstat", O_RDONLY);
if (vmstat == -1) {
- log_error("Failed to open /proc/vmstat: %m");
+ log_error_errno(errno, "Failed to open /proc/vmstat: %m");
exit(EXIT_FAILURE);
}
}
@@ -178,7 +178,7 @@ vmstat_next:
/* overall CPU utilization */
schedstat = openat(procfd, "schedstat", O_RDONLY);
if (schedstat == -1) {
- log_error("Failed to open /proc/schedstat: %m");
+ log_error_errno(errno, "Failed to open /proc/schedstat: %m");
exit(EXIT_FAILURE);
}
}
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 4f3adf72d1..6b15e7d27b 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -1719,7 +1719,7 @@ int main(int argc, char *argv[]) {
r = ppoll(pollfd, 3, ts, NULL);
if (r < 0) {
- log_error("ppoll() failed: %m");
+ log_error_errno(errno, "ppoll() failed: %m");
goto finish;
}
}
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index 27420f4f96..f400bccc0a 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -186,7 +186,7 @@ int main(int argc, char *argv[]) {
p = get_current_dir_name();
if (!p) {
- log_error("Cannot determine current working directory: %m");
+ log_error_errno(errno, "Cannot determine current working directory: %m");
goto finish;
}
diff --git a/src/console/consoled-terminal.c b/src/console/consoled-terminal.c
index 755f23ece2..19d14016ad 100644
--- a/src/console/consoled-terminal.c
+++ b/src/console/consoled-terminal.c
@@ -165,7 +165,7 @@ void terminal_run(Terminal *t) {
setenv("COLORTERM", "systemd-console", 1);
execve(argv[0], argv, environ);
- log_error("Cannot exec %s (%d): %m", argv[0], -errno);
+ log_error_errno(errno, "Cannot exec %s (%d): %m", argv[0], -errno);
_exit(1);
}
}
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++;
}
}
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index c281001e74..b27223cd6c 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -117,7 +117,7 @@ static int create_disk(
f = fopen(p, "wxe");
if (!f) {
- log_error("Failed to create unit file %s: %m", p);
+ log_error_errno(errno, "Failed to create unit file %s: %m", p);
return -errno;
}
@@ -201,7 +201,7 @@ static int create_disk(
fflush(f);
if (ferror(f)) {
- log_error("Failed to write file %s: %m", p);
+ log_error_errno(errno, "Failed to write file %s: %m", p);
return -errno;
}
@@ -215,7 +215,7 @@ static int create_disk(
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
@@ -229,7 +229,7 @@ static int create_disk(
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
}
@@ -241,7 +241,7 @@ static int create_disk(
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
@@ -342,13 +342,13 @@ int main(int argc, char *argv[]) {
if (errno == ENOENT)
r = EXIT_SUCCESS;
else
- log_error("Failed to open /etc/crypttab: %m");
+ log_error_errno(errno, "Failed to open /etc/crypttab: %m");
goto next;
}
if (fstat(fileno(f), &st) < 0) {
- log_error("Failed to stat /etc/crypttab: %m");
+ log_error_errno(errno, "Failed to stat /etc/crypttab: %m");
goto next;
}
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 21e9e9ca73..5a26f38869 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -59,7 +59,7 @@ static int create_dbus_files(
f = fopen(a, "wxe");
if (!f) {
- log_error("Failed to create %s: %m", a);
+ log_error_errno(errno, "Failed to create %s: %m", a);
return -errno;
}
@@ -117,7 +117,7 @@ static int create_dbus_files(
f = fopen(b, "wxe");
if (!f) {
- log_error("Failed to create %s: %m", b);
+ log_error_errno(errno, "Failed to create %s: %m", b);
return -errno;
}
@@ -146,7 +146,7 @@ static int create_dbus_files(
mkdir_parents_label(lnk, 0755);
if (symlink(b, lnk)) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
@@ -229,7 +229,7 @@ static int parse_dbus_fragments(const char *path, const char *type) {
if (errno == -ENOENT)
return 0;
- log_error("Failed to enumerate D-Bus activated services: %m");
+ log_error_errno(errno, "Failed to enumerate D-Bus activated services: %m");
return -errno;
}
@@ -248,7 +248,7 @@ static int parse_dbus_fragments(const char *path, const char *type) {
return r;
fail:
- log_error("Failed to read D-Bus services directory: %m");
+ log_error_errno(errno, "Failed to read D-Bus services directory: %m");
return -errno;
}
@@ -260,7 +260,7 @@ static int link_busnames_target(const char *units) {
mkdir_parents_label(t, 0755);
if (symlink(f, t) < 0) {
- log_error("Failed to create symlink %s: %m", t);
+ log_error_errno(errno, "Failed to create symlink %s: %m", t);
return -errno;
}
@@ -274,7 +274,7 @@ static int link_compatibility(const char *units) {
t = strappenda(arg_dest, "/" SPECIAL_DBUS_SOCKET);
mkdir_parents_label(t, 0755);
if (symlink(f, t) < 0) {
- log_error("Failed to create symlink %s: %m", t);
+ log_error_errno(errno, "Failed to create symlink %s: %m", t);
return -errno;
}
@@ -282,13 +282,13 @@ static int link_compatibility(const char *units) {
t = strappenda(arg_dest, "/" SPECIAL_SOCKETS_TARGET ".wants/systemd-bus-proxyd.socket");
mkdir_parents_label(t, 0755);
if (symlink(f, t) < 0) {
- log_error("Failed to create symlink %s: %m", t);
+ log_error_errno(errno, "Failed to create symlink %s: %m", t);
return -errno;
}
t = strappenda(arg_dest, "/" SPECIAL_DBUS_SERVICE);
if (symlink("/dev/null", t) < 0) {
- log_error("Failed to mask %s: %m", t);
+ log_error_errno(errno, "Failed to mask %s: %m", t);
return -errno;
}
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 4fe64425c0..1b9019325c 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -96,7 +96,7 @@ static int generate_mask_symlinks(void) {
return log_oom();
if (symlink("/dev/null", p) < 0) {
- log_error("Failed to create mask symlink %s: %m", p);
+ log_error_errno(errno, "Failed to create mask symlink %s: %m", p);
r = -errno;
}
}
@@ -125,7 +125,7 @@ static int generate_wants_symlinks(void) {
mkdir_parents_label(p, 0755);
if (symlink(f, p) < 0) {
- log_error("Failed to create wants symlink %s: %m", p);
+ log_error_errno(errno, "Failed to create wants symlink %s: %m", p);
r = -errno;
}
}
diff --git a/src/delta/delta.c b/src/delta/delta.c
index 4753fb38c4..8c4af3665a 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -186,11 +186,11 @@ static int found_override(const char *top, const char *bottom) {
pid = fork();
if (pid < 0) {
- log_error("Failed to fork off diff: %m");
+ log_error_errno(errno, "Failed to fork off diff: %m");
return -errno;
} else if (pid == 0) {
execlp("diff", "diff", "-us", "--", bottom, top, NULL);
- log_error("Failed to execute diff: %m");
+ log_error_errno(errno, "Failed to execute diff: %m");
_exit(1);
}
@@ -305,7 +305,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch
if (errno == ENOENT)
return 0;
- log_error("Failed to open %s: %m", path);
+ log_error_errno(errno, "Failed to open %s: %m", path);
return -errno;
}
diff --git a/src/efi-boot-generator/efi-boot-generator.c b/src/efi-boot-generator/efi-boot-generator.c
index d4e9a8c00c..99a819fe37 100644
--- a/src/efi-boot-generator/efi-boot-generator.c
+++ b/src/efi-boot-generator/efi-boot-generator.c
@@ -87,7 +87,7 @@ int main(int argc, char *argv[]) {
name = strappenda(arg_dest, "/boot.mount");
f = fopen(name, "wxe");
if (!f) {
- log_error("Failed to create mount unit file %s: %m", name);
+ log_error_errno(errno, "Failed to create mount unit file %s: %m", name);
return EXIT_FAILURE;
}
@@ -120,7 +120,7 @@ int main(int argc, char *argv[]) {
fflush(f);
if (ferror(f)) {
- log_error("Failed to write mount unit file: %m");
+ log_error_errno(errno, "Failed to write mount unit file: %m");
return EXIT_FAILURE;
}
@@ -128,7 +128,7 @@ int main(int argc, char *argv[]) {
fclose(f);
f = fopen(name, "wxe");
if (!f) {
- log_error("Failed to create automount unit file %s: %m", name);
+ log_error_errno(errno, "Failed to create automount unit file %s: %m", name);
return EXIT_FAILURE;
}
@@ -140,7 +140,7 @@ int main(int argc, char *argv[]) {
fflush(f);
if (ferror(f)) {
- log_error("Failed to write automount unit file: %m");
+ log_error_errno(errno, "Failed to write automount unit file: %m");
return EXIT_FAILURE;
}
@@ -148,7 +148,7 @@ int main(int argc, char *argv[]) {
mkdir_parents(name, 0755);
if (symlink("../boot.automount", name) < 0) {
- log_error("Failed to create symlink %s: %m", name);
+ log_error_errno(errno, "Failed to create symlink %s: %m", name);
return EXIT_FAILURE;
}
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 343f3e100e..d8fbd5945f 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -337,7 +337,7 @@ static int process_timezone(void) {
mkdir_parents(etc_localtime, 0755);
if (symlink(p, etc_localtime) < 0) {
- log_error("Failed to create %s symlink: %m", etc_localtime);
+ log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime);
return -errno;
}
@@ -357,7 +357,7 @@ static int process_timezone(void) {
mkdir_parents(etc_localtime, 0755);
if (symlink(e, etc_localtime) < 0) {
- log_error("Failed to create %s symlink: %m", etc_localtime);
+ log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime);
return -errno;
}
@@ -566,7 +566,7 @@ static int process_root_password(void) {
if (!errno)
errno = EIO;
- log_error("Failed to find shadow entry for root: %m");
+ log_error_errno(errno, "Failed to find shadow entry for root: %m");
return -errno;
}
@@ -604,7 +604,7 @@ static int process_root_password(void) {
if (!errno)
errno = -EINVAL;
- log_error("Failed to encrypt password: %m");
+ log_error_errno(errno, "Failed to encrypt password: %m");
return -errno;
}
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 82a833fe78..a7226ce4df 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -256,7 +256,7 @@ int main(int argc, char *argv[]) {
root_directory = false;
if (stat(device, &st) < 0) {
- log_error("Failed to stat '%s': %m", device);
+ log_error_errno(errno, "Failed to stat '%s': %m", device);
return EXIT_FAILURE;
}
@@ -271,7 +271,7 @@ int main(int argc, char *argv[]) {
/* Find root device */
if (stat("/", &st) < 0) {
- log_error("Failed to stat() the root directory: %m");
+ log_error_errno(errno, "Failed to stat() the root directory: %m");
return EXIT_FAILURE;
}
@@ -314,7 +314,7 @@ int main(int argc, char *argv[]) {
if (arg_show_progress)
if (pipe(progress_pipe) < 0) {
- log_error("pipe(): %m");
+ log_error_errno(errno, "pipe(): %m");
return EXIT_FAILURE;
}
@@ -346,7 +346,7 @@ int main(int argc, char *argv[]) {
pid = fork();
if (pid < 0) {
- log_error("fork(): %m");
+ log_error_errno(errno, "fork(): %m");
goto finish;
} else if (pid == 0) {
/* Child */
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 4e50151ecd..1c85a729b8 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -111,7 +111,7 @@ static int add_swap(
if (errno == EEXIST)
log_error("Failed to create swap unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
else
- log_error("Failed to create unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to create unit file %s: %m", unit);
return -errno;
}
@@ -149,7 +149,7 @@ static int add_swap(
mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
}
@@ -229,7 +229,7 @@ static int add_mount(
if (errno == EEXIST)
log_error("Failed to create mount unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
else
- log_error("Failed to create unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to create unit file %s: %m", unit);
return -errno;
}
@@ -269,7 +269,7 @@ static int add_mount(
fflush(f);
if (ferror(f)) {
- log_error("Failed to write unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to write unit file %s: %m", unit);
return -errno;
}
@@ -280,7 +280,7 @@ static int add_mount(
mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
}
@@ -297,7 +297,7 @@ static int add_mount(
fclose(f);
f = fopen(automount_unit, "wxe");
if (!f) {
- log_error("Failed to create unit file %s: %m", automount_unit);
+ log_error_errno(errno, "Failed to create unit file %s: %m", automount_unit);
return -errno;
}
@@ -320,7 +320,7 @@ static int add_mount(
fflush(f);
if (ferror(f)) {
- log_error("Failed to write unit file %s: %m", automount_unit);
+ log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit);
return -errno;
}
@@ -331,7 +331,7 @@ static int add_mount(
mkdir_parents_label(lnk, 0755);
if (symlink(automount_unit, lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
}
@@ -351,7 +351,7 @@ static int parse_fstab(bool initrd) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open %s: %m", fstab_path);
+ log_error_errno(errno, "Failed to open %s: %m", fstab_path);
return -errno;
}
diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
index 06ca9b9662..931651e161 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -52,7 +52,7 @@ static int add_symlink(const char *fservice, const char *tservice) {
/* In case console=hvc0 is passed this will very likely result in EEXIST */
return 0;
else {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
}
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 0e935b30b9..5a78087a1f 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -69,7 +69,7 @@ static int add_swap(const char *path) {
f = fopen(unit, "wxe");
if (!f) {
- log_error("Failed to create unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to create unit file %s: %m", unit);
return -errno;
}
@@ -84,7 +84,7 @@ static int add_swap(const char *path) {
fflush(f);
if (ferror(f)) {
- log_error("Failed to write unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to write unit file %s: %m", unit);
return -errno;
}
@@ -94,7 +94,7 @@ static int add_swap(const char *path) {
mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
@@ -129,7 +129,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
f = fopen(p, "wxe");
if (!f) {
- log_error("Failed to create unit file %s: %m", p);
+ log_error_errno(errno, "Failed to create unit file %s: %m", p);
return -errno;
}
@@ -156,7 +156,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
fflush(f);
if (ferror(f)) {
- log_error("Failed to write file %s: %m", p);
+ log_error_errno(errno, "Failed to write file %s: %m", p);
return -errno;
}
@@ -168,7 +168,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
@@ -179,7 +179,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
@@ -190,7 +190,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
@@ -255,7 +255,7 @@ static int add_mount(
f = fopen(p, "wxe");
if (!f) {
- log_error("Failed to create unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to create unit file %s: %m", unit);
return -errno;
}
@@ -287,7 +287,7 @@ static int add_mount(
fflush(f);
if (ferror(f)) {
- log_error("Failed to write unit file %s: %m", p);
+ log_error_errno(errno, "Failed to write unit file %s: %m", p);
return -errno;
}
@@ -298,7 +298,7 @@ static int add_mount(
mkdir_parents_label(lnk, 0755);
if (symlink(p, lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
}
@@ -337,7 +337,7 @@ static int probe_and_add_mount(
if (!b) {
if (errno == 0)
return log_oom();
- log_error("Failed to allocate prober: %m");
+ log_error_errno(errno, "Failed to allocate prober: %m");
return -errno;
}
@@ -351,7 +351,7 @@ static int probe_and_add_mount(
else if (r != 0) {
if (errno == 0)
errno = EIO;
- log_error("Failed to probe %s: %m", what);
+ log_error_errno(errno, "Failed to probe %s: %m", what);
return -errno;
}
@@ -429,7 +429,7 @@ static int enumerate_partitions(dev_t devnum) {
if (errno == 0)
return log_oom();
- log_error("Failed allocate prober: %m");
+ log_error_errno(errno, "Failed allocate prober: %m");
return -errno;
}
@@ -443,7 +443,7 @@ static int enumerate_partitions(dev_t devnum) {
else if (r != 0) {
if (errno == 0)
errno = EIO;
- log_error("Failed to probe %s: %m", node);
+ log_error_errno(errno, "Failed to probe %s: %m", node);
return -errno;
}
@@ -452,7 +452,7 @@ static int enumerate_partitions(dev_t devnum) {
if (r != 0) {
if (errno == 0)
errno = EIO;
- log_error("Failed to determine partition table type of %s: %m", node);
+ log_error_errno(errno, "Failed to determine partition table type of %s: %m", node);
return -errno;
}
@@ -468,7 +468,7 @@ static int enumerate_partitions(dev_t devnum) {
if (errno == 0)
return log_oom();
- log_error("Failed to list partitions of %s: %m", node);
+ log_error_errno(errno, "Failed to list partitions of %s: %m", node);
return -errno;
}
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c
index b8c4bafc05..25cefc2b24 100644
--- a/src/hibernate-resume/hibernate-resume-generator.c
+++ b/src/hibernate-resume/hibernate-resume-generator.c
@@ -58,7 +58,7 @@ static int process_resume(void) {
mkdir_parents_label(lnk, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-hibernate-resume@.service", lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c
index b1d5ffdb3f..f28eabbe37 100644
--- a/src/hibernate-resume/hibernate-resume.c
+++ b/src/hibernate-resume/hibernate-resume.c
@@ -53,7 +53,7 @@ int main(int argc, char *argv[]) {
device = argv[1];
if (stat(device, &st) < 0) {
- log_error("Failed to stat '%s': %m", device);
+ log_error_errno(errno, "Failed to stat '%s': %m", device);
return EXIT_FAILURE;
}
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index a0745af716..d7cd4ba29f 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -162,7 +162,7 @@ static void request_process(Server *s, const struct init_request *req) {
case 'u':
case 'U':
if (kill(1, SIGTERM) < 0)
- log_error("kill() failed: %m");
+ log_error_errno(errno, "kill() failed: %m");
/* The bus connection will be
* terminated if PID 1 is reexecuted,
@@ -175,7 +175,7 @@ static void request_process(Server *s, const struct init_request *req) {
case 'q':
case 'Q':
if (kill(1, SIGHUP) < 0)
- log_error("kill() failed: %m");
+ log_error_errno(errno, "kill() failed: %m");
break;
default:
@@ -217,7 +217,7 @@ static int fifo_process(Fifo *f) {
if (errno == EAGAIN)
return 0;
- log_warning("Failed to read from fifo: %m");
+ log_warning_errno(errno, "Failed to read from fifo: %m");
return -errno;
}
@@ -277,7 +277,7 @@ static int server_init(Server *s, unsigned n_sockets) {
s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (s->epoll_fd < 0) {
r = -errno;
- log_error("Failed to create epoll object: %m");
+ log_error_errno(errno, "Failed to create epoll object: %m");
goto fail;
}
@@ -303,7 +303,7 @@ static int server_init(Server *s, unsigned n_sockets) {
f = new0(Fifo, 1);
if (!f) {
r = -ENOMEM;
- log_error("Failed to create fifo object: %m");
+ log_error_errno(errno, "Failed to create fifo object: %m");
goto fail;
}
@@ -315,7 +315,7 @@ static int server_init(Server *s, unsigned n_sockets) {
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
r = -errno;
fifo_free(f);
- log_error("Failed to add fifo fd to epoll object: %m");
+ log_error_errno(errno, "Failed to add fifo fd to epoll object: %m");
goto fail;
}
@@ -413,7 +413,7 @@ int main(int argc, char *argv[]) {
if (errno == EINTR)
continue;
- log_error("epoll_wait() failed: %m");
+ log_error_errno(errno, "epoll_wait() failed: %m");
goto fail;
}
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index d39a2cc67e..7a99430a63 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -198,7 +198,7 @@ static ssize_t request_reader_entries(
else {
m->tmp = tmpfile();
if (!m->tmp) {
- log_error("Failed to create temporary file: %m");
+ log_error_errno(errno, "Failed to create temporary file: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
}
@@ -211,7 +211,7 @@ static ssize_t request_reader_entries(
sz = ftello(m->tmp);
if (sz == (off_t) -1) {
- log_error("Failed to retrieve file position: %m");
+ log_error_errno(errno, "Failed to retrieve file position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -219,7 +219,7 @@ static ssize_t request_reader_entries(
}
if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
- log_error("Failed to seek to position: %m");
+ log_error_errno(errno, "Failed to seek to position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -559,7 +559,7 @@ static ssize_t request_reader_fields(
else {
m->tmp = tmpfile();
if (!m->tmp) {
- log_error("Failed to create temporary file: %m");
+ log_error_errno(errno, "Failed to create temporary file: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
}
@@ -572,7 +572,7 @@ static ssize_t request_reader_fields(
sz = ftello(m->tmp);
if (sz == (off_t) -1) {
- log_error("Failed to retrieve file position: %m");
+ log_error_errno(errno, "Failed to retrieve file position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@ -580,7 +580,7 @@ static ssize_t request_reader_fields(
}
if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
- log_error("Failed to seek to position: %m");
+ log_error_errno(errno, "Failed to seek to position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c
index 47ff368e6c..76407f711b 100644
--- a/src/journal-remote/journal-remote-parse.c
+++ b/src/journal-remote/journal-remote-parse.c
@@ -125,7 +125,7 @@ static int get_line(RemoteSource *source, char **line, size_t *size) {
source->size - source->filled);
if (n < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK)
- log_error("read(%d, ..., %zd): %m", source->fd,
+ log_error_errno(errno, "read(%d, ..., %zd): %m", source->fd,
source->size - source->filled);
return -errno;
} else if (n == 0)
@@ -186,7 +186,7 @@ static int fill_fixed_size(RemoteSource *source, void **data, size_t size) {
source->size - source->filled);
if (n < 0) {
if (errno != EAGAIN && errno != EWOULDBLOCK)
- log_error("read(%d, ..., %zd): %m", source->fd,
+ log_error_errno(errno, "read(%d, ..., %zd): %m", source->fd,
source->size - source->filled);
return -errno;
} else if (n == 0)
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 78385538b4..06a39920e4 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -85,7 +85,7 @@ static int spawn_child(const char* child, char** argv) {
int r;
if (pipe(fd) < 0) {
- log_error("Failed to create pager pipe: %m");
+ log_error_errno(errno, "Failed to create pager pipe: %m");
return -errno;
}
@@ -94,7 +94,7 @@ static int spawn_child(const char* child, char** argv) {
child_pid = fork();
if (child_pid < 0) {
r = -errno;
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
safe_close_pair(fd);
return r;
}
@@ -103,7 +103,7 @@ static int spawn_child(const char* child, char** argv) {
if (child_pid == 0) {
r = dup2(fd[1], STDOUT_FILENO);
if (r < 0) {
- log_error("Failed to dup pipe to stdout: %m");
+ log_error_errno(errno, "Failed to dup pipe to stdout: %m");
_exit(EXIT_FAILURE);
}
@@ -119,13 +119,13 @@ static int spawn_child(const char* child, char** argv) {
_exit(EXIT_SUCCESS);
execvp(child, argv);
- log_error("Failed to exec child %s: %m", child);
+ log_error_errno(errno, "Failed to exec child %s: %m", child);
_exit(EXIT_FAILURE);
}
r = close(fd[1]);
if (r < 0)
- log_warning("Failed to close write end of pipe: %m");
+ log_warning_errno(errno, "Failed to close write end of pipe: %m");
return fd[0];
}
@@ -140,7 +140,7 @@ static int spawn_curl(const char* url) {
r = spawn_child("curl", argv);
if (r < 0)
- log_error("Failed to spawn curl: %m");
+ log_error_errno(errno, "Failed to spawn curl: %m");
return r;
}
@@ -159,7 +159,7 @@ static int spawn_getter(const char *getter, const char *url) {
r = spawn_child(words[0], words);
if (r < 0)
- log_error("Failed to spawn getter %s: %m", getter);
+ log_error_errno(errno, "Failed to spawn getter %s: %m", getter);
return r;
}
@@ -941,7 +941,7 @@ static int remoteserver_init(RemoteServer *s,
fd = open(*file, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (fd < 0) {
- log_error("Failed to open %s: %m", *file);
+ log_error_errno(errno, "Failed to open %s: %m", *file);
return -errno;
}
output_name = *file;
@@ -1054,7 +1054,7 @@ static int accept_connection(const char* type, int fd,
log_debug("Accepting new %s connection on fd:%d", type, fd);
fd2 = accept4(fd, &addr->sockaddr.sa, &addr->size, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (fd2 < 0) {
- log_error("accept() on fd:%d failed: %m", fd);
+ log_error_errno(errno, "accept() on fd:%d failed: %m", fd);
return -errno;
}
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 8da65132ca..826e41a1c4 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -308,7 +308,7 @@ static size_t fd_input_callback(void *buf, size_t size, size_t nmemb, void *user
close_fd_input(u);
return 0;
} else {
- log_error("Aborting transfer after read error on input: %m.");
+ log_error_errno(errno, "Aborting transfer after read error on input: %m.");
return CURL_READFUNC_ABORT;
}
}
@@ -358,7 +358,7 @@ static int open_file_for_upload(Uploader *u, const char *filename) {
else {
fd = open(filename, O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (fd < 0) {
- log_error("Failed to open %s: %m", filename);
+ log_error_errno(errno, "Failed to open %s: %m", filename);
return -errno;
}
}
diff --git a/src/journal/cat.c b/src/journal/cat.c
index 98f3d87b91..79706b692d 100644
--- a/src/journal/cat.c
+++ b/src/journal/cat.c
@@ -143,7 +143,7 @@ int main(int argc, char *argv[]) {
if (dup3(fd, STDOUT_FILENO, 0) < 0 ||
dup3(fd, STDERR_FILENO, 0) < 0) {
- log_error("Failed to duplicate fd: %m");
+ log_error_errno(errno, "Failed to duplicate fd: %m");
r = -errno;
goto finish;
}
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 03dddb48a5..41cdb0dade 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -210,13 +210,13 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) {
f = fopen(path, "re");
if (!f) {
- log_error("Failed to open file %s: %m", path);
+ log_error_errno(errno, "Failed to open file %s: %m", path);
return -errno;
}
r = catalog_file_lang(path, &deflang);
if (r < 0)
- log_error("Failed to determine language for file %s: %m", path);
+ log_error_errno(errno, "Failed to determine language for file %s: %m", path);
if (r == 1)
log_debug("File %s has language %s.", path, deflang);
@@ -229,7 +229,7 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) {
if (feof(f))
break;
- log_error("Failed to read file %s: %m", path);
+ log_error_errno(errno, "Failed to read file %s: %m", path);
return -errno;
}
@@ -385,7 +385,7 @@ static long write_catalog(const char *database, Hashmap *h, struct strbuf *sb,
fchmod(fileno(w), 0644);
if (rename(p, database) < 0) {
- log_error("rename (%s -> %s) failed: %m", p, database);
+ log_error_errno(errno, "rename (%s -> %s) failed: %m", p, database);
r = -errno;
goto error;
}
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index fec901e8e4..5f2ff2a025 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -140,7 +140,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
if (exclude_fd >= 0) {
if (fstat(exclude_fd, &exclude_st) < 0) {
- log_error("Failed to fstat(): %m");
+ log_error_errno(errno, "Failed to fstat(): %m");
return -errno;
}
}
@@ -156,7 +156,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
if (errno == ENOENT)
return 0;
- log_error("Can't open coredump directory: %m");
+ log_error_errno(errno, "Can't open coredump directory: %m");
return -errno;
}
@@ -258,7 +258,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
if (errno == ENOENT)
continue;
- log_error("Failed to remove file %s: %m", worst->oldest_file);
+ log_error_errno(errno, "Failed to remove file %s: %m", worst->oldest_file);
return -errno;
} else
log_info("Removed old coredump %s.", worst->oldest_file);
@@ -267,6 +267,6 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
return 0;
fail:
- log_error("Failed to read directory: %m");
+ log_error_errno(errno, "Failed to read directory: %m");
return -errno;
}
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index c22d0b0471..a871c570ca 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -143,26 +143,26 @@ static int fix_acl(int fd, uid_t uid) {
acl = acl_get_fd(fd);
if (!acl) {
- log_error("Failed to get ACL: %m");
+ log_error_errno(errno, "Failed to get ACL: %m");
return -errno;
}
if (acl_create_entry(&acl, &entry) < 0 ||
acl_set_tag_type(entry, ACL_USER) < 0 ||
acl_set_qualifier(entry, &uid) < 0) {
- log_error("Failed to patch ACL: %m");
+ log_error_errno(errno, "Failed to patch ACL: %m");
return -errno;
}
if (acl_get_permset(entry, &permset) < 0 ||
acl_add_perm(permset, ACL_READ) < 0 ||
calc_acl_mask_if_needed(&acl) < 0) {
- log_warning("Failed to patch ACL: %m");
+ log_warning_errno(errno, "Failed to patch ACL: %m");
return -errno;
}
if (acl_set_fd(fd, acl) < 0) {
- log_error("Failed to apply ACL: %m");
+ log_error_errno(errno, "Failed to apply ACL: %m");
return -errno;
}
#endif
@@ -224,12 +224,12 @@ static int fix_permissions(
fix_xattr(fd, info);
if (fsync(fd) < 0) {
- log_error("Failed to sync coredump %s: %m", filename);
+ log_error_errno(errno, "Failed to sync coredump %s: %m", filename);
return -errno;
}
if (rename(filename, target) < 0) {
- log_error("Failed to rename coredump %s -> %s: %m", filename, target);
+ log_error_errno(errno, "Failed to rename coredump %s -> %s: %m", filename, target);
return -errno;
}
@@ -248,7 +248,7 @@ static int maybe_remove_external_coredump(const char *filename, off_t size) {
return 1;
if (unlink(filename) < 0 && errno != ENOENT) {
- log_error("Failed to unlink %s: %m", filename);
+ log_error_errno(errno, "Failed to unlink %s: %m", filename);
return -errno;
}
@@ -323,7 +323,7 @@ static int save_external_coredump(
fd = open(tmp, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0640);
if (fd < 0) {
- log_error("Failed to create coredump file %s: %m", tmp);
+ log_error_errno(errno, "Failed to create coredump file %s: %m", tmp);
return -errno;
}
@@ -340,12 +340,12 @@ static int save_external_coredump(
}
if (fstat(fd, &st) < 0) {
- log_error("Failed to fstat coredump %s: %m", tmp);
+ log_error_errno(errno, "Failed to fstat coredump %s: %m", tmp);
goto fail;
}
if (lseek(fd, 0, SEEK_SET) == (off_t) -1) {
- log_error("Failed to seek on %s: %m", tmp);
+ log_error_errno(errno, "Failed to seek on %s: %m", tmp);
goto fail;
}
@@ -371,7 +371,7 @@ static int save_external_coredump(
fd_compressed = open(tmp_compressed, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0640);
if (fd_compressed < 0) {
- log_error("Failed to create file %s: %m", tmp_compressed);
+ log_error_errno(errno, "Failed to create file %s: %m", tmp_compressed);
goto uncompressed;
}
@@ -430,7 +430,7 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
assert(ret_size);
if (lseek(fd, 0, SEEK_SET) == (off_t) -1) {
- log_warning("Failed to seek: %m");
+ log_warning_errno(errno, "Failed to seek: %m");
return -errno;
}
@@ -821,7 +821,7 @@ int main(int argc, char* argv[]) {
* thus making sure the user gets access to the core dump. */
if (setresgid(gid, gid, gid) < 0 ||
setresuid(uid, uid, uid) < 0) {
- log_error("Failed to drop privileges: %m");
+ log_error_errno(errno, "Failed to drop privileges: %m");
r = -errno;
goto finish;
}
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 7e87f5f21d..2163ef9989 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -191,7 +191,7 @@ static int parse_argv(int argc, char *argv[], Set *matches) {
output = fopen(optarg, "we");
if (!output) {
- log_error("writing to '%s': %m", optarg);
+ log_error_errno(errno, "writing to '%s': %m", optarg);
return -errno;
}
@@ -610,7 +610,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
fdt = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
if (fdt < 0) {
- log_error("Failed to create temporary file: %m");
+ log_error_errno(errno, "Failed to create temporary file: %m");
return -errno;
}
log_debug("Created temporary file %s", temp);
@@ -628,7 +628,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
sz = write(fdt, data, len);
if (sz < 0) {
- log_error("Failed to write temporary file: %m");
+ log_error_errno(errno, "Failed to write temporary file: %m");
r = -errno;
goto error;
}
@@ -643,7 +643,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
fdf = open(filename, O_RDONLY | O_CLOEXEC);
if (fdf < 0) {
- log_error("Failed to open %s: %m", filename);
+ log_error_errno(errno, "Failed to open %s: %m", filename);
r = -errno;
goto error;
}
@@ -755,20 +755,20 @@ static int run_gdb(sd_journal *j) {
pid = fork();
if (pid < 0) {
- log_error("Failed to fork(): %m");
+ log_error_errno(errno, "Failed to fork(): %m");
r = -errno;
goto finish;
}
if (pid == 0) {
execlp("gdb", "gdb", exe, path, NULL);
- log_error("Failed to invoke gdb: %m");
+ log_error_errno(errno, "Failed to invoke gdb: %m");
_exit(1);
}
r = wait_for_terminate(pid, &st);
if (r < 0) {
- log_error("Failed to wait for gdb: %m");
+ log_error_errno(errno, "Failed to wait for gdb: %m");
goto finish;
}
diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c
index 5ab1982bf0..f9bd686c11 100644
--- a/src/journal/journal-authenticate.c
+++ b/src/journal/journal-authenticate.c
@@ -339,7 +339,7 @@ int journal_file_fss_load(JournalFile *f) {
fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY, 0600);
if (fd < 0) {
if (errno != ENOENT)
- log_error("Failed to open %s: %m", p);
+ log_error_errno(errno, "Failed to open %s: %m", p);
r = -errno;
goto finish;
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 8a2c0fcac5..7858435bad 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -1292,7 +1292,7 @@ void journal_file_post_change(JournalFile *f) {
__sync_synchronize();
if (ftruncate(f->fd, f->last_stat.st_size) < 0)
- log_error("Failed to truncate file to its own size: %m");
+ log_error_errno(errno, "Failed to truncate file to its own size: %m");
}
static int entry_item_cmp(const void *_a, const void *_b) {
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index 80723c47f0..4973409848 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -275,7 +275,7 @@ int journal_directory_vacuum(
log_full(verbose ? LOG_INFO : LOG_DEBUG, "Deleted empty archived journal %s/%s (%s).", directory, p, format_bytes(sbytes, sizeof(sbytes), size));
freed += size;
} else if (errno != ENOENT)
- log_warning("Failed to delete empty archived journal %s/%s: %m", directory, p);
+ log_warning_errno(errno, "Failed to delete empty archived journal %s/%s: %m", directory, p);
free(p);
continue;
@@ -318,7 +318,7 @@ int journal_directory_vacuum(
sum = 0;
} else if (errno != ENOENT)
- log_warning("Failed to delete archived journal %s/%s: %m", directory, list[i].filename);
+ log_warning_errno(errno, "Failed to delete archived journal %s/%s: %m", directory, list[i].filename);
}
if (oldest_usec && i < n_list && (*oldest_usec == 0 || list[i].realtime < *oldest_usec))
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index f74adcbc89..7e3c974b33 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -825,21 +825,21 @@ int journal_file_verify(
data_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC);
if (data_fd < 0) {
- log_error("Failed to create data file: %m");
+ log_error_errno(errno, "Failed to create data file: %m");
r = -errno;
goto fail;
}
entry_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC);
if (entry_fd < 0) {
- log_error("Failed to create entry file: %m");
+ log_error_errno(errno, "Failed to create entry file: %m");
r = -errno;
goto fail;
}
entry_array_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC);
if (entry_array_fd < 0) {
- log_error("Failed to create entry array file: %m");
+ log_error_errno(errno, "Failed to create entry array file: %m");
r = -errno;
goto fail;
}
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index d6e6332915..317b662ca6 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -795,7 +795,7 @@ static int add_matches(sd_journal *j, char **args) {
path = p ? p : *i;
if (stat(path, &st) < 0) {
- log_error("Couldn't stat file: %m");
+ log_error_errno(errno, "Couldn't stat file: %m");
return -errno;
}
@@ -1304,7 +1304,7 @@ static int setup_keys(void) {
r = stat("/var/log/journal", &st);
if (r < 0 && errno != ENOENT && errno != ENOTDIR) {
- log_error("stat(\"%s\") failed: %m", "/var/log/journal");
+ log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal");
return -errno;
}
@@ -1330,7 +1330,7 @@ static int setup_keys(void) {
if (arg_force) {
r = unlink(p);
if (r < 0) {
- log_error("unlink(\"%s\") failed: %m", p);
+ log_error_errno(errno, "unlink(\"%s\") failed: %m", p);
r = -errno;
goto finish;
}
@@ -1358,7 +1358,7 @@ static int setup_keys(void) {
fd = open("/dev/random", O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (fd < 0) {
- log_error("Failed to open /dev/random: %m");
+ log_error_errno(errno, "Failed to open /dev/random: %m");
r = -errno;
goto finish;
}
@@ -1385,7 +1385,7 @@ static int setup_keys(void) {
safe_close(fd);
fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC);
if (fd < 0) {
- log_error("Failed to open %s: %m", k);
+ log_error_errno(errno, "Failed to open %s: %m", k);
r = -errno;
goto finish;
}
@@ -1393,12 +1393,12 @@ static int setup_keys(void) {
/* Enable secure remove, exclusion from dump, synchronous
* writing and in-place updating */
if (ioctl(fd, FS_IOC_GETFLAGS, &attr) < 0)
- log_warning("FS_IOC_GETFLAGS failed: %m");
+ log_warning_errno(errno, "FS_IOC_GETFLAGS failed: %m");
attr |= FS_SECRM_FL|FS_NODUMP_FL|FS_SYNC_FL|FS_NOCOW_FL;
if (ioctl(fd, FS_IOC_SETFLAGS, &attr) < 0)
- log_warning("FS_IOC_SETFLAGS failed: %m");
+ log_warning_errno(errno, "FS_IOC_SETFLAGS failed: %m");
zero(h);
memcpy(h.signature, "KSHHRHLP", 8);
@@ -1425,7 +1425,7 @@ static int setup_keys(void) {
}
if (link(k, p) < 0) {
- log_error("Failed to link file: %m");
+ log_error_errno(errno, "Failed to link file: %m");
r = -errno;
goto finish;
}
@@ -1686,13 +1686,13 @@ static int flush_to_var(void) {
watch_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
if (watch_fd < 0) {
- log_error("Failed to create inotify watch: %m");
+ log_error_errno(errno, "Failed to create inotify watch: %m");
return -errno;
}
r = inotify_add_watch(watch_fd, "/run/systemd/journal", IN_CREATE|IN_DONT_FOLLOW|IN_ONLYDIR);
if (r < 0) {
- log_error("Failed to watch journal directory: %m");
+ log_error_errno(errno, "Failed to watch journal directory: %m");
return -errno;
}
@@ -1701,7 +1701,7 @@ static int flush_to_var(void) {
break;
if (errno != ENOENT) {
- log_error("Failed to check for existance of /run/systemd/journal/flushed: %m");
+ log_error_errno(errno, "Failed to check for existance of /run/systemd/journal/flushed: %m");
return -errno;
}
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index 18235d9308..ef4ad28833 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -523,14 +523,14 @@ int server_open_audit(Server *s) {
if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)
log_debug("Audit not supported in the kernel.");
else
- log_warning("Failed to create audit socket, ignoring: %m");
+ log_warning_errno(errno, "Failed to create audit socket, ignoring: %m");
return 0;
}
r = bind(s->audit_fd, &sa.sa, sizeof(sa.nl));
if (r < 0) {
- log_error("Failed to join audit multicast group: %m");
+ log_error_errno(errno, "Failed to join audit multicast group: %m");
return -errno;
}
} else
@@ -538,7 +538,7 @@ int server_open_audit(Server *s) {
r = setsockopt(s->audit_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
if (r < 0) {
- log_error("Failed to set SO_PASSCRED on audit socket: %m");
+ log_error_errno(errno, "Failed to set SO_PASSCRED on audit socket: %m");
return -errno;
}
diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c
index 19d077a126..4afa6ef9c3 100644
--- a/src/journal/journald-console.c
+++ b/src/journal/journald-console.c
@@ -100,12 +100,12 @@ void server_forward_console(
fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
if (fd < 0) {
- log_debug("Failed to open %s for logging: %m", tty);
+ log_debug_errno(errno, "Failed to open %s for logging: %m", tty);
return;
}
if (writev(fd, iovec, n) < 0)
- log_debug("Failed to write to %s for logging: %m", tty);
+ log_debug_errno(errno, "Failed to write to %s for logging: %m", tty);
safe_close(fd);
}
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 363c5de869..aca4571ece 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -88,7 +88,7 @@ void server_forward_kmsg(
IOVEC_SET_STRING(iovec[n++], "\n");
if (writev(s->dev_kmsg_fd, iovec, n) < 0)
- log_debug("Failed to write to /dev/kmsg for logging: %m");
+ log_debug_errno(errno, "Failed to write to /dev/kmsg for logging: %m");
free(ident_buf);
}
@@ -342,7 +342,7 @@ static int server_read_dev_kmsg(Server *s) {
if (errno == EAGAIN || errno == EINTR || errno == EPIPE)
return 0;
- log_error("Failed to read from kernel: %m");
+ log_error_errno(errno, "Failed to read from kernel: %m");
return -errno;
}
@@ -446,18 +446,18 @@ int server_open_kernel_seqnum(Server *s) {
fd = open("/run/systemd/journal/kernel-seqnum", O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644);
if (fd < 0) {
- log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
return 0;
}
if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
- log_error("Failed to allocate sequential number file, ignoring: %m");
+ log_error_errno(errno, "Failed to allocate sequential number file, ignoring: %m");
return 0;
}
p = mmap(NULL, sizeof(uint64_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
- log_error("Failed to map sequential number file, ignoring: %m");
+ log_error_errno(errno, "Failed to map sequential number file, ignoring: %m");
return 0;
}
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 6b2edc191d..a19f85d182 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -336,7 +336,7 @@ void server_process_native_file(
r = readlink_malloc(sl, &k);
if (r < 0) {
- log_error("readlink(%s) failed: %m", sl);
+ log_error_errno(errno, "readlink(%s) failed: %m", sl);
return;
}
@@ -357,7 +357,7 @@ void server_process_native_file(
}
if (fstat(fd, &st) < 0) {
- log_error("Failed to stat passed file, ignoring: %m");
+ log_error_errno(errno, "Failed to stat passed file, ignoring: %m");
return;
}
@@ -383,7 +383,7 @@ void server_process_native_file(
ps = PAGE_ALIGN(st.st_size);
p = mmap(NULL, ps, PROT_READ, MAP_PRIVATE, fd, 0);
if (p == MAP_FAILED) {
- log_error("Failed to map memfd, ignoring: %m");
+ log_error_errno(errno, "Failed to map memfd, ignoring: %m");
return;
}
@@ -425,7 +425,7 @@ int server_open_native_socket(Server*s) {
s->native_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->native_fd < 0) {
- log_error("socket() failed: %m");
+ log_error_errno(errno, "socket() failed: %m");
return -errno;
}
@@ -433,7 +433,7 @@ int server_open_native_socket(Server*s) {
r = bind(s->native_fd, &sa.sa, offsetof(union sockaddr_union, 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;
}
@@ -443,7 +443,7 @@ int server_open_native_socket(Server*s) {
r = setsockopt(s->native_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;
}
@@ -451,13 +451,13 @@ int server_open_native_socket(Server*s) {
if (mac_selinux_use()) {
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
if (r < 0)
- log_warning("SO_PASSSEC failed: %m");
+ log_warning_errno(errno, "SO_PASSSEC failed: %m");
}
#endif
r = setsockopt(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
if (r < 0) {
- log_error("SO_TIMESTAMP failed: %m");
+ log_error_errno(errno, "SO_TIMESTAMP failed: %m");
return -errno;
}
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 3d1947f25f..081ae7c08d 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -212,7 +212,7 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
acl = acl_get_fd(f->fd);
if (!acl) {
- log_warning("Failed to read ACL on %s, ignoring: %m", f->path);
+ log_warning_errno(errno, "Failed to read ACL on %s, ignoring: %m", f->path);
return;
}
@@ -222,7 +222,7 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
if (acl_create_entry(&acl, &entry) < 0 ||
acl_set_tag_type(entry, ACL_USER) < 0 ||
acl_set_qualifier(entry, &uid) < 0) {
- log_warning("Failed to patch ACL on %s, ignoring: %m", f->path);
+ log_warning_errno(errno, "Failed to patch ACL on %s, ignoring: %m", f->path);
goto finish;
}
}
@@ -232,12 +232,12 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
if (acl_get_permset(entry, &permset) < 0 ||
acl_add_perm(permset, ACL_READ) < 0 ||
calc_acl_mask_if_needed(&acl) < 0) {
- log_warning("Failed to patch ACL on %s, ignoring: %m", f->path);
+ log_warning_errno(errno, "Failed to patch ACL on %s, ignoring: %m", f->path);
goto finish;
}
if (acl_set_fd(f->fd, acl) < 0)
- log_warning("Failed to set ACL on %s, ignoring: %m", f->path);
+ log_warning_errno(errno, "Failed to set ACL on %s, ignoring: %m", f->path);
finish:
acl_free(acl);
@@ -1174,7 +1174,7 @@ int process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userda
if (errno == EINTR || errno == EAGAIN)
return 0;
- log_error("recvmsg() failed: %m");
+ log_error_errno(errno, "recvmsg() failed: %m");
return -errno;
}
@@ -1432,7 +1432,7 @@ static int server_open_hostname(Server *s) {
s->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
if (s->hostname_fd < 0) {
- log_error("Failed to open /proc/sys/kernel/hostname: %m");
+ log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
return -errno;
}
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index ee309d16b9..751b2f49b5 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -306,7 +306,7 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
if (errno == EAGAIN)
return 0;
- log_warning("Failed to read from stream: %m");
+ log_warning_errno(errno, "Failed to read from stream: %m");
goto terminate;
}
@@ -370,7 +370,7 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
if (errno == EAGAIN)
return 0;
- log_error("Failed to accept stdout connection: %m");
+ log_error_errno(errno, "Failed to accept stdout connection: %m");
return -errno;
}
@@ -390,19 +390,19 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
r = getpeercred(fd, &stream->ucred);
if (r < 0) {
- log_error("Failed to determine peer credentials: %m");
+ log_error_errno(errno, "Failed to determine peer credentials: %m");
goto fail;
}
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
if (getpeercon(fd, &stream->security_context) < 0 && errno != ENOPROTOOPT)
- log_error("Failed to determine peer security context: %m");
+ log_error_errno(errno, "Failed to determine peer security context: %m");
}
#endif
if (shutdown(fd, SHUT_WR) < 0) {
- log_error("Failed to shutdown writing side of socket: %m");
+ log_error_errno(errno, "Failed to shutdown writing side of socket: %m");
goto fail;
}
@@ -442,7 +442,7 @@ int server_open_stdout_socket(Server *s) {
s->stdout_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->stdout_fd < 0) {
- log_error("socket() failed: %m");
+ log_error_errno(errno, "socket() failed: %m");
return -errno;
}
@@ -450,14 +450,14 @@ int server_open_stdout_socket(Server *s) {
r = bind(s->stdout_fd, &sa.sa, offsetof(union sockaddr_union, 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;
}
chmod(sa.un.sun_path, 0666);
if (listen(s->stdout_fd, SOMAXCONN) < 0) {
- log_error("listen(%s) failed: %m", sa.un.sun_path);
+ log_error_errno(errno, "listen(%s) failed: %m", sa.un.sun_path);
return -errno;
}
} else
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 45483eff36..51ebd8192d 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -106,7 +106,7 @@ static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned
}
if (errno != ENOENT)
- log_debug("Failed to forward syslog message: %m");
+ log_debug_errno(errno, "Failed to forward syslog message: %m");
}
static void forward_syslog_raw(Server *s, int priority, const char *buffer, const struct ucred *ucred, const struct timeval *tv) {
@@ -429,7 +429,7 @@ int server_open_syslog_socket(Server *s) {
s->syslog_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->syslog_fd < 0) {
- log_error("socket() failed: %m");
+ log_error_errno(errno, "socket() failed: %m");
return -errno;
}
@@ -437,7 +437,7 @@ int server_open_syslog_socket(Server *s) {
r = bind(s->syslog_fd, &sa.sa, offsetof(union sockaddr_union, 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;
}
@@ -447,7 +447,7 @@ int server_open_syslog_socket(Server *s) {
r = setsockopt(s->syslog_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;
}
@@ -455,13 +455,13 @@ int server_open_syslog_socket(Server *s) {
if (mac_selinux_use()) {
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
if (r < 0)
- log_warning("SO_PASSSEC failed: %m");
+ log_warning_errno(errno, "SO_PASSSEC failed: %m");
}
#endif
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
if (r < 0) {
- log_error("SO_TIMESTAMP failed: %m");
+ log_error_errno(errno, "SO_TIMESTAMP failed: %m");
return -errno;
}
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index d171600eef..bb410ed6ec 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1410,7 +1410,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
d = opendir(path);
if (!d) {
- log_debug("Failed to open %s: %m", path);
+ log_debug_errno(errno, "Failed to open %s: %m", path);
if (errno == ENOENT)
return 0;
return -errno;
@@ -1456,7 +1456,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
de = readdir(d);
if (!de && errno != 0) {
r = -errno;
- log_debug("Failed to read directory %s: %m", m->path);
+ log_debug_errno(errno, "Failed to read directory %s: %m", m->path);
return r;
}
if (!de)
@@ -1546,7 +1546,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
de = readdir(d);
if (!de && errno != 0) {
r = -errno;
- log_debug("Failed to read directory %s: %m", m->path);
+ log_debug_errno(errno, "Failed to read directory %s: %m", m->path);
return r;
}
if (!de)
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
index b77f4b0f51..afb61c71a4 100644
--- a/src/libsystemd-terminal/evcat.c
+++ b/src/libsystemd-terminal/evcat.c
@@ -359,13 +359,13 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
r = ioctl(1, KDSKBMODE, K_UNICODE);
if (r < 0) {
- log_error("Cannot set K_UNICODE on stdout: %m");
+ log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
return -errno;
}
r = ioctl(1, KDSETMODE, KD_TEXT);
if (r < 0) {
- log_error("Cannot set KD_TEXT on stdout: %m");
+ log_error_errno(errno, "Cannot set KD_TEXT on stdout: %m");
return -errno;
}
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
index 2d678e8acf..2df63537f0 100644
--- a/src/libsystemd-terminal/grdev-drm.c
+++ b/src/libsystemd-terminal/grdev-drm.c
@@ -468,9 +468,11 @@ static int grdrm_plane_resync(grdrm_plane *plane) {
if (r == -ENOENT) {
card->async_hotplug = true;
r = 0;
- log_debug("grdrm: %s: plane %u removed during resync", card->base.name, plane->object.id);
+ log_debug("grdrm: %s: plane %u removed during resync",
+ card->base.name, plane->object.id);
} else {
- log_debug("grdrm: %s: cannot retrieve plane %u: %m", card->base.name, plane->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot retrieve plane %u: %m",
+ card->base.name, plane->object.id);
}
return r;
@@ -625,9 +627,11 @@ static int grdrm_connector_resync(grdrm_connector *connector) {
if (r == -ENOENT) {
card->async_hotplug = true;
r = 0;
- log_debug("grdrm: %s: connector %u removed during resync", card->base.name, connector->object.id);
+ log_debug("grdrm: %s: connector %u removed during resync",
+ card->base.name, connector->object.id);
} else {
- log_debug("grdrm: %s: cannot retrieve connector %u: %m", card->base.name, connector->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot retrieve connector %u: %m",
+ card->base.name, connector->object.id);
}
return r;
@@ -783,9 +787,11 @@ static int grdrm_encoder_resync(grdrm_encoder *encoder) {
if (r == -ENOENT) {
card->async_hotplug = true;
r = 0;
- log_debug("grdrm: %s: encoder %u removed during resync", card->base.name, encoder->object.id);
+ log_debug("grdrm: %s: encoder %u removed during resync",
+ card->base.name, encoder->object.id);
} else {
- log_debug("grdrm: %s: cannot retrieve encoder %u: %m", card->base.name, encoder->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot retrieve encoder %u: %m",
+ card->base.name, encoder->object.id);
}
return r;
@@ -916,9 +922,11 @@ static int grdrm_crtc_resync(grdrm_crtc *crtc) {
if (r == -ENOENT) {
card->async_hotplug = true;
r = 0;
- log_debug("grdrm: %s: crtc %u removed during resync", card->base.name, crtc->object.id);
+ log_debug("grdrm: %s: crtc %u removed during resync",
+ card->base.name, crtc->object.id);
} else {
- log_debug("grdrm: %s: cannot retrieve crtc %u: %m", card->base.name, crtc->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot retrieve crtc %u: %m",
+ card->base.name, crtc->object.id);
}
return r;
@@ -1119,8 +1127,8 @@ static void grdrm_crtc_commit_deep(grdrm_crtc *crtc, grdev_fb *basefb) {
r = ioctl(card->fd, DRM_IOCTL_MODE_SETCRTC, &set_crtc);
if (r < 0) {
r = -errno;
- log_debug("grdrm: %s: cannot set crtc %" PRIu32 ": %m",
- card->base.name, crtc->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot set crtc %" PRIu32 ": %m",
+ card->base.name, crtc->object.id);
grdrm_card_async(card, r);
return;
@@ -1188,8 +1196,8 @@ static int grdrm_crtc_commit_flip(grdrm_crtc *crtc, grdev_fb *basefb) {
* possible to see whether cards support page-flipping, so
* avoid logging on each frame. */
if (r != -EINVAL)
- log_debug("grdrm: %s: cannot schedule page-flip on crtc %" PRIu32 ": %m",
- card->base.name, crtc->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot schedule page-flip on crtc %" PRIu32 ": %m",
+ card->base.name, crtc->object.id);
if (grdrm_card_async(card, r))
return r;
@@ -1241,8 +1249,8 @@ static void grdrm_crtc_commit(grdrm_crtc *crtc) {
r = ioctl(card->fd, DRM_IOCTL_MODE_SETCRTC, &set_crtc);
if (r < 0) {
r = -errno;
- log_debug("grdrm: %s: cannot shutdown crtc %" PRIu32 ": %m",
- card->base.name, crtc->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot shutdown crtc %" PRIu32 ": %m",
+ card->base.name, crtc->object.id);
grdrm_card_async(card, r);
return;
@@ -1298,8 +1306,8 @@ static void grdrm_crtc_restore(grdrm_crtc *crtc) {
r = ioctl(card->fd, DRM_IOCTL_MODE_SETCRTC, &set_crtc);
if (r < 0) {
r = -errno;
- log_debug("grdrm: %s: cannot restore crtc %" PRIu32 ": %m",
- card->base.name, crtc->object.id);
+ log_debug_errno(errno, "grdrm: %s: cannot restore crtc %" PRIu32 ": %m",
+ card->base.name, crtc->object.id);
grdrm_card_async(card, r);
return;
@@ -1394,8 +1402,8 @@ static int grdrm_fb_new(grdrm_fb **out, grdrm_card *card, const struct drm_mode_
r = ioctl(card->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb);
if (r < 0) {
r = negative_errno();
- log_debug("grdrm: %s: cannot create dumb buffer %" PRIu32 "x%" PRIu32": %m",
- card->base.name, fb->base.width, fb->base.height);
+ log_debug_errno(errno, "grdrm: %s: cannot create dumb buffer %" PRIu32 "x%" PRIu32": %m",
+ card->base.name, fb->base.width, fb->base.height);
return r;
}
@@ -1408,16 +1416,16 @@ static int grdrm_fb_new(grdrm_fb **out, grdrm_card *card, const struct drm_mode_
r = ioctl(card->fd, DRM_IOCTL_MODE_MAP_DUMB, &map_dumb);
if (r < 0) {
r = negative_errno();
- log_debug("grdrm: %s: cannot map dumb buffer %" PRIu32 "x%" PRIu32": %m",
- card->base.name, fb->base.width, fb->base.height);
+ log_debug_errno(errno, "grdrm: %s: cannot map dumb buffer %" PRIu32 "x%" PRIu32": %m",
+ card->base.name, fb->base.width, fb->base.height);
return r;
}
fb->base.maps[0] = mmap(0, fb->sizes[0], PROT_WRITE, MAP_SHARED, card->fd, map_dumb.offset);
if (fb->base.maps[0] == MAP_FAILED) {
r = negative_errno();
- log_debug("grdrm: %s: cannot memory-map dumb buffer %" PRIu32 "x%" PRIu32": %m",
- card->base.name, fb->base.width, fb->base.height);
+ log_debug_errno(errno, "grdrm: %s: cannot memory-map dumb buffer %" PRIu32 "x%" PRIu32": %m",
+ card->base.name, fb->base.width, fb->base.height);
return r;
}
@@ -1434,8 +1442,8 @@ static int grdrm_fb_new(grdrm_fb **out, grdrm_card *card, const struct drm_mode_
r = ioctl(card->fd, DRM_IOCTL_MODE_ADDFB2, &add_fb);
if (r < 0) {
r = negative_errno();
- log_debug("grdrm: %s: cannot add framebuffer %" PRIu32 "x%" PRIu32": %m",
- card->base.name, fb->base.width, fb->base.height);
+ log_debug_errno(errno, "grdrm: %s: cannot add framebuffer %" PRIu32 "x%" PRIu32": %m",
+ card->base.name, fb->base.width, fb->base.height);
return r;
}
@@ -1461,8 +1469,8 @@ grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
if (fb->id > 0 && fb->card->fd >= 0) {
r = ioctl(fb->card->fd, DRM_IOCTL_MODE_RMFB, fb->id);
if (r < 0)
- log_debug("grdrm: %s: cannot delete framebuffer %" PRIu32 ": %m",
- fb->card->base.name, fb->id);
+ log_debug_errno(errno, "grdrm: %s: cannot delete framebuffer %" PRIu32 ": %m",
+ fb->card->base.name, fb->id);
}
for (i = 0; i < ELEMENTSOF(fb->handles); ++i) {
@@ -1475,8 +1483,8 @@ grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
destroy_dumb.handle = fb->handles[i];
r = ioctl(fb->card->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
if (r < 0)
- log_debug("grdrm: %s: cannot destroy dumb-buffer %" PRIu32 ": %m",
- fb->card->base.name, fb->handles[i]);
+ log_debug_errno(errno, "grdrm: %s: cannot destroy dumb-buffer %" PRIu32 ": %m",
+ fb->card->base.name, fb->handles[i]);
}
}
@@ -1777,7 +1785,8 @@ static int grdrm_card_resync(grdrm_card *card) {
r = ioctl(card->fd, DRM_IOCTL_MODE_GETRESOURCES, &res);
if (r < 0) {
r = -errno;
- log_debug("grdrm: %s: cannot retrieve drm resources: %m", card->base.name);
+ log_debug_errno(errno, "grdrm: %s: cannot retrieve drm resources: %m",
+ card->base.name);
return r;
}
@@ -1788,7 +1797,8 @@ static int grdrm_card_resync(grdrm_card *card) {
r = ioctl(card->fd, DRM_IOCTL_MODE_GETPLANERESOURCES, &pres);
if (r < 0) {
r = -errno;
- log_debug("grdrm: %s: cannot retrieve drm plane-resources: %m", card->base.name);
+ log_debug_errno(errno, "grdrm: %s: cannot retrieve drm plane-resources: %m",
+ card->base.name);
return r;
}
@@ -1799,7 +1809,8 @@ static int grdrm_card_resync(grdrm_card *card) {
n = ALIGN_POWER2(max);
if (!n || n > UINT16_MAX) {
- log_debug("grdrm: %s: excessive DRM resource limit: %" PRIu32, card->base.name, max);
+ log_debug("grdrm: %s: excessive DRM resource limit: %" PRIu32,
+ card->base.name, max);
return -ERANGE;
}
@@ -2228,7 +2239,8 @@ static int grdrm_card_io_fn(sd_event_source *s, int fd, uint32_t revents, void *
if (errno == EAGAIN || errno == EINTR)
return 0;
- log_debug("grdrm: %s/%s: read error: %m", card->base.session->name, card->base.name);
+ log_debug_errno(errno, "grdrm: %s/%s: read error: %m",
+ card->base.session->name, card->base.name);
grdrm_card_close(card);
return 0;
}
@@ -2237,7 +2249,8 @@ static int grdrm_card_io_fn(sd_event_source *s, int fd, uint32_t revents, void *
event = (void*)buf;
if (len < sizeof(*event) || len < event->length) {
- log_debug("grdrm: %s/%s: truncated event", card->base.session->name, card->base.name);
+ log_debug("grdrm: %s/%s: truncated event",
+ card->base.session->name, card->base.name);
break;
}
@@ -2245,7 +2258,8 @@ static int grdrm_card_io_fn(sd_event_source *s, int fd, uint32_t revents, void *
case DRM_EVENT_FLIP_COMPLETE:
vblank = (void*)event;
if (event->length < sizeof(*vblank)) {
- log_debug("grdrm: %s/%s: truncated vblank event", card->base.session->name, card->base.name);
+ log_debug("grdrm: %s/%s: truncated vblank event",
+ card->base.session->name, card->base.name);
break;
}
@@ -2498,8 +2512,8 @@ static void unmanaged_card_enable(grdev_card *basecard) {
fd = open(cu->devnode, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
/* not fatal; simply ignore the device */
- log_debug("grdrm: %s/%s: cannot open node %s: %m",
- basecard->session->name, basecard->name, cu->devnode);
+ log_debug_errno(errno, "grdrm: %s/%s: cannot open node %s: %m",
+ basecard->session->name, basecard->name, cu->devnode);
return;
}
@@ -2515,8 +2529,8 @@ static void unmanaged_card_enable(grdev_card *basecard) {
r = ioctl(cu->card.fd, DRM_IOCTL_SET_MASTER, 0);
if (r < 0) {
- log_debug("grdrm: %s/%s: cannot acquire DRM-Master: %m",
- basecard->session->name, basecard->name);
+ log_debug_errno(errno, "grdrm: %s/%s: cannot acquire DRM-Master: %m",
+ basecard->session->name, basecard->name);
return;
}
@@ -2566,8 +2580,8 @@ static int unmanaged_card_new(grdev_card **out, grdev_session *session, struct u
fd = open(cu->devnode, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
/* not fatal; allow uaccess based control on activation */
- log_debug("grdrm: %s/%s: cannot open node %s: %m",
- basecard->session->name, basecard->name, cu->devnode);
+ log_debug_errno(errno, "grdrm: %s/%s: cannot open node %s: %m",
+ basecard->session->name, basecard->name, cu->devnode);
} else {
/* We might get DRM-Master implicitly on open(); drop it immediately
* so we acquire it only once we're actually enabled. We don't
@@ -2575,8 +2589,8 @@ static int unmanaged_card_new(grdev_card **out, grdev_session *session, struct u
* weird errors, anyway. */
r = ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
if (r < 0 && errno != EACCES && errno != EINVAL)
- log_debug("grdrm: %s/%s: cannot drop DRM-Master: %m",
- basecard->session->name, basecard->name);
+ log_debug_errno(errno, "grdrm: %s/%s: cannot drop DRM-Master: %m",
+ basecard->session->name, basecard->name);
r = grdrm_card_open(&cu->card, fd);
if (r < 0)
@@ -2771,8 +2785,8 @@ static int managed_card_resume_device_fn(sd_bus *bus,
* and our code works fine this way. */
fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
if (fd < 0) {
- log_debug("grdrm: %s/%s: cannot duplicate fd: %m",
- session->name, cm->card.base.name);
+ log_debug_errno(errno, "grdrm: %s/%s: cannot duplicate fd: %m",
+ session->name, cm->card.base.name);
return 0;
}
@@ -2863,8 +2877,8 @@ static int managed_card_take_device_fn(sd_bus *bus,
fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
if (fd < 0) {
- log_debug("grdrm: %s/%s: cannot duplicate fd: %m",
- session->name, cm->card.base.name);
+ log_debug_errno(errno, "grdrm: %s/%s: cannot duplicate fd: %m",
+ session->name, cm->card.base.name);
return 0;
}
diff --git a/src/libsystemd-terminal/idev-evdev.c b/src/libsystemd-terminal/idev-evdev.c
index b3e86bfb19..dfbb2d197f 100644
--- a/src/libsystemd-terminal/idev-evdev.c
+++ b/src/libsystemd-terminal/idev-evdev.c
@@ -426,15 +426,15 @@ static void unmanaged_evdev_resume(idev_element *e) {
fd = open(eu->devnode, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
if (errno != EACCES && errno != EPERM) {
- log_debug("idev-evdev: %s/%s: cannot open node %s: %m",
- e->session->name, e->name, eu->devnode);
+ log_debug_errno(errno, "idev-evdev: %s/%s: cannot open node %s: %m",
+ e->session->name, e->name, eu->devnode);
return;
}
fd = open(eu->devnode, O_RDONLY | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
- log_debug("idev-evdev: %s/%s: cannot open node %s: %m",
- e->session->name, e->name, eu->devnode);
+ log_debug_errno(errno, "idev-evdev: %s/%s: cannot open node %s: %m",
+ e->session->name, e->name, eu->devnode);
return;
}
@@ -565,7 +565,7 @@ static int managed_evdev_take_device_fn(sd_bus *bus,
fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
if (fd < 0) {
- log_debug("idev-evdev: %s/%s: cannot duplicate evdev fd: %m", s->name, e->name);
+ log_debug_errno(errno, "idev-evdev: %s/%s: cannot duplicate evdev fd: %m", s->name, e->name);
return 0;
}
@@ -698,8 +698,8 @@ static void managed_evdev_resume(idev_element *e, int fd) {
fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
if (fd < 0) {
- log_debug("idev-evdev: %s/%s: cannot duplicate evdev fd: %m",
- s->name, e->name);
+ log_debug_errno(errno, "idev-evdev: %s/%s: cannot duplicate evdev fd: %m",
+ s->name, e->name);
return;
}
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
index 0b6499b18f..f7bcbb2914 100644
--- a/src/libsystemd-terminal/modeset.c
+++ b/src/libsystemd-terminal/modeset.c
@@ -355,7 +355,7 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
r = ioctl(1, KDSKBMODE, K_UNICODE);
if (r < 0) {
- log_error("Cannot set K_UNICODE on stdout: %m");
+ log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
return -errno;
}
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c
index 920b661af4..f2651b24ac 100644
--- a/src/libsystemd-terminal/subterm.c
+++ b/src/libsystemd-terminal/subterm.c
@@ -103,7 +103,7 @@ static int output_winch(Output *o) {
r = ioctl(o->fd, TIOCGWINSZ, &wsz);
if (r < 0) {
- log_error("error: cannot read window-size: %m");
+ log_error_errno(errno, "error: cannot read window-size: %m");
return -errno;
}
@@ -707,7 +707,7 @@ static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi
if (errno == EAGAIN || errno == EINTR)
return 0;
- log_error("error: cannot read from TTY (%d): %m", -errno);
+ log_error_errno(errno, "error: cannot read from TTY (%d): %m", -errno);
return -errno;
}
@@ -823,13 +823,13 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
r = tcgetattr(in_fd, &in_attr);
if (r < 0) {
- log_error("error: tcgetattr() (%d): %m", -errno);
+ log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
return -errno;
}
r = tcgetattr(out_fd, &out_attr);
if (r < 0) {
- log_error("error: tcgetattr() (%d): %m", -errno);
+ log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
return -errno;
}
@@ -955,7 +955,7 @@ static int terminal_run(Terminal *t) {
setenv("COLORTERM", "systemd-subterm", 1);
execve(argv[0], argv, environ);
- log_error("error: cannot exec %s (%d): %m", argv[0], -errno);
+ log_error_errno(errno, "error: cannot exec %s (%d): %m", argv[0], -errno);
_exit(1);
}
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index e91c402c5b..4a025d69ea 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -229,7 +229,7 @@ static int server(sd_bus *bus) {
log_info("Received fd=%d", fd);
if (write(fd, &x, 1) < 0) {
- log_error("Failed to write to fd: %m");
+ log_error_errno(errno, "Failed to write to fd: %m");
safe_close(fd);
goto fail;
}
@@ -302,7 +302,7 @@ static void* client1(void*p) {
assert(streq(hello, "hello"));
if (pipe2(pp, O_CLOEXEC|O_NONBLOCK) < 0) {
- log_error("Failed to allocate pipe: %m");
+ log_error_errno(errno, "Failed to allocate pipe: %m");
r = -errno;
goto finish;
}
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index aa3b2270e0..be3f17fd47 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -129,7 +129,7 @@ int udev_device_update_db(struct udev_device *udev_device)
mkdir_parents(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
if (f == NULL) {
- log_debug("unable to create temporary db file '%s': %m", filename_tmp);
+ log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
return -errno;
}
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index fc7d928721..400fb74d83 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -535,7 +535,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
f = fopen(dbfile, "re");
if (f == NULL) {
- log_debug("no db file to read %s: %m", dbfile);
+ log_debug_errno(errno, "no db file to read %s: %m", dbfile);
return -errno;
}
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index 1d0d407208..05a685868f 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -289,7 +289,7 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
else if (errno == ENOENT)
continue;
else {
- log_debug("error reading %s: %m", hwdb_bin_path);
+ log_debug_errno(errno, "error reading %s: %m", hwdb_bin_path);
udev_hwdb_unref(hwdb);
return NULL;
}
@@ -303,14 +303,14 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
(size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
- log_debug("error reading %s: %m", hwdb_bin_path);
+ log_debug_errno(errno, "error reading %s: %m", hwdb_bin_path);
udev_hwdb_unref(hwdb);
return NULL;
}
hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
if (hwdb->map == MAP_FAILED) {
- log_debug("error mapping %s: %m", hwdb_bin_path);
+ log_debug_errno(errno, "error mapping %s: %m", hwdb_bin_path);
udev_hwdb_unref(hwdb);
return NULL;
}
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index bdb5516047..e8d6b4a61b 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -121,7 +121,7 @@ static bool udev_has_devtmpfs(struct udev *udev) {
r = name_to_handle_at(AT_FDCWD, "/dev", &h.handle, &mount_id, 0);
if (r < 0) {
if (errno != EOPNOTSUPP)
- log_debug("name_to_handle_at on /dev: %m");
+ log_debug_errno(errno, "name_to_handle_at on /dev: %m");
return false;
}
@@ -190,7 +190,7 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
if (fd < 0) {
udev_monitor->sock = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT);
if (udev_monitor->sock == -1) {
- log_debug("error getting socket: %m");
+ log_debug_errno(errno, "error getting socket: %m");
free(udev_monitor);
return NULL;
}
@@ -407,14 +407,14 @@ _public_ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
if (err == 0)
udev_monitor->snl.nl.nl_pid = snl.nl.nl_pid;
} else {
- log_debug("bind failed: %m");
+ log_debug_errno(errno, "bind failed: %m");
return -errno;
}
/* enable receiving of sender credentials */
err = setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (err < 0)
- log_debug("setting SO_PASSCRED failed: %m");
+ log_debug_errno(errno, "setting SO_PASSCRED failed: %m");
return 0;
}
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index cb2920974c..a0df78ed6b 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -402,7 +402,7 @@ static int list_x11_keymaps(sd_bus *bus, char **args, unsigned n) {
f = fopen("/usr/share/X11/xkb/rules/base.lst", "re");
if (!f) {
- log_error("Failed to open keyboard mapping list. %m");
+ log_error_errno(errno, "Failed to open keyboard mapping list. %m");
return -errno;
}
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index db977ccc59..b81cf0f688 100644
--- a/src/login/inhibit.c
+++ b/src/login/inhibit.c
@@ -266,7 +266,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");
return EXIT_FAILURE;
}
@@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
close_all_fds(NULL, 0);
execvp(argv[optind], argv + optind);
- log_error("Failed to execute %s: %m", argv[optind]);
+ log_error_errno(errno, "Failed to execute %s: %m", argv[optind]);
_exit(EXIT_FAILURE);
}
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 9c0c6302a9..1afb01fc68 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -251,12 +251,12 @@ int button_open(Button *b) {
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (b->fd < 0) {
- log_warning("Failed to open %s: %m", b->name);
+ log_warning_errno(errno, "Failed to open %s: %m", b->name);
return -errno;
}
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
- log_error("Failed to get input name: %m");
+ log_error_errno(errno, "Failed to get input name: %m");
r = -errno;
goto fail;
}
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index d225ba1619..d4123117a3 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1159,7 +1159,7 @@ static int flush_devices(Manager *m) {
d = opendir("/etc/udev/rules.d");
if (!d) {
if (errno != ENOENT)
- log_warning("Failed to open /etc/udev/rules.d: %m");
+ log_warning_errno(errno, "Failed to open /etc/udev/rules.d: %m");
} else {
struct dirent *de;
@@ -1175,7 +1175,7 @@ static int flush_devices(Manager *m) {
continue;
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
- log_warning("Failed to unlink %s: %m", de->d_name);
+ log_warning_errno(errno, "Failed to unlink %s: %m", de->d_name);
}
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 5b30457a88..c1800e0854 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -968,7 +968,7 @@ static int session_open_vt(Session *s) {
sprintf(path, "/dev/tty%u", s->vtnr);
s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
if (s->vtfd < 0) {
- log_error("cannot open VT %s of session %s: %m", path, s->id);
+ log_error_errno(errno, "cannot open VT %s of session %s: %m", path, s->id);
return -errno;
}
@@ -989,21 +989,21 @@ int session_prepare_vt(Session *s) {
r = fchown(vt, s->user->uid, -1);
if (r < 0) {
r = -errno;
- log_error("Cannot change owner of /dev/tty%u: %m", s->vtnr);
+ log_error_errno(errno, "Cannot change owner of /dev/tty%u: %m", s->vtnr);
goto error;
}
r = ioctl(vt, KDSKBMODE, K_OFF);
if (r < 0) {
r = -errno;
- log_error("Cannot set K_OFF on /dev/tty%u: %m", s->vtnr);
+ log_error_errno(errno, "Cannot set K_OFF on /dev/tty%u: %m", s->vtnr);
goto error;
}
r = ioctl(vt, KDSETMODE, KD_GRAPHICS);
if (r < 0) {
r = -errno;
- log_error("Cannot set KD_GRAPHICS on /dev/tty%u: %m", s->vtnr);
+ log_error_errno(errno, "Cannot set KD_GRAPHICS on /dev/tty%u: %m", s->vtnr);
goto error;
}
@@ -1016,7 +1016,7 @@ int session_prepare_vt(Session *s) {
r = ioctl(vt, VT_SETMODE, &mode);
if (r < 0) {
r = -errno;
- log_error("Cannot set VT_PROCESS on /dev/tty%u: %m", s->vtnr);
+ log_error_errno(errno, "Cannot set VT_PROCESS on /dev/tty%u: %m", s->vtnr);
goto error;
}
@@ -1073,7 +1073,7 @@ void session_leave_vt(Session *s) {
session_device_pause_all(s);
r = ioctl(s->vtfd, VT_RELDISP, 1);
if (r < 0)
- log_debug("Cannot release VT of session %s: %m", s->id);
+ log_debug_errno(errno, "Cannot release VT of session %s: %m", s->id);
}
bool session_is_controller(Session *s, const char *sender) {
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index f865afdb53..9ff1302663 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -511,7 +511,7 @@ static int user_remove_runtime_path(User *u) {
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
if (umount2(u->runtime_path, MNT_DETACH) < 0)
- log_error("Failed to unmount user runtime directory %s: %m", u->runtime_path);
+ log_error_errno(errno, "Failed to unmount user runtime directory %s: %m", u->runtime_path);
r = rm_rf(u->runtime_path, false, true, false);
if (r < 0)
diff --git a/src/login/logind.c b/src/login/logind.c
index 78220ff4dd..b44f376427 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -290,7 +290,7 @@ static int manager_enumerate_seats(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /run/systemd/seats: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/seats: %m");
return -errno;
}
@@ -327,7 +327,7 @@ static int manager_enumerate_linger_users(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /var/lib/systemd/linger/: %m");
+ log_error_errno(errno, "Failed to open /var/lib/systemd/linger/: %m");
return -errno;
}
@@ -363,7 +363,7 @@ static int manager_enumerate_users(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /run/systemd/users: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/users: %m");
return -errno;
}
@@ -404,7 +404,7 @@ static int manager_enumerate_sessions(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /run/systemd/sessions: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/sessions: %m");
return -errno;
}
@@ -451,7 +451,7 @@ static int manager_enumerate_inhibitors(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /run/systemd/inhibit: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/inhibit: %m");
return -errno;
}
@@ -568,7 +568,7 @@ static int manager_reserve_vt(Manager *m) {
/* Don't complain on VT-less systems */
if (errno != ENOENT)
- log_warning("Failed to pin reserved VT: %m");
+ log_warning_errno(errno, "Failed to pin reserved VT: %m");
return -errno;
}
@@ -753,7 +753,7 @@ static int manager_connect_console(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /sys/class/tty/tty0/active: %m");
+ log_error_errno(errno, "Failed to open /sys/class/tty/tty0/active: %m");
return -errno;
}
diff --git a/src/login/user-sessions.c b/src/login/user-sessions.c
index fb0afc5e50..6edb823e8c 100644
--- a/src/login/user-sessions.c
+++ b/src/login/user-sessions.c
@@ -44,7 +44,7 @@ int main(int argc, char*argv[]) {
int r = 0;
if (unlink("/run/nologin") < 0 && errno != ENOENT) {
- log_error("Failed to remove /run/nologin file: %m");
+ log_error_errno(errno, "Failed to remove /run/nologin file: %m");
r = -errno;
}
@@ -55,7 +55,7 @@ int main(int argc, char*argv[]) {
* exist), don't complain */
if (errno != EROFS || access("/etc/nologin", F_OK) >= 0) {
- log_error("Failed to remove /etc/nologin file: %m");
+ log_error_errno(errno, "Failed to remove /etc/nologin file: %m");
return EXIT_FAILURE;
}
}
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 6db9e5c91b..5ea4f4b0d9 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -726,7 +726,7 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
pty = ptsname(master);
if (!pty) {
- log_error("Failed to get pty name: %m");
+ log_error_errno(errno, "Failed to get pty name: %m");
return -errno;
}
@@ -745,7 +745,7 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
return log_oom();
if (unlockpt(master) < 0) {
- log_error("Failed to unlock tty: %m");
+ log_error_errno(errno, "Failed to unlock tty: %m");
return -errno;
}
diff --git a/src/machine/machined.c b/src/machine/machined.c
index d1c10d2a26..ef59497fb2 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -96,7 +96,7 @@ int manager_enumerate_machines(Manager *m) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open /run/systemd/machines: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/machines: %m");
return -errno;
}
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 4dbacd13dc..5f678789ce 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -151,7 +151,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent
if (feof(f))
break;
- log_error("Failed to read file '%s', ignoring: %m", path);
+ log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
return -errno;
}
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 035dce162b..c0cbbe0647 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -195,7 +195,7 @@ static int list_links(char **args, unsigned n) {
udev = udev_new();
if (!udev) {
- log_error("Failed to connect to udev: %m");
+ log_error_errno(errno, "Failed to connect to udev: %m");
return -errno;
}
@@ -446,7 +446,7 @@ static int link_status(char **args, unsigned n) {
udev = udev_new();
if (!udev) {
- log_error("Failed to connect to udev: %m");
+ log_error_errno(errno, "Failed to connect to udev: %m");
return -errno;
}
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 3a8450ed7b..e3e3dfe20e 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -302,7 +302,7 @@ static int parse_argv(int argc, char *argv[]) {
free(arg_directory);
arg_directory = canonicalize_file_name(optarg);
if (!arg_directory) {
- log_error("Invalid root directory: %m");
+ log_error_errno(errno, "Invalid root directory: %m");
return -ENOMEM;
}
@@ -718,12 +718,12 @@ static int mount_all(const char *dest) {
o) < 0) {
if (mount_table[k].fatal) {
- log_error("mount(%s) failed: %m", where);
+ log_error_errno(errno, "mount(%s) failed: %m", where);
if (r == 0)
r = -errno;
} else
- log_warning("mount(%s) failed: %m", where);
+ log_warning_errno(errno, "mount(%s) failed: %m", where);
}
}
@@ -739,7 +739,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
int r;
if (stat(*x, &source_st) < 0) {
- log_error("Failed to stat %s: %m", *x);
+ log_error_errno(errno, "Failed to stat %s: %m", *x);
return -errno;
}
@@ -758,7 +758,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
if (r < 0)
return log_error_errno(r, "Failed to bind mount %s: %m", *x);
} else {
- log_error("Failed to bind mount %s: %m", *x);
+ log_error_errno(errno, "Failed to bind mount %s: %m", *x);
return -errno;
}
@@ -771,14 +771,14 @@ static int mount_binds(const char *dest, char **l, bool ro) {
} else if (S_ISFIFO(source_st.st_mode)) {
r = mkfifo(where, 0644);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create mount point %s: %m", where);
+ log_error_errno(errno, "Failed to create mount point %s: %m", where);
return -errno;
}
} else if (S_ISSOCK(source_st.st_mode)) {
r = mknod(where, 0644 | S_IFSOCK, 0);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create mount point %s: %m", where);
+ log_error_errno(errno, "Failed to create mount point %s: %m", where);
return -errno;
}
@@ -792,7 +792,7 @@ static int mount_binds(const char *dest, char **l, bool ro) {
}
if (mount(*x, where, "bind", MS_BIND, NULL) < 0) {
- log_error("mount(%s) failed: %m", where);
+ log_error_errno(errno, "mount(%s) failed: %m", where);
return -errno;
}
@@ -822,7 +822,7 @@ static int mount_tmpfs(const char *dest) {
return log_error_errno(r, "creating mount point for tmpfs %s failed: %m", where);
if (mount("tmpfs", where, "tmpfs", MS_NODEV|MS_STRICTATIME, *o) < 0) {
- log_error("tmpfs mount to %s failed: %m", where);
+ log_error_errno(errno, "tmpfs mount to %s failed: %m", where);
return -errno;
}
}
@@ -889,13 +889,13 @@ static int setup_timezone(const char *dest) {
r = unlink(where);
if (r < 0 && errno != ENOENT) {
- log_error("Failed to remove existing timezone info %s in container: %m", where);
+ log_error_errno(errno, "Failed to remove existing timezone info %s in container: %m", where);
return 0;
}
if (symlink(what, where) < 0) {
- log_error("Failed to correct timezone of container: %m");
+ log_error_errno(errno, "Failed to correct timezone of container: %m");
return 0;
}
@@ -954,12 +954,12 @@ static int setup_volatile_state(const char *directory) {
p = strappenda(directory, "/var");
r = mkdir(p, 0755);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create %s: %m", directory);
+ log_error_errno(errno, "Failed to create %s: %m", directory);
return -errno;
}
if (mount("tmpfs", p, "tmpfs", MS_STRICTATIME, "mode=755") < 0) {
- log_error("Failed to mount tmpfs to /var: %m");
+ log_error_errno(errno, "Failed to mount tmpfs to /var: %m");
return -errno;
}
@@ -981,12 +981,12 @@ static int setup_volatile(const char *directory) {
the original /usr to use inside it, and that read-only. */
if (!mkdtemp(template)) {
- log_error("Failed to create temporary directory: %m");
+ log_error_errno(errno, "Failed to create temporary directory: %m");
return -errno;
}
if (mount("tmpfs", template, "tmpfs", MS_STRICTATIME, "mode=755") < 0) {
- log_error("Failed to mount tmpfs for root directory: %m");
+ log_error_errno(errno, "Failed to mount tmpfs for root directory: %m");
r = -errno;
goto fail;
}
@@ -998,13 +998,13 @@ static int setup_volatile(const char *directory) {
r = mkdir(t, 0755);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create %s: %m", t);
+ log_error_errno(errno, "Failed to create %s: %m", t);
r = -errno;
goto fail;
}
if (mount(f, t, "bind", MS_BIND|MS_REC, NULL) < 0) {
- log_error("Failed to create /usr bind mount: %m");
+ log_error_errno(errno, "Failed to create /usr bind mount: %m");
r = -errno;
goto fail;
}
@@ -1018,7 +1018,7 @@ static int setup_volatile(const char *directory) {
}
if (mount(template, directory, NULL, MS_MOVE, NULL) < 0) {
- log_error("Failed to move root mount: %m");
+ log_error_errno(errno, "Failed to move root mount: %m");
r = -errno;
goto fail;
}
@@ -1075,10 +1075,10 @@ static int setup_boot_id(const char *dest) {
return log_error_errno(r, "Failed to write boot id: %m");
if (mount(from, to, "bind", MS_BIND, NULL) < 0) {
- log_error("Failed to bind mount boot id: %m");
+ log_error_errno(errno, "Failed to bind mount boot id: %m");
r = -errno;
} else if (mount(from, to, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL))
- log_warning("Failed to make boot id read-only: %m");
+ log_warning_errno(errno, "Failed to make boot id read-only: %m");
unlink(from);
return r;
@@ -1115,7 +1115,7 @@ static int copy_devnodes(const char *dest) {
if (stat(from, &st) < 0) {
if (errno != ENOENT) {
- log_error("Failed to stat %s: %m", from);
+ log_error_errno(errno, "Failed to stat %s: %m", from);
return -errno;
}
@@ -1132,7 +1132,7 @@ static int copy_devnodes(const char *dest) {
}
if (mknod(to, st.st_mode, st.st_rdev) < 0) {
- log_error("mknod(%s) failed: %m", dest);
+ log_error_errno(errno, "mknod(%s) failed: %m", dest);
return -errno;
}
}
@@ -1149,7 +1149,7 @@ static int setup_ptmx(const char *dest) {
return log_oom();
if (symlink("pts/ptmx", p) < 0) {
- log_error("Failed to create /dev/ptmx symlink: %m");
+ log_error_errno(errno, "Failed to create /dev/ptmx symlink: %m");
return -errno;
}
@@ -1168,7 +1168,7 @@ static int setup_dev_console(const char *dest, const char *console) {
u = umask(0000);
if (stat("/dev/null", &st) < 0) {
- log_error("Failed to stat /dev/null: %m");
+ log_error_errno(errno, "Failed to stat /dev/null: %m");
return -errno;
}
@@ -1186,12 +1186,12 @@ static int setup_dev_console(const char *dest, const char *console) {
to = strappenda(dest, "/dev/console");
if (mknod(to, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0) {
- log_error("mknod() for /dev/console failed: %m");
+ log_error_errno(errno, "mknod() for /dev/console failed: %m");
return -errno;
}
if (mount(console, to, "bind", MS_BIND, NULL) < 0) {
- log_error("Bind mount for /dev/console failed: %m");
+ log_error_errno(errno, "Bind mount for /dev/console failed: %m");
return -errno;
}
@@ -1229,7 +1229,7 @@ static int setup_kmsg(const char *dest, int kmsg_socket) {
return log_oom();
if (mkfifo(from, 0600) < 0) {
- log_error("mkfifo() for /dev/kmsg failed: %m");
+ log_error_errno(errno, "mkfifo() for /dev/kmsg failed: %m");
return -errno;
}
@@ -1238,13 +1238,13 @@ static int setup_kmsg(const char *dest, int kmsg_socket) {
return log_error_errno(r, "Failed to correct access mode for /dev/kmsg: %m");
if (mount(from, to, "bind", MS_BIND, NULL) < 0) {
- log_error("Bind mount for /proc/kmsg failed: %m");
+ log_error_errno(errno, "Bind mount for /proc/kmsg failed: %m");
return -errno;
}
fd = open(from, O_RDWR|O_NDELAY|O_CLOEXEC);
if (fd < 0) {
- log_error("Failed to open fifo: %m");
+ log_error_errno(errno, "Failed to open fifo: %m");
return -errno;
}
@@ -1262,7 +1262,7 @@ static int setup_kmsg(const char *dest, int kmsg_socket) {
safe_close(fd);
if (k < 0) {
- log_error("Failed to send FIFO fd: %m");
+ log_error_errno(errno, "Failed to send FIFO fd: %m");
return -errno;
}
@@ -1355,12 +1355,12 @@ static int setup_journal(const char *directory) {
r = mkdir_p(q, 0755);
if (r < 0)
- log_warning("Failed to create directory %s: %m", q);
+ log_warning_errno(errno, "Failed to create directory %s: %m", q);
return 0;
}
if (unlink(p) < 0) {
- log_error("Failed to remove symlink %s: %m", p);
+ log_error_errno(errno, "Failed to remove symlink %s: %m", p);
return -errno;
}
} else if (r == -EINVAL) {
@@ -1372,12 +1372,12 @@ static int setup_journal(const char *directory) {
log_error("%s already exists and is neither a symlink nor a directory", p);
return r;
} else {
- log_error("Failed to remove %s: %m", p);
+ log_error_errno(errno, "Failed to remove %s: %m", p);
return -errno;
}
}
} else if (r != -ENOENT) {
- log_error("readlink(%s) failed: %m", p);
+ log_error_errno(errno, "readlink(%s) failed: %m", p);
return r;
}
@@ -1385,17 +1385,17 @@ static int setup_journal(const char *directory) {
if (symlink(q, p) < 0) {
if (arg_link_journal_try) {
- log_debug("Failed to symlink %s to %s, skipping journal setup: %m", q, p);
+ log_debug_errno(errno, "Failed to symlink %s to %s, skipping journal setup: %m", q, p);
return 0;
} else {
- log_error("Failed to symlink %s to %s: %m", q, p);
+ log_error_errno(errno, "Failed to symlink %s to %s: %m", q, p);
return -errno;
}
}
r = mkdir_p(q, 0755);
if (r < 0)
- log_warning("Failed to create directory %s: %m", q);
+ log_warning_errno(errno, "Failed to create directory %s: %m", q);
return 0;
}
@@ -1405,10 +1405,10 @@ static int setup_journal(const char *directory) {
r = mkdir(p, 0755);
if (r < 0) {
if (arg_link_journal_try) {
- log_debug("Failed to create %s, skipping journal setup: %m", p);
+ log_debug_errno(errno, "Failed to create %s, skipping journal setup: %m", p);
return 0;
} else {
- log_error("Failed to create %s: %m", p);
+ log_error_errno(errno, "Failed to create %s: %m", p);
return r;
}
}
@@ -1421,12 +1421,12 @@ static int setup_journal(const char *directory) {
r = mkdir_p(q, 0755);
if (r < 0) {
- log_error("Failed to create %s: %m", q);
+ log_error_errno(errno, "Failed to create %s: %m", q);
return r;
}
if (mount(p, q, "bind", MS_BIND, NULL) < 0) {
- log_error("Failed to bind mount journal from host into guest: %m");
+ log_error_errno(errno, "Failed to bind mount journal from host into guest: %m");
return -errno;
}
@@ -1753,7 +1753,7 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) {
i = (int) if_nametoindex(iface_name);
if (i <= 0) {
- log_error("Failed to resolve interface %s: %m", iface_name);
+ log_error_errno(errno, "Failed to resolve interface %s: %m", iface_name);
return -errno;
}
@@ -1778,7 +1778,7 @@ static int setup_bridge(const char veth_name[], int *ifi) {
bridge = (int) if_nametoindex(arg_network_bridge);
if (bridge <= 0) {
- log_error("Failed to resolve interface %s: %m", arg_network_bridge);
+ log_error_errno(errno, "Failed to resolve interface %s: %m", arg_network_bridge);
return -errno;
}
@@ -1818,14 +1818,14 @@ static int parse_interface(struct udev *udev, const char *name) {
ifi = (int) if_nametoindex(name);
if (ifi <= 0) {
- log_error("Failed to resolve interface %s: %m", name);
+ log_error_errno(errno, "Failed to resolve interface %s: %m", name);
return -errno;
}
sprintf(ifi_str, "n%i", ifi);
d = udev_device_new_from_device_id(udev, ifi_str);
if (!d) {
- log_error("Failed to get udev device for interface %s: %m", name);
+ log_error_errno(errno, "Failed to get udev device for interface %s: %m", name);
return -errno;
}
@@ -2058,12 +2058,12 @@ static int setup_image(char **device_path, int *loop_nr) {
fd = open(arg_image, O_CLOEXEC|(arg_read_only ? O_RDONLY : O_RDWR)|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
- log_error("Failed to open %s: %m", arg_image);
+ log_error_errno(errno, "Failed to open %s: %m", arg_image);
return -errno;
}
if (fstat(fd, &st) < 0) {
- log_error("Failed to stat %s: %m", arg_image);
+ log_error_errno(errno, "Failed to stat %s: %m", arg_image);
return -errno;
}
@@ -2085,19 +2085,19 @@ static int setup_image(char **device_path, int *loop_nr) {
}
if (!S_ISREG(st.st_mode)) {
- log_error("%s is not a regular file or block device: %m", arg_image);
+ log_error_errno(errno, "%s is not a regular file or block device: %m", arg_image);
return -EINVAL;
}
control = open("/dev/loop-control", O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (control < 0) {
- log_error("Failed to open /dev/loop-control: %m");
+ log_error_errno(errno, "Failed to open /dev/loop-control: %m");
return -errno;
}
nr = ioctl(control, LOOP_CTL_GET_FREE);
if (nr < 0) {
- log_error("Failed to allocate loop device: %m");
+ log_error_errno(errno, "Failed to allocate loop device: %m");
return -errno;
}
@@ -2106,12 +2106,12 @@ static int setup_image(char **device_path, int *loop_nr) {
loop = open(loopdev, O_CLOEXEC|(arg_read_only ? O_RDONLY : O_RDWR)|O_NONBLOCK|O_NOCTTY);
if (loop < 0) {
- log_error("Failed to open loop device %s: %m", loopdev);
+ log_error_errno(errno, "Failed to open loop device %s: %m", loopdev);
return -errno;
}
if (ioctl(loop, LOOP_SET_FD, fd) < 0) {
- log_error("Failed to set loopback file descriptor on %s: %m", loopdev);
+ log_error_errno(errno, "Failed to set loopback file descriptor on %s: %m", loopdev);
return -errno;
}
@@ -2119,7 +2119,7 @@ static int setup_image(char **device_path, int *loop_nr) {
info.lo_flags |= LO_FLAGS_READ_ONLY;
if (ioctl(loop, LOOP_SET_STATUS64, &info) < 0) {
- log_error("Failed to set loopback settings on %s: %m", loopdev);
+ log_error_errno(errno, "Failed to set loopback settings on %s: %m", loopdev);
return -errno;
}
@@ -2171,7 +2171,7 @@ static int dissect_image(
if (errno == 0)
return log_oom();
- log_error("Failed to set device on blkid probe: %m");
+ log_error_errno(errno, "Failed to set device on blkid probe: %m");
return -errno;
}
@@ -2187,7 +2187,7 @@ static int dissect_image(
} else if (r != 0) {
if (errno == 0)
errno = EIO;
- log_error("Failed to probe: %m");
+ log_error_errno(errno, "Failed to probe: %m");
return -errno;
}
@@ -2213,7 +2213,7 @@ static int dissect_image(
return log_oom();
if (fstat(fd, &st) < 0) {
- log_error("Failed to stat block device: %m");
+ log_error_errno(errno, "Failed to stat block device: %m");
return -errno;
}
@@ -2249,7 +2249,7 @@ static int dissect_image(
if (!errno)
errno = ENOMEM;
- log_error("Failed to get partition device of %s: %m", arg_image);
+ log_error_errno(errno, "Failed to get partition device of %s: %m", arg_image);
return -errno;
}
@@ -2404,7 +2404,7 @@ static int mount_device(const char *what, const char *where, const char *directo
if (!b) {
if (errno == 0)
return log_oom();
- log_error("Failed to allocate prober for %s: %m", what);
+ log_error_errno(errno, "Failed to allocate prober for %s: %m", what);
return -errno;
}
@@ -2419,7 +2419,7 @@ static int mount_device(const char *what, const char *where, const char *directo
} else if (r != 0) {
if (errno == 0)
errno = EIO;
- log_error("Failed to probe %s: %m", what);
+ log_error_errno(errno, "Failed to probe %s: %m", what);
return -errno;
}
@@ -2437,7 +2437,7 @@ static int mount_device(const char *what, const char *where, const char *directo
}
if (mount(what, p, fstype, MS_NODEV|(rw ? 0 : MS_RDONLY), NULL) < 0) {
- log_error("Failed to mount %s: %m", what);
+ log_error_errno(errno, "Failed to mount %s: %m", what);
return -errno;
}
@@ -2488,19 +2488,19 @@ static void loop_remove(int nr, int *image_fd) {
if (image_fd && *image_fd >= 0) {
r = ioctl(*image_fd, LOOP_CLR_FD);
if (r < 0)
- log_warning("Failed to close loop image: %m");
+ log_warning_errno(errno, "Failed to close loop image: %m");
*image_fd = safe_close(*image_fd);
}
control = open("/dev/loop-control", O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (control < 0) {
- log_warning("Failed to open /dev/loop-control: %m");
+ log_warning_errno(errno, "Failed to open /dev/loop-control: %m");
return;
}
r = ioctl(control, LOOP_CTL_REMOVE, nr);
if (r < 0)
- log_warning("Failed to remove loop %d: %m", nr);
+ log_warning_errno(errno, "Failed to remove loop %d: %m", nr);
}
static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
@@ -2512,13 +2512,13 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
assert(rpid);
if (pipe2(pipe_fds, O_CLOEXEC) < 0) {
- log_error("Failed to allocate pipe: %m");
+ log_error_errno(errno, "Failed to allocate pipe: %m");
return -errno;
}
pid = fork();
if (pid < 0) {
- log_error("Failed to fork getent child: %m");
+ log_error_errno(errno, "Failed to fork getent child: %m");
return -errno;
} else if (pid == 0) {
int nullfd;
@@ -2580,17 +2580,17 @@ static int change_uid_gid(char **_home) {
/* Reset everything fully to 0, just in case */
if (setgroups(0, NULL) < 0) {
- log_error("setgroups() failed: %m");
+ log_error_errno(errno, "setgroups() failed: %m");
return -errno;
}
if (setresgid(0, 0, 0) < 0) {
- log_error("setregid() failed: %m");
+ log_error_errno(errno, "setregid() failed: %m");
return -errno;
}
if (setresuid(0, 0, 0) < 0) {
- log_error("setreuid() failed: %m");
+ log_error_errno(errno, "setreuid() failed: %m");
return -errno;
}
@@ -2615,7 +2615,7 @@ static int change_uid_gid(char **_home) {
return -ESRCH;
}
- log_error("Failed to read from getent: %m");
+ log_error_errno(errno, "Failed to read from getent: %m");
return -errno;
}
@@ -2699,7 +2699,7 @@ static int change_uid_gid(char **_home) {
return -ESRCH;
}
- log_error("Failed to read from getent: %m");
+ log_error_errno(errno, "Failed to read from getent: %m");
return -errno;
}
@@ -2741,17 +2741,17 @@ static int change_uid_gid(char **_home) {
fchown(STDERR_FILENO, uid, gid);
if (setgroups(n_uids, uids) < 0) {
- log_error("Failed to set auxiliary groups: %m");
+ log_error_errno(errno, "Failed to set auxiliary groups: %m");
return -errno;
}
if (setresgid(gid, gid, gid) < 0) {
- log_error("setregid() failed: %m");
+ log_error_errno(errno, "setregid() failed: %m");
return -errno;
}
if (setresuid(uid, uid, uid) < 0) {
- log_error("setreuid() failed: %m");
+ log_error_errno(errno, "setreuid() failed: %m");
return -errno;
}
@@ -2950,7 +2950,7 @@ int main(int argc, char *argv[]) {
char template[] = "/tmp/nspawn-root-XXXXXX";
if (!mkdtemp(template)) {
- log_error("Failed to create temporary directory: %m");
+ log_error_errno(errno, "Failed to create temporary directory: %m");
r = -errno;
goto finish;
}
@@ -2978,13 +2978,13 @@ int main(int argc, char *argv[]) {
master = posix_openpt(O_RDWR|O_NOCTTY|O_CLOEXEC|O_NDELAY);
if (master < 0) {
- log_error("Failed to acquire pseudo tty: %m");
+ log_error_errno(errno, "Failed to acquire pseudo tty: %m");
goto finish;
}
console = ptsname(master);
if (!console) {
- log_error("Failed to determine tty name: %m");
+ log_error_errno(errno, "Failed to determine tty name: %m");
goto finish;
}
@@ -2993,12 +2993,12 @@ int main(int argc, char *argv[]) {
arg_machine, arg_image ? arg_image : arg_directory);
if (unlockpt(master) < 0) {
- log_error("Failed to unlock tty: %m");
+ log_error_errno(errno, "Failed to unlock tty: %m");
goto finish;
}
if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, kmsg_socket_pair) < 0) {
- log_error("Failed to create kmsg socket pair: %m");
+ log_error_errno(errno, "Failed to create kmsg socket pair: %m");
goto finish;
}
@@ -3032,13 +3032,13 @@ int main(int argc, char *argv[]) {
* give it a chance to call wait() and terminate. */
r = sigprocmask(SIG_UNBLOCK, &mask_chld, NULL);
if (r < 0) {
- log_error("Failed to change the signal mask: %m");
+ log_error_errno(errno, "Failed to change the signal mask: %m");
goto finish;
}
r = sigaction(SIGCHLD, &sa, NULL);
if (r < 0) {
- log_error("Failed to install SIGCHLD handler: %m");
+ log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
goto finish;
}
@@ -3047,9 +3047,9 @@ int main(int argc, char *argv[]) {
(arg_private_network ? CLONE_NEWNET : 0), NULL);
if (pid < 0) {
if (errno == EINVAL)
- log_error("clone() failed, do you have namespace support enabled in your kernel? (You need UTS, IPC, PID and NET namespacing built in): %m");
+ log_error_errno(errno, "clone() failed, do you have namespace support enabled in your kernel? (You need UTS, IPC, PID and NET namespacing built in): %m");
else
- log_error("clone() failed: %m");
+ log_error_errno(errno, "clone() failed: %m");
r = pid;
goto finish;
@@ -3103,12 +3103,12 @@ int main(int argc, char *argv[]) {
if (dup2(STDIN_FILENO, STDOUT_FILENO) != STDOUT_FILENO ||
dup2(STDIN_FILENO, STDERR_FILENO) != STDERR_FILENO) {
- log_error("Failed to duplicate console: %m");
+ log_error_errno(errno, "Failed to duplicate console: %m");
_exit(EXIT_FAILURE);
}
if (setsid() < 0) {
- log_error("setsid() failed: %m");
+ log_error_errno(errno, "setsid() failed: %m");
_exit(EXIT_FAILURE);
}
@@ -3116,7 +3116,7 @@ int main(int argc, char *argv[]) {
_exit(EXIT_FAILURE);
if (prctl(PR_SET_PDEATHSIG, SIGKILL) < 0) {
- log_error("PR_SET_PDEATHSIG failed: %m");
+ log_error_errno(errno, "PR_SET_PDEATHSIG failed: %m");
_exit(EXIT_FAILURE);
}
@@ -3124,7 +3124,7 @@ int main(int argc, char *argv[]) {
* receive mounts from the real root, but don't
* propagate mounts to the real root. */
if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) {
- log_error("MS_SLAVE|MS_REC failed: %m");
+ log_error_errno(errno, "MS_SLAVE|MS_REC failed: %m");
_exit(EXIT_FAILURE);
}
@@ -3136,7 +3136,7 @@ int main(int argc, char *argv[]) {
/* Turn directory into bind mount */
if (mount(arg_directory, arg_directory, "bind", MS_BIND|MS_REC, NULL) < 0) {
- log_error("Failed to make bind mount: %m");
+ log_error_errno(errno, "Failed to make bind mount: %m");
_exit(EXIT_FAILURE);
}
@@ -3208,22 +3208,22 @@ int main(int argc, char *argv[]) {
(void)barrier_place(&barrier);
if (chdir(arg_directory) < 0) {
- log_error("chdir(%s) failed: %m", arg_directory);
+ log_error_errno(errno, "chdir(%s) failed: %m", arg_directory);
_exit(EXIT_FAILURE);
}
if (mount(arg_directory, "/", NULL, MS_MOVE, NULL) < 0) {
- log_error("mount(MS_MOVE) failed: %m");
+ log_error_errno(errno, "mount(MS_MOVE) failed: %m");
_exit(EXIT_FAILURE);
}
if (chroot(".") < 0) {
- log_error("chroot() failed: %m");
+ log_error_errno(errno, "chroot() failed: %m");
_exit(EXIT_FAILURE);
}
if (chdir("/") < 0) {
- log_error("chdir() failed: %m");
+ log_error_errno(errno, "chdir() failed: %m");
_exit(EXIT_FAILURE);
}
@@ -3233,7 +3233,7 @@ int main(int argc, char *argv[]) {
loopback_setup();
if (drop_capabilities() < 0) {
- log_error("drop_capabilities() failed: %m");
+ log_error_errno(errno, "drop_capabilities() failed: %m");
_exit(EXIT_FAILURE);
}
@@ -3275,12 +3275,12 @@ int main(int argc, char *argv[]) {
if (arg_personality != 0xffffffffLU) {
if (personality(arg_personality) < 0) {
- log_error("personality() failed: %m");
+ log_error_errno(errno, "personality() failed: %m");
_exit(EXIT_FAILURE);
}
} else if (secondary) {
if (personality(PER_LINUX32) < 0) {
- log_error("personality() failed: %m");
+ log_error_errno(errno, "personality() failed: %m");
_exit(EXIT_FAILURE);
}
}
@@ -3288,7 +3288,7 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_SELINUX
if (arg_selinux_context)
if (setexeccon((security_context_t) arg_selinux_context) < 0) {
- log_error("setexeccon(\"%s\") failed: %m", arg_selinux_context);
+ log_error_errno(errno, "setexeccon(\"%s\") failed: %m", arg_selinux_context);
_exit(EXIT_FAILURE);
}
#endif
@@ -3336,7 +3336,7 @@ int main(int argc, char *argv[]) {
execle("/bin/sh", "-sh", NULL, env_use);
}
- log_error("execv() failed: %m");
+ log_error_errno(errno, "execv() failed: %m");
_exit(EXIT_FAILURE);
}
diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c
index ebbd632794..bf79d1dbaa 100644
--- a/src/quotacheck/quotacheck.c
+++ b/src/quotacheck/quotacheck.c
@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) {
pid = fork();
if (pid < 0) {
- log_error("fork(): %m");
+ log_error_errno(errno, "fork(): %m");
return EXIT_FAILURE;
} else if (pid == 0) {
/* Child */
diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c
index 7714bcef9f..40eaaf46d9 100644
--- a/src/random-seed/random-seed.c
+++ b/src/random-seed/random-seed.c
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
if (seed_fd < 0) {
seed_fd = open(RANDOM_SEED, O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (seed_fd < 0) {
- log_error("Failed to open " RANDOM_SEED ": %m");
+ log_error_errno(errno, "Failed to open " RANDOM_SEED ": %m");
r = -errno;
goto finish;
}
@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {
if (random_fd < 0) {
random_fd = open("/dev/urandom", O_WRONLY|O_CLOEXEC|O_NOCTTY, 0600);
if (random_fd < 0) {
- log_error("Failed to open /dev/urandom: %m");
+ log_error_errno(errno, "Failed to open /dev/urandom: %m");
r = -errno;
goto finish;
}
@@ -106,7 +106,7 @@ int main(int argc, char *argv[]) {
if (k <= 0) {
if (r != 0)
- log_error("Failed to read seed from " RANDOM_SEED ": %m");
+ log_error_errno(errno, "Failed to read seed from " RANDOM_SEED ": %m");
r = k == 0 ? -EIO : (int) k;
@@ -125,14 +125,14 @@ int main(int argc, char *argv[]) {
seed_fd = open(RANDOM_SEED, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT, 0600);
if (seed_fd < 0) {
- log_error("Failed to open " RANDOM_SEED ": %m");
+ log_error_errno(errno, "Failed to open " RANDOM_SEED ": %m");
r = -errno;
goto finish;
}
random_fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (random_fd < 0) {
- log_error("Failed to open /dev/urandom: %m");
+ log_error_errno(errno, "Failed to open /dev/urandom: %m");
r = -errno;
goto finish;
}
diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c
index 01ff4702a7..d4e6ba4bf9 100644
--- a/src/rc-local-generator/rc-local-generator.c
+++ b/src/rc-local-generator/rc-local-generator.c
@@ -60,7 +60,7 @@ static int add_symlink(const char *service, const char *where) {
if (errno == EEXIST)
return 0;
- log_error("Failed to create symlink %s: %m", to);
+ log_error_errno(errno, "Failed to create symlink %s: %m", to);
return -errno;
}
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
index 2969404185..57b47021e4 100644
--- a/src/remount-fs/remount-fs.c
+++ b/src/remount-fs/remount-fs.c
@@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {
if (errno == ENOENT)
return EXIT_SUCCESS;
- log_error("Failed to open /etc/fstab: %m");
+ log_error_errno(errno, "Failed to open /etc/fstab: %m");
return EXIT_FAILURE;
}
@@ -87,7 +87,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");
ret = EXIT_FAILURE;
continue;
}
@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
execv("/bin/mount", (char **) arguments);
- log_error("Failed to execute /bin/mount: %m");
+ log_error_errno(errno, "Failed to execute /bin/mount: %m");
_exit(EXIT_FAILURE);
}
@@ -135,7 +135,7 @@ int main(int argc, char *argv[]) {
if (errno == EINTR)
continue;
- log_error("waitid() failed: %m");
+ log_error_errno(errno, "waitid() failed: %m");
ret = EXIT_FAILURE;
break;
}
diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c
index 73c2d1bbdf..54528d67ab 100644
--- a/src/reply-password/reply-password.c
+++ b/src/reply-password/reply-password.c
@@ -52,7 +52,7 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s
strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0) {
- log_error("Failed to send: %m");
+ log_error_errno(errno, "Failed to send: %m");
return -errno;
}
@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) {
packet[0] = '+';
if (!fgets(packet+1, sizeof(packet)-1, stdin)) {
- log_error("Failed to read password: %m");
+ log_error_errno(errno, "Failed to read password: %m");
goto finish;
}
@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) {
fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (fd < 0) {
- log_error("socket() failed: %m");
+ log_error_errno(errno, "socket() failed: %m");
goto finish;
}
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 457b3e2d31..a3c7f96c9e 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -514,7 +514,7 @@ static int parse_argv(int argc, char *argv[]) {
case 'i':
arg_ifindex = if_nametoindex(optarg);
if (arg_ifindex <= 0) {
- log_error("Unknown interfaces %s: %m", optarg);
+ log_error_errno(errno, "Unknown interfaces %s: %m", optarg);
return -errno;
}
break;
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
index 3690679ec6..4c0b557bad 100644
--- a/src/resolve/resolved-dns-stream.c
+++ b/src/resolve/resolved-dns-stream.c
@@ -172,11 +172,11 @@ static int dns_stream_identify(DnsStream *s) {
if (s->local.sa.sa_family == AF_INET) {
r = setsockopt(s->fd, IPPROTO_IP, IP_UNICAST_IF, &ifindex, sizeof(ifindex));
if (r < 0)
- log_debug("Failed to invoke IP_UNICAST_IF: %m");
+ log_debug_errno(errno, "Failed to invoke IP_UNICAST_IF: %m");
} else if (s->local.sa.sa_family == AF_INET6) {
r = setsockopt(s->fd, IPPROTO_IPV6, IPV6_UNICAST_IF, &ifindex, sizeof(ifindex));
if (r < 0)
- log_debug("Failed to invoke IPV6_UNICAST_IF: %m");
+ log_debug_errno(errno, "Failed to invoke IPV6_UNICAST_IF: %m");
}
}
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 661f8fc738..0594479787 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -370,7 +370,7 @@ static int manager_watch_hostname(Manager *m) {
m->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
if (m->hostname_fd < 0) {
- log_warning("Failed to watch hostname: %m");
+ log_warning_errno(errno, "Failed to watch hostname: %m");
return 0;
}
@@ -591,7 +591,7 @@ int manager_read_resolv_conf(Manager *m) {
r = stat("/etc/resolv.conf", &st);
if (r < 0) {
if (errno != ENOENT)
- log_warning("Failed to open /etc/resolv.conf: %m");
+ log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
r = -errno;
goto clear;
}
@@ -614,13 +614,13 @@ int manager_read_resolv_conf(Manager *m) {
f = fopen("/etc/resolv.conf", "re");
if (!f) {
if (errno != ENOENT)
- log_warning("Failed to open /etc/resolv.conf: %m");
+ log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
r = -errno;
goto clear;
}
if (fstat(fileno(f), &st) < 0) {
- log_error("Failed to stat open file: %m");
+ log_error_errno(errno, "Failed to stat open file: %m");
r = -errno;
goto clear;
}
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index c75d6a60d8..68729b0c04 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
device = udev_device_new_from_subsystem_sysname(udev, "rfkill", argv[2]);
if (!device) {
if (errno != 0)
- log_error("Failed to get rfkill device '%s': %m", argv[2]);
+ log_error_errno(errno, "Failed to get rfkill device '%s': %m", argv[2]);
else
log_oom();
diff --git a/src/run/run.c b/src/run/run.c
index b96517a99a..d61f8db350 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -489,7 +489,7 @@ static int start_transient_scope(
if (arg_nice_set) {
if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0) {
- log_error("Failed to set nice level: %m");
+ log_error_errno(errno, "Failed to set nice level: %m");
return -errno;
}
}
@@ -502,7 +502,7 @@ static int start_transient_scope(
return log_error_errno(r, "Failed to resolve group %s: %m", arg_exec_group);
if (setresgid(gid, gid, gid) < 0) {
- log_error("Failed to change GID to " GID_FMT ": %m", gid);
+ log_error_errno(errno, "Failed to change GID to " GID_FMT ": %m", gid);
return -errno;
}
}
@@ -534,13 +534,13 @@ static int start_transient_scope(
if (!arg_exec_group) {
if (setresgid(gid, gid, gid) < 0) {
- log_error("Failed to change GID to " GID_FMT ": %m", gid);
+ log_error_errno(errno, "Failed to change GID to " GID_FMT ": %m", gid);
return -errno;
}
}
if (setresuid(uid, uid, uid) < 0) {
- log_error("Failed to change UID to " UID_FMT ": %m", uid);
+ log_error_errno(errno, "Failed to change UID to " UID_FMT ": %m", uid);
return -errno;
}
}
@@ -552,7 +552,7 @@ static int start_transient_scope(
log_info("Running as unit %s.", name);
execvpe(argv[0], argv, env);
- log_error("Failed to execute: %m");
+ log_error_errno(errno, "Failed to execute: %m");
return -errno;
}
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 94a27f9010..41049d79bd 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -259,7 +259,7 @@ static int create_socket(char **name) {
fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (fd < 0) {
- log_error("socket() failed: %m");
+ log_error_errno(errno, "socket() failed: %m");
return -errno;
}
@@ -271,13 +271,13 @@ static int create_socket(char **name) {
if (r < 0) {
r = -errno;
- log_error("bind(%s) failed: %m", sa.un.sun_path);
+ log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
goto fail;
}
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0) {
r = -errno;
- log_error("SO_PASSCRED failed: %m");
+ log_error_errno(errno, "SO_PASSCRED failed: %m");
goto fail;
}
@@ -330,7 +330,7 @@ int ask_password_agent(
fd = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
if (fd < 0) {
- log_error("Failed to create password file: %m");
+ log_error_errno(errno, "Failed to create password file: %m");
r = -errno;
goto finish;
}
@@ -339,7 +339,7 @@ int ask_password_agent(
f = fdopen(fd, "w");
if (!f) {
- log_error("Failed to allocate FILE: %m");
+ log_error_errno(errno, "Failed to allocate FILE: %m");
r = -errno;
goto finish;
}
@@ -348,7 +348,7 @@ int ask_password_agent(
signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
if (signal_fd < 0) {
- log_error("signalfd(): %m");
+ log_error_errno(errno, "signalfd(): %m");
r = -errno;
goto finish;
}
@@ -384,7 +384,7 @@ int ask_password_agent(
fflush(f);
if (ferror(f)) {
- log_error("Failed to write query file: %m");
+ log_error_errno(errno, "Failed to write query file: %m");
r = -errno;
goto finish;
}
@@ -396,7 +396,7 @@ int ask_password_agent(
final[sizeof(final)-9] = 'k';
if (rename(temp, final) < 0) {
- log_error("Failed to rename query file: %m");
+ log_error_errno(errno, "Failed to rename query file: %m");
r = -errno;
goto finish;
}
@@ -433,7 +433,7 @@ int ask_password_agent(
if (errno == EINTR)
continue;
- log_error("poll() failed: %m");
+ log_error_errno(errno, "poll() failed: %m");
r = -errno;
goto finish;
}
@@ -472,7 +472,7 @@ int ask_password_agent(
errno == EINTR)
continue;
- log_error("recvmsg() failed: %m");
+ log_error_errno(errno, "recvmsg() failed: %m");
r = -errno;
goto finish;
}
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index 4c65a495d3..b1f1f4190e 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -59,7 +59,7 @@ int base_filesystem_create(const char *root) {
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
if (fd < 0) {
- log_error("Failed to open root file system: %m");
+ log_error_errno(errno, "Failed to open root file system: %m");
return -errno;
}
@@ -96,7 +96,7 @@ int base_filesystem_create(const char *root) {
r = symlinkat(target, fd, table[i].dir);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create symlink at %s/%s: %m", root, table[i].dir);
+ log_error_errno(errno, "Failed to create symlink at %s/%s: %m", root, table[i].dir);
return -errno;
}
continue;
@@ -105,7 +105,7 @@ int base_filesystem_create(const char *root) {
RUN_WITH_UMASK(0000)
r = mkdirat(fd, table[i].dir, table[i].mode);
if (r < 0 && errno != EEXIST) {
- log_error("Failed to create directory at %s/%s: %m", root, table[i].dir);
+ log_error_errno(errno, "Failed to create directory at %s/%s: %m", root, table[i].dir);
return -errno;
}
}
diff --git a/src/shared/capability.c b/src/shared/capability.c
index b7e055318a..e2e0dd1a33 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -228,28 +228,28 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
* which we want to avoid. */
if (setresgid(gid, gid, gid) < 0) {
- log_error("Failed to change group ID: %m");
+ log_error_errno(errno, "Failed to change group ID: %m");
return -errno;
}
if (setgroups(0, NULL) < 0) {
- log_error("Failed to drop auxiliary groups list: %m");
+ log_error_errno(errno, "Failed to drop auxiliary groups list: %m");
return -errno;
}
if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
- log_error("Failed to enable keep capabilities flag: %m");
+ log_error_errno(errno, "Failed to enable keep capabilities flag: %m");
return -errno;
}
r = setresuid(uid, uid, uid);
if (r < 0) {
- log_error("Failed to change user ID: %m");
+ log_error_errno(errno, "Failed to change user ID: %m");
return -errno;
}
if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
- log_error("Failed to disable keep capabilities flag: %m");
+ log_error_errno(errno, "Failed to disable keep capabilities flag: %m");
return -errno;
}
@@ -271,13 +271,13 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
if (cap_set_flag(d, CAP_EFFECTIVE, j, bits, CAP_SET) < 0 ||
cap_set_flag(d, CAP_PERMITTED, j, bits, CAP_SET) < 0) {
- log_error("Failed to enable capabilities bits: %m");
+ log_error_errno(errno, "Failed to enable capabilities bits: %m");
return -errno;
}
}
if (cap_set_proc(d) < 0) {
- log_error("Failed to increase capabilities: %m");
+ log_error_errno(errno, "Failed to increase capabilities: %m");
return -errno;
}
diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c
index cb1722614e..39ab645133 100644
--- a/src/shared/clean-ipc.c
+++ b/src/shared/clean-ipc.c
@@ -44,7 +44,7 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
if (errno == ENOENT)
return 0;
- log_warning("Failed to open /proc/sysvipc/shm: %m");
+ log_warning_errno(errno, "Failed to open /proc/sysvipc/shm: %m");
return -errno;
}
@@ -78,7 +78,7 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
if (errno == EIDRM || errno == EINVAL)
continue;
- log_warning("Failed to remove SysV shared memory segment %i: %m", shmid);
+ log_warning_errno(errno, "Failed to remove SysV shared memory segment %i: %m", shmid);
ret = -errno;
}
}
@@ -86,7 +86,7 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
return ret;
fail:
- log_warning("Failed to read /proc/sysvipc/shm: %m");
+ log_warning_errno(errno, "Failed to read /proc/sysvipc/shm: %m");
return -errno;
}
@@ -101,7 +101,7 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
if (errno == ENOENT)
return 0;
- log_warning("Failed to open /proc/sysvipc/sem: %m");
+ log_warning_errno(errno, "Failed to open /proc/sysvipc/sem: %m");
return -errno;
}
@@ -130,7 +130,7 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
if (errno == EIDRM || errno == EINVAL)
continue;
- log_warning("Failed to remove SysV semaphores object %i: %m", semid);
+ log_warning_errno(errno, "Failed to remove SysV semaphores object %i: %m", semid);
ret = -errno;
}
}
@@ -138,7 +138,7 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
return ret;
fail:
- log_warning("Failed to read /proc/sysvipc/sem: %m");
+ log_warning_errno(errno, "Failed to read /proc/sysvipc/sem: %m");
return -errno;
}
@@ -153,7 +153,7 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
if (errno == ENOENT)
return 0;
- log_warning("Failed to open /proc/sysvipc/msg: %m");
+ log_warning_errno(errno, "Failed to open /proc/sysvipc/msg: %m");
return -errno;
}
@@ -183,7 +183,7 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
if (errno == EIDRM || errno == EINVAL)
continue;
- log_warning("Failed to remove SysV message queue %i: %m", msgid);
+ log_warning_errno(errno, "Failed to remove SysV message queue %i: %m", msgid);
ret = -errno;
}
}
@@ -191,7 +191,7 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
return ret;
fail:
- log_warning("Failed to read /proc/sysvipc/msg: %m");
+ log_warning_errno(errno, "Failed to read /proc/sysvipc/msg: %m");
return -errno;
}
@@ -211,7 +211,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning("Failed to stat() POSIX shared memory segment %s: %m", de->d_name);
+ log_warning_errno(errno, "Failed to stat() POSIX shared memory segment %s: %m", de->d_name);
ret = -errno;
continue;
}
@@ -225,7 +225,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
kid = xopendirat(dirfd(dir), de->d_name, O_NOFOLLOW|O_NOATIME);
if (!kid) {
if (errno != ENOENT) {
- log_warning("Failed to enter shared memory directory %s: %m", de->d_name);
+ log_warning_errno(errno, "Failed to enter shared memory directory %s: %m", de->d_name);
ret = -errno;
}
} else {
@@ -239,7 +239,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning("Failed to remove POSIX shared memory directory %s: %m", de->d_name);
+ log_warning_errno(errno, "Failed to remove POSIX shared memory directory %s: %m", de->d_name);
ret = -errno;
}
} else {
@@ -249,7 +249,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning("Failed to remove POSIX shared memory segment %s: %m", de->d_name);
+ log_warning_errno(errno, "Failed to remove POSIX shared memory segment %s: %m", de->d_name);
ret = -errno;
}
}
@@ -258,7 +258,7 @@ static int clean_posix_shm_internal(DIR *dir, uid_t uid) {
return ret;
fail:
- log_warning("Failed to read /dev/shm: %m");
+ log_warning_errno(errno, "Failed to read /dev/shm: %m");
return -errno;
}
@@ -270,7 +270,7 @@ static int clean_posix_shm(uid_t uid) {
if (errno == ENOENT)
return 0;
- log_warning("Failed to open /dev/shm: %m");
+ log_warning_errno(errno, "Failed to open /dev/shm: %m");
return -errno;
}
@@ -287,7 +287,7 @@ static int clean_posix_mq(uid_t uid) {
if (errno == ENOENT)
return 0;
- log_warning("Failed to open /dev/mqueue: %m");
+ log_warning_errno(errno, "Failed to open /dev/mqueue: %m");
return -errno;
}
@@ -302,7 +302,7 @@ static int clean_posix_mq(uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning("Failed to stat() MQ segment %s: %m", de->d_name);
+ log_warning_errno(errno, "Failed to stat() MQ segment %s: %m", de->d_name);
ret = -errno;
continue;
}
@@ -317,7 +317,7 @@ static int clean_posix_mq(uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning("Failed to unlink POSIX message queue %s: %m", fn);
+ log_warning_errno(errno, "Failed to unlink POSIX message queue %s: %m", fn);
ret = -errno;
}
}
@@ -325,7 +325,7 @@ static int clean_posix_mq(uid_t uid) {
return ret;
fail:
- log_warning("Failed to read /dev/mqueue: %m");
+ log_warning_errno(errno, "Failed to read /dev/mqueue: %m");
return -errno;
}
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 94808fa6ce..5fe983a847 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -367,7 +367,7 @@ int config_parse(const char *unit,
if (feof(f))
break;
- log_error("Failed to read configuration file '%s': %m", filename);
+ log_error_errno(errno, "Failed to read configuration file '%s': %m", filename);
return -errno;
}
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 2cb4d111f1..01229d8d71 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -65,7 +65,7 @@ int generator_write_fsck_deps(
mkdir_parents(lnk, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0) {
- log_error("Failed to create symlink %s: %m", lnk);
+ log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return -errno;
}
diff --git a/src/shared/pager.c b/src/shared/pager.c
index aa74bab103..2863940725 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -40,7 +40,7 @@ noreturn static void pager_fallback(void) {
} while (n > 0);
if (n < 0) {
- log_error("Internal pager failed: %m");
+ log_error_errno(errno, "Internal pager failed: %m");
_exit(EXIT_FAILURE);
}
@@ -68,7 +68,7 @@ int pager_open(bool jump_to_end) {
columns();
if (pipe(fd) < 0) {
- log_error("Failed to create pager pipe: %m");
+ log_error_errno(errno, "Failed to create pager pipe: %m");
return -errno;
}
@@ -77,7 +77,7 @@ int pager_open(bool jump_to_end) {
pager_pid = fork();
if (pager_pid < 0) {
r = -errno;
- log_error("Failed to fork pager: %m");
+ log_error_errno(errno, "Failed to fork pager: %m");
safe_close_pair(fd);
return r;
}
@@ -127,7 +127,7 @@ int pager_open(bool jump_to_end) {
/* Return in the parent */
if (dup2(fd[1], STDOUT_FILENO) < 0) {
- log_error("Failed to duplicate pager pipe: %m");
+ log_error_errno(errno, "Failed to duplicate pager pipe: %m");
return -errno;
}
@@ -177,7 +177,7 @@ int show_man_page(const char *desc, bool null_stdio) {
pid = fork();
if (pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return -errno;
}
@@ -192,7 +192,7 @@ int show_man_page(const char *desc, bool null_stdio) {
}
execvp(args[0], (char**) args);
- log_error("Failed to execute man: %m");
+ log_error_errno(errno, "Failed to execute man: %m");
_exit(EXIT_FAILURE);
}
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 3f8853902a..085d374ed8 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -116,7 +116,7 @@ static int shovel(PTYForward *f) {
f->stdin_event_source = sd_event_source_unref(f->stdin_event_source);
} else {
- log_error("read(): %m");
+ log_error_errno(errno, "read(): %m");
return sd_event_exit(f->event, EXIT_FAILURE);
}
} else if (k == 0) {
@@ -150,7 +150,7 @@ static int shovel(PTYForward *f) {
f->master_event_source = sd_event_source_unref(f->master_event_source);
} else {
- log_error("write(): %m");
+ log_error_errno(errno, "write(): %m");
return sd_event_exit(f->event, EXIT_FAILURE);
}
} else {
@@ -179,7 +179,7 @@ static int shovel(PTYForward *f) {
f->master_event_source = sd_event_source_unref(f->master_event_source);
} else {
- log_error("read(): %m");
+ log_error_errno(errno, "read(): %m");
return sd_event_exit(f->event, EXIT_FAILURE);
}
} else
@@ -198,7 +198,7 @@ static int shovel(PTYForward *f) {
f->stdout_hangup = true;
f->stdout_event_source = sd_event_source_unref(f->stdout_event_source);
} else {
- log_error("write(): %m");
+ log_error_errno(errno, "write(): %m");
return sd_event_exit(f->event, EXIT_FAILURE);
}
diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
index b6c96435ce..a62c479900 100644
--- a/src/shared/smack-util.c
+++ b/src/shared/smack-util.c
@@ -194,7 +194,7 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
if (ignore_erofs && errno == EROFS)
return 0;
- log_debug("Unable to fix SMACK label of %s: %m", path);
+ log_debug_errno(errno, "Unable to fix SMACK label of %s: %m", path);
r = -errno;
}
#endif
diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c
index 815b90fdfb..b1ef19f265 100644
--- a/src/shared/socket-label.c
+++ b/src/shared/socket-label.c
@@ -93,13 +93,13 @@ int socket_address_listen(
if (free_bind) {
one = 1;
if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one)) < 0)
- log_warning("IP_FREEBIND failed: %m");
+ log_warning_errno(errno, "IP_FREEBIND failed: %m");
}
if (transparent) {
one = 1;
if (setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &one, sizeof(one)) < 0)
- log_warning("IP_TRANSPARENT failed: %m");
+ log_warning_errno(errno, "IP_TRANSPARENT failed: %m");
}
}
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 6bdcb99205..b5b001a6f2 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -658,7 +658,7 @@ int getnameinfo_pretty(int fd, char **ret) {
assert(ret);
if (getsockname(fd, &sa.sa, &salen) < 0) {
- log_error("getsockname(%d) failed: %m", fd);
+ log_error_errno(errno, "getsockname(%d) failed: %m", fd);
return -errno;
}
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
index 3adb8463c5..c5b635d17d 100644
--- a/src/shared/switch-root.c
+++ b/src/shared/switch-root.c
@@ -57,7 +57,7 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
old_root_remove = in_initrd();
if (stat(new_root, &new_root_stat) < 0) {
- log_error("Failed to stat directory %s: %m", new_root);
+ log_error_errno(errno, "Failed to stat directory %s: %m", new_root);
return -errno;
}
@@ -67,7 +67,7 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
*
* https://bugzilla.redhat.com/show_bug.cgi?id=847418 */
if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0)
- log_warning("Failed to make \"/\" private mount: %m");
+ log_warning_errno(errno, "Failed to make \"/\" private mount: %m");
NULSTR_FOREACH(i, move_mounts) {
char new_mount[PATH_MAX];
@@ -85,19 +85,19 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
* stat failed. Unmount the old mount
* point. */
if (umount2(i, MNT_DETACH) < 0)
- log_warning("Failed to unmount %s: %m", i);
+ log_warning_errno(errno, "Failed to unmount %s: %m", i);
continue;
}
if (mount(i, new_mount, NULL, mountflags, NULL) < 0) {
if (mountflags & MS_MOVE) {
- log_error("Failed to move mount %s to %s, forcing unmount: %m", i, new_mount);
+ log_error_errno(errno, "Failed to move mount %s to %s, forcing unmount: %m", i, new_mount);
if (umount2(i, MNT_FORCE) < 0)
- log_warning("Failed to unmount %s: %m", i);
+ log_warning_errno(errno, "Failed to unmount %s: %m", i);
}
if (mountflags & MS_BIND)
- log_error("Failed to bind mount %s to %s: %m", i, new_mount);
+ log_error_errno(errno, "Failed to bind mount %s to %s: %m", i, new_mount);
}
}
@@ -110,14 +110,14 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
(void) base_filesystem_create(new_root);
if (chdir(new_root) < 0) {
- log_error("Failed to change directory to %s: %m", new_root);
+ log_error_errno(errno, "Failed to change directory to %s: %m", new_root);
return -errno;
}
if (old_root_remove) {
old_root_fd = open("/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY|O_DIRECTORY);
if (old_root_fd < 0)
- log_warning("Failed to open root directory: %m");
+ log_warning_errno(errno, "Failed to open root directory: %m");
}
/* We first try a pivot_root() so that we can umount the old
@@ -128,22 +128,22 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
/* Immediately get rid of the old root, if detach_oldroot is set.
* Since we are running off it we need to do this lazily. */
if (detach_oldroot && umount2(oldroot, MNT_DETACH) < 0)
- log_error("Failed to lazily umount old root dir %s, %s: %m",
+ log_error_errno(errno, "Failed to lazily umount old root dir %s, %s: %m",
oldroot,
errno == ENOENT ? "ignoring" : "leaving it around");
} else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0) {
- log_error("Failed to mount moving %s to /: %m", new_root);
+ log_error_errno(errno, "Failed to mount moving %s to /: %m", new_root);
return -errno;
}
if (chroot(".") < 0) {
- log_error("Failed to change root: %m");
+ log_error_errno(errno, "Failed to change root: %m");
return -errno;
}
if (chdir("/") < 0) {
- log_error("Failed to change directory: %m");
+ log_error_errno(errno, "Failed to change directory: %m");
return -errno;
}
@@ -151,7 +151,7 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
struct stat rb;
if (fstat(old_root_fd, &rb) < 0)
- log_warning("Failed to stat old root directory, leaving: %m");
+ log_warning_errno(errno, "Failed to stat old root directory, leaving: %m");
else {
rm_rf_children(old_root_fd, false, false, &rb);
old_root_fd = -1;
diff --git a/src/shared/util.c b/src/shared/util.c
index 74dd4b7f4e..f8511ff4aa 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4065,7 +4065,7 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
executor_pid = fork();
if (executor_pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return;
} else if (executor_pid == 0) {
@@ -4088,7 +4088,7 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
if (errno == ENOENT)
_exit(EXIT_SUCCESS);
- log_error("Failed to enumerate directory %s: %m", directory);
+ log_error_errno(errno, "Failed to enumerate directory %s: %m", directory);
_exit(EXIT_FAILURE);
}
}
@@ -4114,7 +4114,7 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
pid = fork();
if (pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
continue;
} else if (pid == 0) {
char *_argv[2];
@@ -4129,7 +4129,7 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
argv[0] = path;
execv(path, argv);
- log_error("Failed to execute %s: %m", path);
+ log_error_errno(errno, "Failed to execute %s: %m", path);
_exit(EXIT_FAILURE);
}
@@ -5321,7 +5321,7 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
* keep an unused copy of stdin around. */
fd = open("/dev/tty", O_WRONLY);
if (fd < 0) {
- log_error("Failed to open /dev/tty: %m");
+ log_error_errno(errno, "Failed to open /dev/tty: %m");
_exit(EXIT_FAILURE);
}
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c
index 7d188d98e8..386751418e 100644
--- a/src/shared/watchdog.c
+++ b/src/shared/watchdog.c
@@ -45,7 +45,7 @@ static int update_timeout(void) {
flags = WDIOS_DISABLECARD;
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
if (r < 0) {
- log_warning("Failed to disable hardware watchdog: %m");
+ log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
return -errno;
}
} else {
@@ -55,7 +55,7 @@ static int update_timeout(void) {
sec = (int) ((watchdog_timeout + USEC_PER_SEC - 1) / USEC_PER_SEC);
r = ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec);
if (r < 0) {
- log_warning("Failed to set timeout to %is: %m", sec);
+ log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
return -errno;
}
@@ -65,13 +65,13 @@ static int update_timeout(void) {
flags = WDIOS_ENABLECARD;
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
if (r < 0) {
- log_warning("Failed to enable hardware watchdog: %m");
+ log_warning_errno(errno, "Failed to enable hardware watchdog: %m");
return -errno;
}
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
if (r < 0) {
- log_warning("Failed to ping hardware watchdog: %m");
+ log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
return -errno;
}
}
@@ -128,7 +128,7 @@ int watchdog_ping(void) {
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
if (r < 0) {
- log_warning("Failed to ping hardware watchdog: %m");
+ log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
return -errno;
}
@@ -148,7 +148,7 @@ void watchdog_close(bool disarm) {
flags = WDIOS_DISABLECARD;
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
if (r < 0)
- log_warning("Failed to disable hardware watchdog: %m");
+ log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
/* To be sure, use magic close logic, too */
for (;;) {
@@ -158,7 +158,7 @@ void watchdog_close(bool disarm) {
break;
if (errno != EINTR) {
- log_error("Failed to disarm watchdog timer: %m");
+ log_error_errno(errno, "Failed to disarm watchdog timer: %m");
break;
}
}
diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
index cdad583bcb..826efbfeab 100644
--- a/src/shutdownd/shutdownd.c
+++ b/src/shutdownd/shutdownd.c
@@ -79,7 +79,7 @@ static int read_packet(int fd, union shutdown_buffer *_b) {
if (errno == EAGAIN || errno == EINTR)
return 0;
- log_error("recvmsg(): %m");
+ log_error_errno(errno, "recvmsg(): %m");
return -errno;
}
@@ -233,7 +233,7 @@ static int update_schedule_file(struct sd_shutdown_command *c) {
fflush(f);
if (ferror(f) || rename(temp_path, "/run/systemd/shutdown/scheduled") < 0) {
- log_error("Failed to write information about scheduled shutdowns: %m");
+ log_error_errno(errno, "Failed to write information about scheduled shutdowns: %m");
r = -errno;
unlink(temp_path);
@@ -296,7 +296,7 @@ int main(int argc, char *argv[]) {
pollfd[i].events = POLLIN;
pollfd[i].fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK|TFD_CLOEXEC);
if (pollfd[i].fd < 0) {
- log_error("timerfd_create(): %m");
+ log_error_errno(errno, "timerfd_create(): %m");
goto finish;
}
}
@@ -317,7 +317,7 @@ int main(int argc, char *argv[]) {
if (errno == EAGAIN || errno == EINTR)
continue;
- log_error("poll(): %m");
+ log_error_errno(errno, "poll(): %m");
goto finish;
}
@@ -354,7 +354,7 @@ int main(int argc, char *argv[]) {
warn_wall(n, &b.command);
}
if (timerfd_settime(pollfd[FD_WALL_TIMER].fd, TFD_TIMER_ABSTIME, &its, NULL) < 0) {
- log_error("timerfd_settime(): %m");
+ log_error_errno(errno, "timerfd_settime(): %m");
goto finish;
}
@@ -362,7 +362,7 @@ int main(int argc, char *argv[]) {
zero(its);
timespec_store(&its.it_value, when_nologin(b.command.usec));
if (timerfd_settime(pollfd[FD_NOLOGIN_TIMER].fd, TFD_TIMER_ABSTIME, &its, NULL) < 0) {
- log_error("timerfd_settime(): %m");
+ log_error_errno(errno, "timerfd_settime(): %m");
goto finish;
}
@@ -370,7 +370,7 @@ int main(int argc, char *argv[]) {
zero(its);
timespec_store(&its.it_value, b.command.usec);
if (timerfd_settime(pollfd[FD_SHUTDOWN_TIMER].fd, TFD_TIMER_ABSTIME, &its, NULL) < 0) {
- log_error("timerfd_settime(): %m");
+ log_error_errno(errno, "timerfd_settime(): %m");
goto finish;
}
@@ -394,7 +394,7 @@ int main(int argc, char *argv[]) {
/* Restart timer */
timespec_store(&its.it_value, when_wall(n, b.command.usec));
if (timerfd_settime(pollfd[FD_WALL_TIMER].fd, TFD_TIMER_ABSTIME, &its, NULL) < 0) {
- log_error("timerfd_settime(): %m");
+ log_error_errno(errno, "timerfd_settime(): %m");
goto finish;
}
}
@@ -448,7 +448,7 @@ finish:
(b.command.warn_wall ? NULL : "--no-wall"),
NULL);
- log_error("Failed to execute /sbin/shutdown: %m");
+ log_error_errno(errno, "Failed to execute /sbin/shutdown: %m");
}
sd_notify(false,
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 6261502588..a7506ed771 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -78,7 +78,7 @@ static int write_state(FILE **f, char **states) {
fclose(*f);
*f = fopen("/sys/power/state", "we");
if (!*f) {
- log_error("Failed to open /sys/power/state: %m");
+ log_error_errno(errno, "Failed to open /sys/power/state: %m");
return -errno;
}
}
@@ -102,7 +102,7 @@ static int execute(char **modes, char **states) {
* we can abort before modifying any state. */
f = fopen("/sys/power/state", "we");
if (!f) {
- log_error("Failed to open /sys/power/state: %m");
+ log_error_errno(errno, "Failed to open /sys/power/state: %m");
return -errno;
}
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index ca59311662..a2507ad456 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -121,7 +121,7 @@ static int connection_create_pipes(Connection *c, int buffer[2], size_t *sz) {
r = pipe2(buffer, O_CLOEXEC|O_NONBLOCK);
if (r < 0) {
- log_error("Failed to allocate pipe buffer: %m");
+ log_error_errno(errno, "Failed to allocate pipe buffer: %m");
return -errno;
}
@@ -129,7 +129,7 @@ static int connection_create_pipes(Connection *c, int buffer[2], size_t *sz) {
r = fcntl(buffer[0], F_GETPIPE_SZ);
if (r < 0) {
- log_error("Failed to get pipe buffer size: %m");
+ log_error_errno(errno, "Failed to get pipe buffer size: %m");
return -errno;
}
@@ -172,7 +172,7 @@ static int connection_shovel(
*from_source = sd_event_source_unref(*from_source);
*from = safe_close(*from);
} else if (errno != EAGAIN && errno != EINTR) {
- log_error("Failed to splice: %m");
+ log_error_errno(errno, "Failed to splice: %m");
return -errno;
}
}
@@ -186,7 +186,7 @@ static int connection_shovel(
*to_source = sd_event_source_unref(*to_source);
*to = safe_close(*to);
} else if (errno != EAGAIN && errno != EINTR) {
- log_error("Failed to splice: %m");
+ log_error_errno(errno, "Failed to splice: %m");
return -errno;
}
}
@@ -317,7 +317,7 @@ static int connect_cb(sd_event_source *s, int fd, uint32_t revents, void *userda
solen = sizeof(error);
r = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &solen);
if (r < 0) {
- log_error("Failed to issue SO_ERROR: %m");
+ log_error_errno(errno, "Failed to issue SO_ERROR: %m");
goto fail;
}
@@ -344,7 +344,7 @@ static int connection_start(Connection *c, struct sockaddr *sa, socklen_t salen)
c->client_fd = socket(sa->sa_family, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (c->client_fd < 0) {
- log_error("Failed to get remote socket: %m");
+ log_error_errno(errno, "Failed to get remote socket: %m");
goto fail;
}
@@ -363,7 +363,7 @@ static int connection_start(Connection *c, struct sockaddr *sa, socklen_t salen)
goto fail;
}
} else {
- log_error("Failed to connect to remote host: %m");
+ log_error_errno(errno, "Failed to connect to remote host: %m");
goto fail;
}
} else {
@@ -510,7 +510,7 @@ static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdat
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (nfd < 0) {
if (errno != -EAGAIN)
- log_warning("Failed to accept() socket: %m");
+ log_warning_errno(errno, "Failed to accept() socket: %m");
} else {
getpeername_pretty(nfd, &peer);
log_debug("New connection from %s", strna(peer));
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 2d1ae6e8b1..973e67e3c8 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -147,7 +147,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
if (feof(f))
break;
- log_error("Failed to read file '%s', ignoring: %m", path);
+ log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
return -errno;
}
diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c
index 4f22c9c359..2e37410bf4 100644
--- a/src/system-update-generator/system-update-generator.c
+++ b/src/system-update-generator/system-update-generator.c
@@ -41,13 +41,13 @@ static int generate_symlink(void) {
if (errno == ENOENT)
return 0;
- log_error("Failed to check for system update: %m");
+ log_error_errno(errno, "Failed to check for system update: %m");
return -EINVAL;
}
p = strappenda(arg_dest, "/default.target");
if (symlink(SYSTEM_DATA_UNIT_PATH "/system-update.target", p) < 0) {
- log_error("Failed to create symlink %s: %m", p);
+ log_error_errno(errno, "Failed to create symlink %s: %m", p);
return -errno;
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 35d14bd267..69f157cebb 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5220,7 +5220,7 @@ static int enable_sysv_units(const char *verb, char **args) {
pid = fork();
if (pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return -errno;
} else if (pid == 0) {
/* Child */
@@ -6721,14 +6721,14 @@ static int talk_initctl(void) {
if (errno == ENOENT)
return 0;
- log_error("Failed to open "INIT_FIFO": %m");
+ log_error_errno(errno, "Failed to open "INIT_FIFO": %m");
return -errno;
}
errno = 0;
r = loop_write(fd, &request, sizeof(request), false) != sizeof(request);
if (r) {
- log_error("Failed to write to "INIT_FIFO": %m");
+ log_error_errno(errno, "Failed to write to "INIT_FIFO": %m");
return errno > 0 ? -errno : -EIO;
}
@@ -6953,7 +6953,7 @@ static int reload_with_fallback(sd_bus *bus) {
assert(arg_action == ACTION_RELOAD || arg_action == ACTION_REEXEC);
if (kill(1, arg_action == ACTION_RELOAD ? SIGHUP : SIGTERM) < 0) {
- log_error("kill() failed: %m");
+ log_error_errno(errno, "kill() failed: %m");
return -errno;
}
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 845a307ae7..e69a5f58ad 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -226,15 +226,15 @@ static int make_backup(const char *target, const char *x) {
/* Copy over the access mask */
if (fchmod(fileno(dst), st.st_mode & 07777) < 0)
- log_warning("Failed to change mode on %s: %m", backup);
+ log_warning_errno(errno, "Failed to change mode on %s: %m", backup);
if (fchown(fileno(dst), st.st_uid, st.st_gid)< 0)
- log_warning("Failed to change ownership of %s: %m", backup);
+ log_warning_errno(errno, "Failed to change ownership of %s: %m", backup);
ts[0] = st.st_atim;
ts[1] = st.st_mtim;
if (futimens(fileno(dst), ts) < 0)
- log_warning("Failed to fix access and modification time of %s: %m", backup);
+ log_warning_errno(errno, "Failed to fix access and modification time of %s: %m", backup);
if (rename(temp, backup) < 0)
goto fail;
@@ -899,7 +899,7 @@ static int add_user(Item *i) {
return 0;
}
if (!IN_SET(errno, 0, ENOENT)) {
- log_error("Failed to check if user %s already exists: %m", i->name);
+ log_error_errno(errno, "Failed to check if user %s already exists: %m", i->name);
return -errno;
}
@@ -911,7 +911,7 @@ static int add_user(Item *i) {
return -EBADMSG;
}
if (!IN_SET(errno, 0, ENOENT)) {
- log_error("Failed to check if user %s already exists in shadow database: %m", i->name);
+ log_error_errno(errno, "Failed to check if user %s already exists in shadow database: %m", i->name);
return -errno;
}
}
@@ -1057,7 +1057,7 @@ static int add_group(Item *i) {
return 0;
}
if (!IN_SET(errno, 0, ENOENT)) {
- log_error("Failed to check if group %s already exists: %m", i->name);
+ log_error_errno(errno, "Failed to check if group %s already exists: %m", i->name);
return -errno;
}
}
@@ -1731,7 +1731,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
}
if (ferror(f)) {
- log_error("Failed to read from file %s: %m", fn);
+ log_error_errno(errno, "Failed to read from file %s: %m", fn);
if (r == 0)
r = -EIO;
}
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 5ff621d1fa..434947e1ef 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -144,7 +144,7 @@ static int generate_unit_file(SysvStub *s) {
f = fopen(unit, "wxe");
if (!f) {
- log_error("Failed to create unit file %s: %m", unit);
+ log_error_errno(errno, "Failed to create unit file %s: %m", unit);
return -errno;
}
@@ -699,7 +699,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
d = opendir(*path);
if (!d) {
if (errno != ENOENT)
- log_warning("opendir(%s) failed: %m", *path);
+ log_warning_errno(errno, "opendir(%s) failed: %m", *path);
continue;
}
@@ -774,7 +774,7 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
d = opendir(path);
if (!d) {
if (errno != ENOENT)
- log_warning("opendir(%s) failed: %m", path);
+ log_warning_errno(errno, "opendir(%s) failed: %m", path);
continue;
}
diff --git a/src/test/test-capability.c b/src/test/test-capability.c
index a362fc6c57..43769923b0 100644
--- a/src/test/test-capability.c
+++ b/src/test/test-capability.c
@@ -70,7 +70,7 @@ static int setup_tests(void) {
nobody = getpwnam("nobody");
if (!nobody) {
- log_error("Could not find nobody user: %m");
+ log_error_errno(errno, "Could not find nobody user: %m");
return -EXIT_TEST_SKIP;
}
test_uid = nobody->pw_uid;
diff --git a/src/test/test-ns.c b/src/test/test-ns.c
index e66d97ff33..7cd7b77153 100644
--- a/src/test/test-ns.c
+++ b/src/test/test-ns.c
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
}
execl("/bin/sh", "/bin/sh", NULL);
- log_error("execl(): %m");
+ log_error_errno(errno, "execl(): %m");
return 1;
}
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 56df59f9b7..24de21008f 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -569,7 +569,7 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
/* Set system clock */
if (clock_settime(CLOCK_REALTIME, &ts) < 0) {
- log_error("Failed to set local time: %m");
+ log_error_errno(errno, "Failed to set local time: %m");
return sd_bus_error_set_errnof(error, errno, "Failed to set local time: %m");
}
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 670b122836..b16b25a96a 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -211,7 +211,7 @@ static int manager_send_request(Manager *m) {
m->pending = true;
log_debug("Sent NTP request to %s (%s).", strna(pretty), m->current_server_name->string);
} else {
- log_debug("Sending NTP request to %s (%s) failed: %m", strna(pretty), m->current_server_name->string);
+ log_debug_errno(errno, "Sending NTP request to %s (%s) failed: %m", strna(pretty), m->current_server_name->string);
return manager_connect(m);
}
@@ -312,12 +312,12 @@ static int manager_clock_watch_setup(Manager *m) {
m->clock_watch_fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK|TFD_CLOEXEC);
if (m->clock_watch_fd < 0) {
- log_error("Failed to create timerfd: %m");
+ log_error_errno(errno, "Failed to create timerfd: %m");
return -errno;
}
if (timerfd_settime(m->clock_watch_fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0) {
- log_error("Failed to set up timerfd: %m");
+ log_error_errno(errno, "Failed to set up timerfd: %m");
return -errno;
}
@@ -682,7 +682,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
m->sync = true;
r = manager_adjust_clock(m, offset, leap_sec);
if (r < 0)
- log_error("Failed to call clock_adjtime(): %m");
+ log_error_errno(errno, "Failed to call clock_adjtime(): %m");
}
log_info("interval/delta/delay/jitter/drift " USEC_FMT "s/%+.3fs/%.3fs/%.3fs/%+ippm%s",
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index ed02e6db3a..f7e089fc0c 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -73,7 +73,7 @@ static int load_clock_timestamp(uid_t uid, gid_t gid) {
format_timestamp(date, sizeof(date), min));
if (clock_settime(CLOCK_REALTIME, timespec_store(&ts, min)) < 0)
- log_error("Failed to restore system clock: %m");
+ log_error_errno(errno, "Failed to restore system clock: %m");
}
return 0;
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 45d31fb5d8..852bb45315 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -291,9 +291,9 @@ static int dir_cleanup(
/* FUSE, NFS mounts, SELinux might return EACCES */
if (errno == EACCES)
- log_debug("stat(%s/%s) failed: %m", p, dent->d_name);
+ log_debug_errno(errno, "stat(%s/%s) failed: %m", p, dent->d_name);
else
- log_error("stat(%s/%s) failed: %m", p, dent->d_name);
+ log_error_errno(errno, "stat(%s/%s) failed: %m", p, dent->d_name);
r = -errno;
continue;
}
@@ -341,7 +341,7 @@ static int dir_cleanup(
sub_dir = xopendirat(dirfd(d), dent->d_name, O_NOFOLLOW|O_NOATIME);
if (!sub_dir) {
if (errno != ENOENT) {
- log_error("opendir(%s/%s) failed: %m", p, dent->d_name);
+ log_error_errno(errno, "opendir(%s/%s) failed: %m", p, dent->d_name);
r = -errno;
}
@@ -374,7 +374,7 @@ static int dir_cleanup(
if (unlinkat(dirfd(d), dent->d_name, AT_REMOVEDIR) < 0) {
if (errno != ENOENT && errno != ENOTEMPTY) {
- log_error("rmdir(%s): %m", sub_path);
+ log_error_errno(errno, "rmdir(%s): %m", sub_path);
r = -errno;
}
}
@@ -422,7 +422,7 @@ static int dir_cleanup(
if (unlinkat(dirfd(d), dent->d_name, 0) < 0) {
if (errno != ENOENT) {
- log_error("unlink(%s): %m", sub_path);
+ log_error_errno(errno, "unlink(%s): %m", sub_path);
r = -errno;
}
}
@@ -438,7 +438,7 @@ finish:
times[1] = ds->st_mtim;
if (futimens(dirfd(d), times) < 0)
- log_error("utimensat(%s): %m", p);
+ log_error_errno(errno, "utimensat(%s): %m", p);
}
return r;
@@ -470,7 +470,7 @@ static int item_set_perms(Item *i, const char *path) {
if (!st_valid || m != (st.st_mode & 07777)) {
if (chmod(path, m) < 0) {
- log_error("chmod(%s) failed: %m", path);
+ log_error_errno(errno, "chmod(%s) failed: %m", path);
return -errno;
}
}
@@ -482,7 +482,7 @@ static int item_set_perms(Item *i, const char *path) {
i->uid_set ? i->uid : (uid_t) -1,
i->gid_set ? i->gid : (gid_t) -1) < 0) {
- log_error("chown(%s) failed: %m", path);
+ log_error_errno(errno, "chown(%s) failed: %m", path);
return -errno;
}
@@ -510,7 +510,7 @@ static int write_one_file(Item *i, const char *path) {
if (i->type == WRITE_FILE && errno == ENOENT)
return 0;
- log_error("Failed to create file %s: %m", path);
+ log_error_errno(errno, "Failed to create file %s: %m", path);
return -errno;
}
@@ -535,7 +535,7 @@ static int write_one_file(Item *i, const char *path) {
fd = safe_close(fd);
if (stat(path, &st) < 0) {
- log_error("stat(%s) failed: %m", path);
+ log_error_errno(errno, "stat(%s) failed: %m", path);
return -errno;
}
@@ -628,7 +628,7 @@ static int glob_item(Item *i, int (*action)(Item *, const char *)) {
if (errno == 0)
errno = EIO;
- log_error("glob(%s) failed: %m", i->path);
+ log_error_errno(errno, "glob(%s) failed: %m", i->path);
return -errno;
}
@@ -671,12 +671,12 @@ static int create_item(Item *i) {
return log_error_errno(r, "Failed to copy files to %s: %m", i->path);
if (stat(i->argument, &a) < 0) {
- log_error("stat(%s) failed: %m", i->argument);
+ log_error_errno(errno, "stat(%s) failed: %m", i->argument);
return -errno;
}
if (stat(i->path, &b) < 0) {
- log_error("stat(%s) failed: %m", i->path);
+ log_error_errno(errno, "stat(%s) failed: %m", i->path);
return -errno;
}
@@ -712,7 +712,7 @@ static int create_item(Item *i) {
return log_error_errno(r, "Failed to create directory %s: %m", i->path);
if (stat(i->path, &st) < 0) {
- log_error("stat(%s) failed: %m", i->path);
+ log_error_errno(errno, "stat(%s) failed: %m", i->path);
return -errno;
}
@@ -738,12 +738,12 @@ static int create_item(Item *i) {
if (r < 0) {
if (errno != EEXIST) {
- log_error("Failed to create fifo %s: %m", i->path);
+ log_error_errno(errno, "Failed to create fifo %s: %m", i->path);
return -errno;
}
if (stat(i->path, &st) < 0) {
- log_error("stat(%s) failed: %m", i->path);
+ log_error_errno(errno, "stat(%s) failed: %m", i->path);
return -errno;
}
@@ -782,7 +782,7 @@ static int create_item(Item *i) {
_cleanup_free_ char *x = NULL;
if (errno != EEXIST) {
- log_error("symlink(%s, %s) failed: %m", i->argument, i->path);
+ log_error_errno(errno, "symlink(%s, %s) failed: %m", i->argument, i->path);
return -errno;
}
@@ -835,12 +835,12 @@ static int create_item(Item *i) {
}
if (errno != EEXIST) {
- log_error("Failed to create device node %s: %m", i->path);
+ log_error_errno(errno, "Failed to create device node %s: %m", i->path);
return -errno;
}
if (stat(i->path, &st) < 0) {
- log_error("stat(%s) failed: %m", i->path);
+ log_error_errno(errno, "stat(%s) failed: %m", i->path);
return -errno;
}
@@ -917,7 +917,7 @@ static int remove_item_instance(Item *i, const char *instance) {
case REMOVE_PATH:
if (remove(instance) < 0 && errno != ENOENT) {
- log_error("remove(%s): %m", instance);
+ log_error_errno(errno, "remove(%s): %m", instance);
return -errno;
}
@@ -993,12 +993,12 @@ static int clean_item_instance(Item *i, const char* instance) {
if (errno == ENOENT || errno == ENOTDIR)
return 0;
- log_error("Failed to open directory %s: %m", i->path);
+ log_error_errno(errno, "Failed to open directory %s: %m", i->path);
return -errno;
}
if (fstat(dirfd(d), &s) < 0) {
- log_error("stat(%s) failed: %m", i->path);
+ log_error_errno(errno, "stat(%s) failed: %m", i->path);
return -errno;
}
@@ -1008,7 +1008,7 @@ static int clean_item_instance(Item *i, const char* instance) {
}
if (fstatat(dirfd(d), "..", &ps, AT_SYMLINK_NOFOLLOW) != 0) {
- log_error("stat(%s/..) failed: %m", i->path);
+ log_error_errno(errno, "stat(%s/..) failed: %m", i->path);
return -errno;
}
@@ -1564,7 +1564,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
}
if (ferror(f)) {
- log_error("Failed to read from file %s: %m", fn);
+ log_error_errno(errno, "Failed to read from file %s: %m", fn);
if (r == 0)
r = -EIO;
}
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 44da9a8c25..f8e80a39be 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -91,7 +91,7 @@ static int ask_password_plymouth(
r = connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1));
if (r < 0) {
- log_error("Failed to connect to Plymouth: %m");
+ log_error_errno(errno, "Failed to connect to Plymouth: %m");
return -errno;
}
@@ -343,7 +343,7 @@ static int parse_password(const char *filename, char **wall) {
socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
if (socket_fd < 0) {
- log_error("socket(): %m");
+ log_error_errno(errno, "socket(): %m");
return -errno;
}
@@ -353,7 +353,7 @@ static int parse_password(const char *filename, char **wall) {
r = sendto(socket_fd, packet, packet_length, MSG_NOSIGNAL, &sa.sa,
offsetof(struct sockaddr_un, sun_path) + strlen(socket_name));
if (r < 0) {
- log_error("Failed to send: %m");
+ log_error_errno(errno, "Failed to send: %m");
return r;
}
}
@@ -428,7 +428,7 @@ static int show_passwords(void) {
if (errno == ENOENT)
return 0;
- log_error("opendir(/run/systemd/ask-password): %m");
+ log_error_errno(errno, "opendir(/run/systemd/ask-password): %m");
return -errno;
}
diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
index 0d56f9b09d..89628c929d 100644
--- a/src/udev/ata_id/ata_id.c
+++ b/src/udev/ata_id/ata_id.c
@@ -494,7 +494,7 @@ int main(int argc, char *argv[])
} else {
/* If this fails, then try HDIO_GET_IDENTITY */
if (ioctl(fd, HDIO_GET_IDENTITY, &id) != 0) {
- log_debug("HDIO_GET_IDENTITY failed for '%s': %m", node);
+ log_debug_errno(errno, "HDIO_GET_IDENTITY failed for '%s': %m", node);
rc = 2;
goto close;
}
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index 1c269084aa..27adb09d15 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -174,7 +174,7 @@ static int get_file_options(struct udev *udev,
if (errno == ENOENT)
return 1;
else {
- log_error("can't open %s: %m", config_file);
+ log_error_errno(errno, "can't open %s: %m", config_file);
return -1;
}
}
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index 9338671591..dcfff1d4ea 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -361,7 +361,7 @@ resend:
dev_scsi->use_sg = 3;
goto resend;
}
- log_debug("%s: ioctl failed: %m", dev_scsi->kernel);
+ log_debug_errno(errno, "%s: ioctl failed: %m", dev_scsi->kernel);
goto error;
}
@@ -819,12 +819,12 @@ int scsi_std_inquiry(struct udev *udev,
fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (fd < 0) {
- log_debug("scsi_id: cannot open %s: %m", devname);
+ log_debug_errno(errno, "scsi_id: cannot open %s: %m", devname);
return 1;
}
if (fstat(fd, &statbuf) < 0) {
- log_debug("scsi_id: cannot stat %s: %m", devname);
+ log_debug_errno(errno, "scsi_id: cannot stat %s: %m", devname);
err = 2;
goto out;
}
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
index 2deb8b9fbb..273b27ddcb 100644
--- a/src/udev/udev-builtin-keyboard.c
+++ b/src/udev/udev-builtin-keyboard.c
@@ -140,7 +140,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
- log_error("Error, opening device '%s': %m", node);
+ log_error_errno(errno, "Error, opening device '%s': %m", node);
return EXIT_FAILURE;
}
@@ -149,7 +149,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)",
map[i].scan, map[i].scan, map[i].key, map[i].key);
if (ioctl(fd, EVIOCSKEYCODE, &map[i]) < 0)
- log_error("Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", node, map[i].scan, map[i].key);
+ log_error_errno(errno, "Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", node, map[i].scan, map[i].key);
}
/* install list of force-release codes */
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 2c016da103..9cece4a85d 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -84,7 +84,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
if (fd < 0) {
uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (uctrl->sock < 0) {
- log_error("error getting socket: %m");
+ log_error_errno(errno, "error getting socket: %m");
udev_ctrl_unref(uctrl);
return NULL;
}
@@ -94,7 +94,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
}
r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (r < 0)
- log_warning("could not set SO_PASSCRED: %m");
+ log_warning_errno(errno, "could not set SO_PASSCRED: %m");
uctrl->saddr.sun_family = AF_LOCAL;
strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");
@@ -118,14 +118,14 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
if (err < 0) {
err = -errno;
- log_error("bind failed: %m");
+ log_error_errno(errno, "bind failed: %m");
return err;
}
err = listen(uctrl->sock, 0);
if (err < 0) {
err = -errno;
- log_error("listen failed: %m");
+ log_error_errno(errno, "listen failed: %m");
return err;
}
@@ -187,7 +187,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
if (conn->sock < 0) {
if (errno != EINTR)
- log_error("unable to receive ctrl connection: %m");
+ log_error_errno(errno, "unable to receive ctrl connection: %m");
goto err;
}
@@ -205,7 +205,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
/* enable receiving of the sender credentials in the messages */
r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
if (r < 0)
- log_warning("could not set SO_PASSCRED: %m");
+ log_warning_errno(errno, "could not set SO_PASSCRED: %m");
udev_ctrl_ref(uctrl);
return conn;
@@ -361,7 +361,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
goto err;
} else {
if (!(pfd[0].revents & POLLIN)) {
- log_error("ctrl connection error: %m");
+ log_error_errno(errno, "ctrl connection error: %m");
goto err;
}
}
@@ -374,7 +374,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {
- log_error("unable to receive ctrl message: %m");
+ log_error_errno(errno, "unable to receive ctrl message: %m");
goto err;
}
cmsg = CMSG_FIRSTHDR(&smsg);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 5a7b65aff3..6b184303d8 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -387,7 +387,7 @@ static int spawn_exec(struct udev_event *event,
if (fd_stderr < 0)
dup2(fd, STDERR_FILENO);
} else
- log_error("open /dev/null failed: %m");
+ log_error_errno(errno, "open /dev/null failed: %m");
/* connect pipes to std{out,err} */
if (fd_stdout >= 0) {
@@ -409,7 +409,7 @@ static int spawn_exec(struct udev_event *event,
execve(argv[0], argv, envp);
/* exec failed */
- log_error("failed to execute '%s' '%s': %m", argv[0], cmd);
+ log_error_errno(errno, "failed to execute '%s' '%s': %m", argv[0], cmd);
return -errno;
}
@@ -437,14 +437,14 @@ static void spawn_read(struct udev_event *event,
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
return;
}
if (fd_stdout >= 0) {
r = epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stdout, &ep_outpipe);
if (r < 0) {
- log_error("fail to add stdout fd to epoll: %m");
+ log_error_errno(errno, "fail to add stdout fd to epoll: %m");
return;
}
}
@@ -452,7 +452,7 @@ static void spawn_read(struct udev_event *event,
if (fd_stderr >= 0) {
r = epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stderr, &ep_errpipe);
if (r < 0) {
- log_error("fail to add stderr fd to epoll: %m");
+ log_error_errno(errno, "fail to add stderr fd to epoll: %m");
return;
}
}
@@ -481,7 +481,7 @@ static void spawn_read(struct udev_event *event,
if (fdcount < 0) {
if (errno == EINTR)
continue;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
return;
} else if (fdcount == 0) {
log_error("timeout '%s'", cmd);
@@ -527,7 +527,7 @@ static void spawn_read(struct udev_event *event,
} else if (ev[i].events & EPOLLHUP) {
r = epoll_ctl(fd_ep, EPOLL_CTL_DEL, *fd, NULL);
if (r < 0) {
- log_error("failed to remove fd from epoll: %m");
+ log_error_errno(errno, "failed to remove fd from epoll: %m");
return;
}
*fd = -1;
@@ -576,7 +576,7 @@ static int spawn_wait(struct udev_event *event,
if (errno == EINTR)
continue;
err = -errno;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
goto out;
}
if (fdcount == 0) {
@@ -587,7 +587,7 @@ static int spawn_wait(struct udev_event *event,
if (errno == EINTR)
continue;
err = -errno;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
goto out;
}
if (fdcount == 0) {
@@ -691,14 +691,14 @@ int udev_event_spawn(struct udev_event *event,
if (result != NULL || log_get_max_level() >= LOG_INFO) {
if (pipe2(outpipe, O_NONBLOCK) != 0) {
err = -errno;
- log_error("pipe failed: %m");
+ log_error_errno(errno, "pipe failed: %m");
goto out;
}
}
if (log_get_max_level() >= LOG_INFO) {
if (pipe2(errpipe, O_NONBLOCK) != 0) {
err = -errno;
- log_error("pipe failed: %m");
+ log_error_errno(errno, "pipe failed: %m");
goto out;
}
}
@@ -729,7 +729,7 @@ int udev_event_spawn(struct udev_event *event,
_exit(2 );
case -1:
- log_error("fork of '%s' failed: %m", cmd);
+ log_error_errno(errno, "fork of '%s' failed: %m", cmd);
err = -1;
goto out;
default:
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index c9a273d003..c30a428ea1 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -112,12 +112,12 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s
mac_selinux_create_file_clear();
} while (err == -ENOENT);
if (err != 0) {
- log_error("symlink '%s' '%s' failed: %m", target, slink_tmp);
+ log_error_errno(errno, "symlink '%s' '%s' failed: %m", target, slink_tmp);
goto exit;
}
err = rename(slink_tmp, slink);
if (err != 0) {
- log_error("rename '%s' '%s' failed: %m", slink_tmp, slink);
+ log_error_errno(errno, "rename '%s' '%s' failed: %m", slink_tmp, slink);
unlink(slink_tmp);
}
exit:
@@ -264,7 +264,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
if (lstat(devnode, &stats) != 0) {
err = -errno;
- log_debug("can not stat() node '%s' (%m)", devnode);
+ log_debug_errno(errno, "can not stat() node '%s' (%m)", devnode);
goto out;
}
@@ -283,10 +283,10 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
log_debug("set permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
err = chmod(devnode, mode);
if (err < 0)
- log_warning("setting mode of %s to %#o failed: %m", devnode, mode);
+ log_warning_errno(errno, "setting mode of %s to %#o failed: %m", devnode, mode);
err = chown(devnode, uid, gid);
if (err < 0)
- log_warning("setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
+ log_warning_errno(errno, "setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
} else {
log_debug("preserve permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
}
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index beb5dc6ef1..d72362fcbd 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2535,10 +2535,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
f = fopen(attr, "we");
if (f != NULL) {
if (fprintf(f, "%s", value) <= 0)
- log_error("error writing ATTR{%s}: %m", attr);
+ log_error_errno(errno, "error writing ATTR{%s}: %m", attr);
fclose(f);
} else {
- log_error("error opening ATTR{%s} for writing: %m", attr);
+ log_error_errno(errno, "error opening ATTR{%s} for writing: %m", attr);
}
break;
}
@@ -2660,7 +2660,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
r = symlink(device_node, tag_symlink);
if (r < 0 && errno != EEXIST) {
- log_error("failed to create symlink %s -> %s: %m", tag_symlink, device_node);
+ log_error_errno(errno, "failed to create symlink %s -> %s: %m", tag_symlink, device_node);
return -errno;
} else
r = 0;
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index 061bd05875..6ba8674d77 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -39,7 +39,7 @@ static int inotify_fd = -1;
int udev_watch_init(struct udev *udev) {
inotify_fd = inotify_init1(IN_CLOEXEC);
if (inotify_fd < 0)
- log_error("inotify_init failed: %m");
+ log_error_errno(errno, "inotify_init failed: %m");
return inotify_fd;
}
@@ -56,7 +56,7 @@ void udev_watch_restore(struct udev *udev) {
dir = opendir("/run/udev/watch.old");
if (dir == NULL) {
- log_error("unable to open old watches dir /run/udev/watch.old; old watches will not be restored: %m");
+ log_error_errno(errno, "unable to open old watches dir /run/udev/watch.old; old watches will not be restored: %m");
return;
}
@@ -88,7 +88,7 @@ unlink:
rmdir("/run/udev/watch.old");
} else if (errno != ENOENT) {
- log_error("unable to move watches dir /run/udev/watch; old watches will not be restored: %m");
+ log_error_errno(errno, "unable to move watches dir /run/udev/watch; old watches will not be restored: %m");
}
}
@@ -103,7 +103,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
log_debug("adding watch on '%s'", udev_device_get_devnode(dev));
wd = inotify_add_watch(inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
if (wd < 0) {
- log_error("inotify_add_watch(%d, %s, %o) failed: %m",
+ log_error_errno(errno, "inotify_add_watch(%d, %s, %o) failed: %m",
inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
return;
}
@@ -113,7 +113,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) {
unlink(filename);
r = symlink(udev_device_get_id_filename(dev), filename);
if (r < 0)
- log_error("Failed to create symlink %s: %m", filename);
+ log_error_errno(errno, "Failed to create symlink %s: %m", filename);
udev_device_set_watch_handle(dev, wd);
}
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index e776fb99dc..1a5f516ddc 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -155,7 +155,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
return 1;
}
@@ -195,7 +195,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
ep_udev.events = EPOLLIN;
ep_udev.data.fd = fd_udev;
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) {
- log_error("fail to add fd to epoll: %m");
+ log_error_errno(errno, "fail to add fd to epoll: %m");
return 2;
}
@@ -229,7 +229,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
ep_kernel.events = EPOLLIN;
ep_kernel.data.fd = fd_kernel;
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_kernel, &ep_kernel) < 0) {
- log_error("fail to add fd to epoll: %m");
+ log_error_errno(errno, "fail to add fd to epoll: %m");
return 5;
}
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index e8a0c2fef6..4308466b84 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -54,7 +54,7 @@ static void exec_list(struct udev_enumerate *udev_enumerate, const char *action)
if (fd < 0)
continue;
if (write(fd, action, strlen(action)) < 0)
- log_debug("error writing '%s' to '%s': %m", action, filename);
+ log_debug_errno(errno, "error writing '%s' to '%s': %m", action, filename);
close(fd);
}
}
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index aaa806aa27..ab2b4ba611 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -220,14 +220,14 @@ static void worker_new(struct event *event) {
sigfillset(&mask);
fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
if (fd_signal < 0) {
- log_error("error creating signalfd %m");
+ log_error_errno(errno, "error creating signalfd %m");
rc = 2;
goto out;
}
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
rc = 3;
goto out;
}
@@ -243,7 +243,7 @@ static void worker_new(struct event *event) {
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) {
- log_error("fail to add fds to epoll: %m");
+ log_error_errno(errno, "fail to add fds to epoll: %m");
rc = 4;
goto out;
}
@@ -293,7 +293,7 @@ static void worker_new(struct event *event) {
if (d) {
fd_lock = open(udev_device_get_devnode(d), O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
if (fd_lock >= 0 && flock(fd_lock, LOCK_SH|LOCK_NB) < 0) {
- log_debug("Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
+ log_debug_errno(errno, "Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
err = -EWOULDBLOCK;
fd_lock = safe_close(fd_lock);
goto skip;
@@ -358,7 +358,7 @@ skip:
if (fdcount < 0) {
if (errno == EINTR)
continue;
- log_error("failed to poll: %m");
+ log_error_errno(errno, "failed to poll: %m");
goto out;
}
@@ -398,7 +398,7 @@ out:
udev_monitor_unref(worker_monitor);
event->state = EVENT_QUEUED;
free(worker);
- log_error("fork of child failed: %m");
+ log_error_errno(errno, "fork of child failed: %m");
break;
default:
/* close monitor, but keep address around */
@@ -429,7 +429,7 @@ static void event_run(struct event *event) {
count = udev_monitor_send_device(monitor, worker->monitor, event->dev);
if (count < 0) {
- log_error("worker [%u] did not accept message %zi (%m), kill it", worker->pid, count);
+ log_error_errno(errno, "worker [%u] did not accept message %zi (%m), kill it", worker->pid, count);
kill(worker->pid, SIGKILL);
worker->state = WORKER_KILLED;
continue;
@@ -1142,7 +1142,7 @@ int main(int argc, char *argv[]) {
/* set umask before creating any file/directory */
r = chdir("/");
if (r < 0) {
- log_error("could not change dir to /: %m");
+ log_error_errno(errno, "could not change dir to /: %m");
goto exit;
}
@@ -1152,7 +1152,7 @@ int main(int argc, char *argv[]) {
r = mkdir("/run/udev", 0755);
if (r < 0 && errno != EEXIST) {
- log_error("could not create /run/udev: %m");
+ log_error_errno(errno, "could not create /run/udev: %m");
goto exit;
}
@@ -1249,7 +1249,7 @@ int main(int argc, char *argv[]) {
case 0:
break;
case -1:
- log_error("fork of daemon failed: %m");
+ log_error_errno(errno, "fork of daemon failed: %m");
rc = 4;
goto exit;
default:
@@ -1312,7 +1312,7 @@ int main(int argc, char *argv[]) {
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- log_error("error creating epoll fd: %m");
+ log_error_errno(errno, "error creating epoll fd: %m");
goto exit;
}
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_ctrl, &ep_ctrl) < 0 ||
@@ -1320,7 +1320,7 @@ int main(int argc, char *argv[]) {
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_netlink, &ep_netlink) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_worker, &ep_worker) < 0) {
- log_error("fail to add fds to epoll: %m");
+ log_error_errno(errno, "fail to add fds to epoll: %m");
goto exit;
}
diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c
index 93c14d82fe..15da83193b 100644
--- a/src/update-utmp/update-utmp.c
+++ b/src/update-utmp/update-utmp.c
@@ -133,7 +133,7 @@ static int on_reboot(Context *c) {
if (c->audit_fd >= 0)
if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
errno != EPERM) {
- log_error("Failed to send audit message: %m");
+ log_error_errno(errno, "Failed to send audit message: %m");
r = -errno;
}
#endif
@@ -163,7 +163,7 @@ static int on_shutdown(Context *c) {
if (c->audit_fd >= 0)
if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_SHUTDOWN, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
errno != EPERM) {
- log_error("Failed to send audit message: %m");
+ log_error_errno(errno, "Failed to send audit message: %m");
r = -errno;
}
#endif
@@ -215,7 +215,7 @@ static int on_runlevel(Context *c) {
if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s, "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
errno != EPERM) {
- log_error("Failed to send audit message: %m");
+ log_error_errno(errno, "Failed to send audit message: %m");
r = -errno;
}
}
@@ -259,7 +259,7 @@ int main(int argc, char *argv[]) {
* don't worry about it. */
c.audit_fd = audit_open();
if (c.audit_fd < 0 && errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
- log_error("Failed to connect to audit log: %m");
+ log_error_errno(errno, "Failed to connect to audit log: %m");
#endif
r = bus_open_system_systemd(&c.bus);
if (r < 0) {
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 5bd0b9b143..e79ad2a5f0 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -123,7 +123,7 @@ static int keymap_load(const char *vc, const char *map, const char *map_toggle,
pid = fork();
if (pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return -errno;
} else if (pid == 0) {
execv(args[0], (char **) args);
@@ -161,7 +161,7 @@ static int font_load(const char *vc, const char *font, const char *map, const ch
pid = fork();
if (pid < 0) {
- log_error("Failed to fork: %m");
+ log_error_errno(errno, "Failed to fork: %m");
return -errno;
} else if (pid == 0) {
execv(args[0], (char **) args);
@@ -262,7 +262,7 @@ int main(int argc, char **argv) {
fd = open_terminal(vc, O_RDWR|O_CLOEXEC);
if (fd < 0) {
- log_error("Failed to open %s: %m", vc);
+ log_error_errno(errno, "Failed to open %s: %m", vc);
return EXIT_FAILURE;
}