summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-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
14 files changed, 80 insertions, 80 deletions
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;
}
}