summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal')
-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
18 files changed, 88 insertions, 88 deletions
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)