mirror of
https://github.com/AuxXxilium/eudev.git
synced 2025-03-09 15:14:01 +07:00
coredumpctl: show timestamps in list
This commit is contained in:
parent
34741aa3e2
commit
684341b073
@ -232,12 +232,15 @@ static int retrieve(const void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_entry(FILE* file, sd_journal *j, int had_header) {
|
||||
static int print_entry(FILE* file, sd_journal *j, int had_header) {
|
||||
const char _cleanup_free_
|
||||
*pid = NULL, *uid = NULL, *gid = NULL,
|
||||
*sgnl = NULL, *exe = NULL;
|
||||
const void *d;
|
||||
size_t l;
|
||||
usec_t t;
|
||||
char buf[FORMAT_TIMESTAMP_MAX];
|
||||
int r;
|
||||
|
||||
SD_JOURNAL_FOREACH_DATA(j, d, l) {
|
||||
retrieve(d, l, "COREDUMP_PID", &pid);
|
||||
@ -253,24 +256,36 @@ static void print_entry(FILE* file, sd_journal *j, int had_header) {
|
||||
}
|
||||
|
||||
if (!pid && !uid && !gid && !sgnl && !exe) {
|
||||
log_warning("empty coredump log entry");
|
||||
return;
|
||||
log_warning("Empty coredump log entry");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = sd_journal_get_realtime_usec(j, &t);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get realtime timestamp: %s", strerror(-r));
|
||||
return r;
|
||||
}
|
||||
|
||||
format_timestamp(buf, sizeof(buf), t);
|
||||
|
||||
if (!had_header)
|
||||
fprintf(file, "%*s %*s %*s %*s %s\n",
|
||||
fprintf(file, "%-*s %*s %*s %*s %*s %s\n",
|
||||
FORMAT_TIMESTAMP_MAX-1, "TIME",
|
||||
6, "PID",
|
||||
5, "UID",
|
||||
5, "GID",
|
||||
3, "sig",
|
||||
"exe");
|
||||
3, "SIG",
|
||||
"EXE");
|
||||
|
||||
fprintf(file, "%*s %*s %*s %*s %s\n",
|
||||
fprintf(file, "%*s %*s %*s %*s %*s %s\n",
|
||||
FORMAT_TIMESTAMP_MAX-1, buf,
|
||||
6, pid,
|
||||
5, uid,
|
||||
5, gid,
|
||||
3, sgnl,
|
||||
exe);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_list(sd_journal *j) {
|
||||
@ -282,7 +297,7 @@ static int dump_list(sd_journal *j) {
|
||||
print_entry(stdout, j, found++);
|
||||
|
||||
if (!found) {
|
||||
log_error("no coredumps found");
|
||||
log_notice("No coredumps found");
|
||||
return -ESRCH;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ union dirent_storage {
|
||||
#define QUOTES "\"\'"
|
||||
#define COMMENTS "#;\n"
|
||||
|
||||
#define FORMAT_TIMESTAMP_MAX 64
|
||||
#define FORMAT_TIMESTAMP_MAX (5+11+9+4+1)
|
||||
#define FORMAT_TIMESTAMP_PRETTY_MAX 256
|
||||
#define FORMAT_TIMESPAN_MAX 64
|
||||
#define FORMAT_BYTES_MAX 8
|
||||
|
Loading…
Reference in New Issue
Block a user