[systemd-devel] [PATCH 09/17] journalctl: print monotonic timestamp in --header
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Fri Jun 7 21:22:41 PDT 2013
---
src/journal/journal-file.c | 6 ++++--
src/journal/journald-server.c | 19 +++----------------
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 073e4a4..b3c9a92 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2294,6 +2294,7 @@ void journal_file_print_header(JournalFile *f) {
"Tail Sequential Number: %"PRIu64"\n"
"Head Realtime Timestamp: %s\n"
"Tail Realtime Timestamp: %s\n"
+ "Tail Monotonic Timestamp: %5llu.%06llu s\n"
"Objects: %"PRIu64"\n"
"Entry Objects: %"PRIu64"\n",
f->path,
@@ -2317,6 +2318,8 @@ void journal_file_print_header(JournalFile *f) {
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)),
+ le64toh(f->header->tail_entry_monotonic) / USEC_PER_SEC,
+ le64toh(f->header->tail_entry_monotonic) % USEC_PER_SEC,
le64toh(f->header->n_objects),
le64toh(f->header->n_entries));
@@ -2595,7 +2598,7 @@ int journal_file_open_reliably(
int r;
size_t l;
- char *p;
+ _cleanup_free_ char *p = NULL;
r = journal_file_open(fname, flags, mode, compress, seal,
metrics, mmap_cache, template, ret);
@@ -2626,7 +2629,6 @@ int journal_file_open_reliably(
return -ENOMEM;
r = rename(fname, p);
- free(p);
if (r < 0)
return -errno;
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index d46b290..1bb1f2d 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -244,7 +244,7 @@ finish:
}
static JournalFile* find_journal(Server *s, uid_t uid) {
- char *p;
+ _cleanup_free_ char *p = NULL;
int r;
JournalFile *f;
sd_id128_t machine;
@@ -282,8 +282,6 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
}
r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, s->system_journal, &f);
- free(p);
-
if (r < 0)
return s->system_journal;
@@ -371,7 +369,6 @@ void server_sync(Server *s) {
}
void server_vacuum(Server *s) {
- char *p;
char ids[33];
sd_id128_t machine;
int r;
@@ -389,29 +386,19 @@ void server_vacuum(Server *s) {
sd_id128_to_string(machine, ids);
if (s->system_journal) {
- p = strappend("/var/log/journal/", ids);
- if (!p) {
- log_oom();
- return;
- }
+ char *p = strappenda("/var/log/journal/", ids);
r = journal_directory_vacuum(p, s->system_metrics.max_use, s->system_metrics.keep_free, s->max_retention_usec, &s->oldest_file_usec);
if (r < 0 && r != -ENOENT)
log_error("Failed to vacuum %s: %s", p, strerror(-r));
- free(p);
}
if (s->runtime_journal) {
- p = strappend("/run/log/journal/", ids);
- if (!p) {
- log_oom();
- return;
- }
+ char *p = strappenda("/run/log/journal/", ids);
r = journal_directory_vacuum(p, s->runtime_metrics.max_use, s->runtime_metrics.keep_free, s->max_retention_usec, &s->oldest_file_usec);
if (r < 0 && r != -ENOENT)
log_error("Failed to vacuum %s: %s", p, strerror(-r));
- free(p);
}
s->cached_available_space_timestamp = 0;
--
1.8.2.562.g931e949
More information about the systemd-devel
mailing list