chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus-proxy: also consider ENOTCONN a clean termination condition
[elogind.git]
/
src
/
journal
/
journald-kmsg.c
diff --git
a/src/journal/journald-kmsg.c
b/src/journal/journald-kmsg.c
index 126126b8878b488849d4ce5223b8a7f15d186c81..c4216c4043370bb8047c99a07faf9336cc9bfe16 100644
(file)
--- a/
src/journal/journald-kmsg.c
+++ b/
src/journal/journald-kmsg.c
@@
-40,7
+40,8
@@
void server_forward_kmsg(
const struct ucred *ucred) {
struct iovec iovec[5];
const struct ucred *ucred) {
struct iovec iovec[5];
- char header_priority[6], header_pid[16];
+ char header_priority[DECIMAL_STR_MAX(priority) + 3],
+ header_pid[sizeof("[]: ")-1 + DECIMAL_STR_MAX(pid_t) + 1];
int n = 0;
char *ident_buf = NULL;
int n = 0;
char *ident_buf = NULL;
@@
-60,8
+61,7
@@
void server_forward_kmsg(
priority = syslog_fixup_facility(priority);
/* First: priority field */
priority = syslog_fixup_facility(priority);
/* First: priority field */
- snprintf(header_priority, sizeof(header_priority), "<%i>", priority);
- char_array_0(header_priority);
+ xsprintf(header_priority, "<%i>", priority);
IOVEC_SET_STRING(iovec[n++], header_priority);
/* Second: identifier and PID */
IOVEC_SET_STRING(iovec[n++], header_priority);
/* Second: identifier and PID */
@@
-71,8
+71,7
@@
void server_forward_kmsg(
identifier = ident_buf;
}
identifier = ident_buf;
}
- snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", ucred->pid);
- char_array_0(header_pid);
+ xsprintf(header_pid, "["PID_FMT"]: ", ucred->pid);
if (identifier)
IOVEC_SET_STRING(iovec[n++], identifier);
if (identifier)
IOVEC_SET_STRING(iovec[n++], identifier);
@@
-88,7
+87,7
@@
void server_forward_kmsg(
IOVEC_SET_STRING(iovec[n++], "\n");
if (writev(s->dev_kmsg_fd, iovec, n) < 0)
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);
}
free(ident_buf);
}
@@
-342,7
+341,7
@@
static int server_read_dev_kmsg(Server *s) {
if (errno == EAGAIN || errno == EINTR || errno == EPIPE)
return 0;
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;
}
return -errno;
}
@@
-413,13
+412,13
@@
int server_open_dev_kmsg(Server *s) {
goto fail;
}
goto fail;
}
- log_error
("Failed to add /dev/kmsg fd to event loop: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to add /dev/kmsg fd to event loop: %m"
);
goto fail;
}
r = sd_event_source_set_priority(s->dev_kmsg_event_source, SD_EVENT_PRIORITY_IMPORTANT+10);
if (r < 0) {
goto fail;
}
r = sd_event_source_set_priority(s->dev_kmsg_event_source, SD_EVENT_PRIORITY_IMPORTANT+10);
if (r < 0) {
- log_error
("Failed to adjust priority of kmsg event source: %s", strerror(-r)
);
+ log_error
_errno(r, "Failed to adjust priority of kmsg event source: %m"
);
goto fail;
}
goto fail;
}
@@
-446,18
+445,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) {
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) {
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) {
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;
}
return 0;
}