summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-25 17:29:14 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-26 19:45:10 -0500
commitcc4419ed929b5c7c99eaed020b015b1b2e8c7a66 (patch)
tree5af5baddbdf72d8f129256c2b76cc18a03a9d296 /src
parent7bbf2d84234db8f9dd39604a367dc56a8f5455c7 (diff)
downloadsystemd-cc4419ed929b5c7c99eaed020b015b1b2e8c7a66.tar.gz
coredumpctl,man: mark truncated messages as such in output
Unit systemd-coredump@1-3854-0.service is failed/failed, not counting it. TIME PID UID GID SIG COREFILE EXE Fri 2017-02-24 11:11:00 EST 10002 1000 1000 6 none /home/zbyszek/src/systemd-work/.libs/lt-Sat 2017-02-25 00:49:32 EST 26921 0 0 11 error /usr/libexec/fprintd Sat 2017-02-25 11:56:30 EST 30703 1000 1000 - - /usr/bin/python3.5 Sat 2017-02-25 13:16:54 EST 3275 1000 1000 11 present /usr/bin/bash Sat 2017-02-25 17:25:40 EST 4049 1000 1000 11 truncated /usr/bin/bash For info and gdb output, the filename is marked in red and "(truncated)" is appended. (Red is necessary because the annotation is hard to see when running under a pager.) Fixed #3883.
Diffstat (limited to 'src')
-rw-r--r--src/coredump/coredump.c6
-rw-r--r--src/coredump/coredumpctl.c34
2 files changed, 29 insertions, 11 deletions
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index 855f0e9330..9e7206cc6a 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -325,7 +325,7 @@ static int save_external_coredump(
int *ret_node_fd,
int *ret_data_fd,
uint64_t *ret_size,
- bool *truncated) {
+ bool *ret_truncated) {
_cleanup_free_ char *fn = NULL, *tmp = NULL;
_cleanup_close_ int fd = -1;
@@ -374,8 +374,8 @@ static int save_external_coredump(
log_error_errno(r, "Cannot store coredump of %s (%s): %m", context[CONTEXT_PID], context[CONTEXT_COMM]);
goto fail;
}
- *truncated = r == 1;
- if (*truncated)
+ *ret_truncated = r == 1;
+ if (*ret_truncated)
log_struct(LOG_INFO,
LOG_MESSAGE("Core file was truncated to %zu bytes.", max_size),
"SIZE_LIMIT=%zu", max_size,
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 810d4f95a4..5237e2e069 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -343,7 +343,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
_cleanup_free_ char
*mid = NULL, *pid = NULL, *uid = NULL, *gid = NULL,
*sgnl = NULL, *exe = NULL, *comm = NULL, *cmdline = NULL,
- *filename = NULL, *coredump = NULL;
+ *filename = NULL, *truncated = NULL, *coredump = NULL;
const void *d;
size_t l;
usec_t t;
@@ -365,6 +365,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
RETRIEVE(d, l, "COREDUMP_COMM", comm);
RETRIEVE(d, l, "COREDUMP_CMDLINE", cmdline);
RETRIEVE(d, l, "COREDUMP_FILENAME", filename);
+ RETRIEVE(d, l, "COREDUMP_TRUNCATED", truncated);
RETRIEVE(d, l, "COREDUMP", coredump);
}
@@ -380,13 +381,13 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
format_timestamp(buf, sizeof(buf), t);
if (!had_legend && !arg_no_legend)
- fprintf(file, "%-*s %*s %*s %*s %*s %*s %s\n",
+ fprintf(file, "%-*s %*s %*s %*s %*s %-*s %s\n",
FORMAT_TIMESTAMP_WIDTH, "TIME",
6, "PID",
5, "UID",
5, "GID",
3, "SIG",
- 8, "COREFILE",
+ 9, "COREFILE",
"EXE");
normal_coredump = streq_ptr(mid, SD_MESSAGE_COREDUMP_STR);
@@ -405,13 +406,16 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
else
present = "-";
+ if (STR_IN_SET(present, "present", "journal") && streq_ptr(truncated, "yes"))
+ present = "truncated";
+
fprintf(file, "%-*s %*s %*s %*s %*s %-*s %s\n",
FORMAT_TIMESTAMP_WIDTH, buf,
6, strna(pid),
5, strna(uid),
5, strna(gid),
3, normal_coredump ? strna(sgnl) : "-",
- 8, present,
+ 9, present,
strna(exe ?: (comm ?: cmdline)));
return 0;
@@ -425,7 +429,7 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
*boot_id = NULL, *machine_id = NULL, *hostname = NULL,
*slice = NULL, *cgroup = NULL, *owner_uid = NULL,
*message = NULL, *timestamp = NULL, *filename = NULL,
- *coredump = NULL;
+ *truncated = NULL, *coredump = NULL;
const void *d;
size_t l;
bool normal_coredump;
@@ -451,6 +455,7 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
RETRIEVE(d, l, "COREDUMP_CGROUP", cgroup);
RETRIEVE(d, l, "COREDUMP_TIMESTAMP", timestamp);
RETRIEVE(d, l, "COREDUMP_FILENAME", filename);
+ RETRIEVE(d, l, "COREDUMP_TRUNCATED", truncated);
RETRIEVE(d, l, "COREDUMP", coredump);
RETRIEVE(d, l, "_BOOT_ID", boot_id);
RETRIEVE(d, l, "_MACHINE_ID", machine_id);
@@ -569,9 +574,22 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
if (hostname)
fprintf(file, " Hostname: %s\n", hostname);
- if (filename)
- fprintf(file, " Storage: %s%s\n", filename,
- access(filename, R_OK) < 0 ? " (inaccessible)" : "");
+ if (filename) {
+ bool inacc = access(filename, R_OK) < 0;
+ bool trunc = streq_ptr(truncated, "yes");
+
+ if (inacc || trunc)
+ fprintf(file, " Storage: %s%s (%s%s%s)%s\n",
+ ansi_highlight_red(),
+ filename,
+ inacc ? "inaccessible" : "",
+ inacc && trunc ? ", " : "",
+ trunc ? "truncated" : "",
+ ansi_normal());
+ else
+ fprintf(file, " Storage: %s\n", filename);
+ }
+
else if (coredump)
fprintf(file, " Storage: journal\n");
else