Skip to content

Commit ed375be

Browse files
committed
journalctl: print monotonic timestamp in --header
1 parent 2765b7b commit ed375be

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

src/journal/journal-file.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ void journal_file_dump(JournalFile *f) {
22722272

22732273
void journal_file_print_header(JournalFile *f) {
22742274
char a[33], b[33], c[33], d[33];
2275-
char x[FORMAT_TIMESTAMP_MAX], y[FORMAT_TIMESTAMP_MAX];
2275+
char x[FORMAT_TIMESTAMP_MAX], y[FORMAT_TIMESTAMP_MAX], z[FORMAT_TIMESTAMP_MAX];
22762276
struct stat st;
22772277
char bytes[FORMAT_BYTES_MAX];
22782278

@@ -2295,6 +2295,7 @@ void journal_file_print_header(JournalFile *f) {
22952295
"Tail Sequential Number: %"PRIu64"\n"
22962296
"Head Realtime Timestamp: %s\n"
22972297
"Tail Realtime Timestamp: %s\n"
2298+
"Tail Monotonic Timestamp: %s\n"
22982299
"Objects: %"PRIu64"\n"
22992300
"Entry Objects: %"PRIu64"\n",
23002301
f->path,
@@ -2318,6 +2319,7 @@ void journal_file_print_header(JournalFile *f) {
23182319
le64toh(f->header->tail_entry_seqnum),
23192320
format_timestamp(x, sizeof(x), le64toh(f->header->head_entry_realtime)),
23202321
format_timestamp(y, sizeof(y), le64toh(f->header->tail_entry_realtime)),
2322+
format_timespan(z, sizeof(z), le64toh(f->header->tail_entry_monotonic), USEC_PER_MSEC),
23212323
le64toh(f->header->n_objects),
23222324
le64toh(f->header->n_entries));
23232325

@@ -2596,7 +2598,7 @@ int journal_file_open_reliably(
25962598

25972599
int r;
25982600
size_t l;
2599-
char *p;
2601+
_cleanup_free_ char *p = NULL;
26002602

26012603
r = journal_file_open(fname, flags, mode, compress, seal,
26022604
metrics, mmap_cache, template, ret);
@@ -2627,7 +2629,6 @@ int journal_file_open_reliably(
26272629
return -ENOMEM;
26282630

26292631
r = rename(fname, p);
2630-
free(p);
26312632
if (r < 0)
26322633
return -errno;
26332634

src/journal/journald-server.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
245245
}
246246

247247
static JournalFile* find_journal(Server *s, uid_t uid) {
248-
char *p;
248+
_cleanup_free_ char *p = NULL;
249249
int r;
250250
JournalFile *f;
251251
sd_id128_t machine;
@@ -283,8 +283,6 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
283283
}
284284

285285
r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, s->system_journal, &f);
286-
free(p);
287-
288286
if (r < 0)
289287
return s->system_journal;
290288

@@ -372,7 +370,6 @@ void server_sync(Server *s) {
372370
}
373371

374372
void server_vacuum(Server *s) {
375-
char *p;
376373
char ids[33];
377374
sd_id128_t machine;
378375
int r;
@@ -390,29 +387,19 @@ void server_vacuum(Server *s) {
390387
sd_id128_to_string(machine, ids);
391388

392389
if (s->system_journal) {
393-
p = strappend("/var/log/journal/", ids);
394-
if (!p) {
395-
log_oom();
396-
return;
397-
}
390+
char *p = strappenda("/var/log/journal/", ids);
398391

399392
r = journal_directory_vacuum(p, s->system_metrics.max_use, s->system_metrics.keep_free, s->max_retention_usec, &s->oldest_file_usec);
400393
if (r < 0 && r != -ENOENT)
401394
log_error("Failed to vacuum %s: %s", p, strerror(-r));
402-
free(p);
403395
}
404396

405397
if (s->runtime_journal) {
406-
p = strappend("/run/log/journal/", ids);
407-
if (!p) {
408-
log_oom();
409-
return;
410-
}
398+
char *p = strappenda("/run/log/journal/", ids);
411399

412400
r = journal_directory_vacuum(p, s->runtime_metrics.max_use, s->runtime_metrics.keep_free, s->max_retention_usec, &s->oldest_file_usec);
413401
if (r < 0 && r != -ENOENT)
414402
log_error("Failed to vacuum %s: %s", p, strerror(-r));
415-
free(p);
416403
}
417404

418405
s->cached_available_space_timestamp = 0;

0 commit comments

Comments
 (0)