diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-06-18 10:36:51 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-06-18 10:57:40 +0200 |
commit | a9357c2ce2d188b5b63592fd271f14d335867c23 (patch) | |
tree | cef17050267a031e6a85bd87486b0ceab461aa0c | |
parent | sd-journal: realign flags (diff) | |
download | systemd-a9357c2ce2d188b5b63592fd271f14d335867c23.tar.xz systemd-a9357c2ce2d188b5b63592fd271f14d335867c23.zip |
journal: introduce _SOURCE_BOOTTIME_TIMESTAMP field
Then, fix the monotonic timestamp.
The _SOURCE_MONOTONIC_TIMESTAMP field is already used in other projects.
Hence, we cannot remove the field. But, let's store the correct value.
The existence of the new _SOURCE_BOOTTIME_TIMESTAMP field can indicate
that the monotonic timestamp field is reliable or not.
-rw-r--r-- | src/journal/journald-kmsg.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 78f6e1fef3..4123fda5f9 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -253,9 +253,17 @@ void dev_kmsg_record(Server *s, char *p, size_t l) { } } - char source_time[STRLEN("_SOURCE_MONOTONIC_TIMESTAMP=") + DECIMAL_STR_MAX(unsigned long long)]; - xsprintf(source_time, "_SOURCE_MONOTONIC_TIMESTAMP=%llu", usec); - iovec[n++] = IOVEC_MAKE_STRING(source_time); + char source_boot_time[STRLEN("_SOURCE_BOOTTIME_TIMESTAMP=") + DECIMAL_STR_MAX(unsigned long long)]; + xsprintf(source_boot_time, "_SOURCE_BOOTTIME_TIMESTAMP=%llu", usec); + iovec[n++] = IOVEC_MAKE_STRING(source_boot_time); + + /* Historically, we stored the timestamp 'usec' as _SOURCE_MONOTONIC_TIMESTAMP, so we cannot remove + * the field as it is already used in other projects. So, let's store the correct timestamp here by + * mapping the boottime to monotonic. Then, the existence of _SOURCE_BOOTTIME_TIMESTAMP indicates + * the reliability of _SOURCE_MONOTONIC_TIMESTAMP field. */ + char source_monotonic_time[STRLEN("_SOURCE_MONOTONIC_TIMESTAMP=") + DECIMAL_STR_MAX(unsigned long long)]; + xsprintf(source_monotonic_time, "_SOURCE_MONOTONIC_TIMESTAMP="USEC_FMT, map_clock_usec(usec, CLOCK_BOOTTIME, CLOCK_MONOTONIC)); + iovec[n++] = IOVEC_MAKE_STRING(source_monotonic_time); iovec[n++] = IOVEC_MAKE_STRING("_TRANSPORT=kernel"); |