summaryrefslogtreecommitdiff
path: root/src/journal/journal-file.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-19 15:15:59 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-19 15:16:11 +0200
commitfc89a13992384ab8d8fb0c937b021434123bbc49 (patch)
tree6cd0136ce58b336caf800fb0406de867b3933a06 /src/journal/journal-file.h
parent84168d8068bb67dcd5468ab3b376535d81643aef (diff)
journal: validate timestamps as well
Diffstat (limited to 'src/journal/journal-file.h')
-rw-r--r--src/journal/journal-file.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index e2ef03347c..7358173e7a 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -119,6 +119,21 @@ int journal_file_open_reliably(
#define ALIGN64(x) (((x) + 7ULL) & ~7ULL)
#define VALID64(x) (((x) & 7ULL) == 0ULL)
+static inline bool VALID_REALTIME(uint64_t u) {
+ /* This considers timestamps until the year 3112 valid. That should be plenty room... */
+ return u > 0 && u < (1ULL << 55);
+}
+
+static inline bool VALID_MONOTONIC(uint64_t u) {
+ /* This considers timestamps until 1142 years of runtime valid. */
+ return u < (1ULL << 55);
+}
+
+static inline bool VALID_EPOCH(uint64_t u) {
+ /* This allows changing the key for 1142 years, every usec. */
+ return u < (1ULL << 55);
+}
+
#define JOURNAL_HEADER_CONTAINS(h, field) \
(le64toh((h)->header_size) >= offsetof(Header, field) + sizeof((h)->field))