diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-06-18 08:48:14 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-06-18 08:50:08 -0400 |
commit | 718fe4b1d50f89cbc11318edb0c2c3de9be2ac34 (patch) | |
tree | d8c3be55dfce177b98018ea130afaebcf5cb4e85 /src/journal/journal-file.c | |
parent | 214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7 (diff) |
journalctl: properly print headers of empty journals
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r-- | src/journal/journal-file.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index ca217f93fe..12364030d9 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -2270,6 +2270,15 @@ fail: log_error("File corrupt"); } +static const char* format_timestamp_safe(char *buf, size_t l, usec_t t) { + const char *x; + + x = format_timestamp(buf, l, t); + if (x) + return x; + return " --- "; +} + void journal_file_print_header(JournalFile *f) { char a[33], b[33], c[33], d[33]; char x[FORMAT_TIMESTAMP_MAX], y[FORMAT_TIMESTAMP_MAX], z[FORMAT_TIMESTAMP_MAX]; @@ -2317,8 +2326,8 @@ void journal_file_print_header(JournalFile *f) { yes_no(journal_file_rotate_suggested(f, 0)), le64toh(f->header->head_entry_seqnum), le64toh(f->header->tail_entry_seqnum), - format_timestamp(x, sizeof(x), le64toh(f->header->head_entry_realtime)), - format_timestamp(y, sizeof(y), le64toh(f->header->tail_entry_realtime)), + format_timestamp_safe(x, sizeof(x), le64toh(f->header->head_entry_realtime)), + format_timestamp_safe(y, sizeof(y), le64toh(f->header->tail_entry_realtime)), format_timespan(z, sizeof(z), le64toh(f->header->tail_entry_monotonic), USEC_PER_MSEC), le64toh(f->header->n_objects), le64toh(f->header->n_entries)); |