|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
From 634a6893abd524b5ccae0c9b8cd0957fa00abb24 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
Date: Fri, 18 Jul 2014 21:44:36 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
Subject: [PATCH] man,journal: add note about
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
sd_journal_get_cutoff_monotonic_usec return value
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
Also modify the function itself to be a bit simpler to read.
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
(cherry picked from commit 1651e2c61e544de9ca947c8b3202552b1272ef57)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
man/sd_journal_get_cutoff_realtime_usec.xml | 36 ++++++++++++++++++-----------
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
src/journal/sd-journal.c | 16 ++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
2 files changed, 31 insertions(+), 21 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
diff --git a/man/sd_journal_get_cutoff_realtime_usec.xml b/man/sd_journal_get_cutoff_realtime_usec.xml
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
index 6df4b26e6f..ef987d85b0 100644
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
--- a/man/sd_journal_get_cutoff_realtime_usec.xml
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+++ b/man/sd_journal_get_cutoff_realtime_usec.xml
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
@@ -74,25 +74,29 @@
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
<title>Description</title>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
<para><function>sd_journal_get_cutoff_realtime_usec()</function>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- gets the realtime (wallclock) timestamps of the first
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- and last entries accessible in the journal. It takes
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- three arguments: the journal context object and two
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- pointers to 64-bit unsigned integers to store the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- timestamps in. The timestamps are in microseconds
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- since the epoch,
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ retrieves the realtime (wallclock) timestamps of the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ first and last entries accessible in the journal. It
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ takes three arguments: the journal context object
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>j</parameter> and two pointers
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>from</parameter> and
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>to</parameter> pointing at 64-bit unsigned
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ integers to store the timestamps in. The timestamps
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ are in microseconds since the epoch,
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
i.e. <constant>CLOCK_REALTIME</constant>. Either one
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
of the two timestamp arguments may be passed as
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
<constant>NULL</constant> in case the timestamp is not
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
needed, but not both.</para>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
<para><function>sd_journal_get_cutoff_monotonic_usec()</function>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- gets the monotonic timestamps of the first and last
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- entries accessible in the journal. It takes three
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- arguments: the journal context object, a 128-bit
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- identifier for the boot, and two pointers to 64-bit
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- unsigned integers to store the timestamps. The
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- timestamps are in microseconds since boot-up of the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- specific boot,
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ retrieves the monotonic timestamps of the first and
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ last entries accessible in the journal. It takes three
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ arguments: the journal context object
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>j</parameter>, a 128-bit identifier for the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ boot <parameter>boot_id</parameter>, and two pointers
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ to 64-bit unsigned integers to store the timestamps,
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>from</parameter> and
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>to</parameter>. The timestamps are in
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ microseconds since boot-up of the specific boot,
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
i.e. <constant>CLOCK_MONOTONIC</constant>. Since the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
monotonic clock begins new with every reboot it only
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
defines a well-defined point in time when used
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
@@ -113,6 +117,12 @@
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
<function>sd_journal_get_cutoff_monotonic_usec()</function>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
return 1 on success, 0 if not suitable entries are in
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
the journal or a negative errno-style error code.</para>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <para>Locations pointed to by parameters
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>from</parameter> and
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ <parameter>to</parameter> will be set only if the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ return value is positive, and obviously, the
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ parameters are non-null.</para>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
</refsect1>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
<refsect1>
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
index ca805f83fe..15dae90925 100644
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
--- a/src/journal/sd-journal.c
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+++ b/src/journal/sd-journal.c
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
@@ -2390,7 +2390,7 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) {
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
Iterator i;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
JournalFile *f;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- bool first = true;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ bool found = false;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
assert_return(j, -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
@@ -2409,21 +2409,21 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
if (r == 0)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- if (first) {
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ if (found) {
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
if (from)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- *from = fr;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ *from = MIN(fr, *from);
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
if (to)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- *to = t;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- first = false;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ *to = MAX(t, *to);
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
if (from)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- *from = MIN(fr, *from);
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ *from = fr;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
if (to)
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- *to = MAX(t, *to);
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ *to = t;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ found = true;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
- return first ? 0 : 1;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
+ return found;
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
|
|
Zbigniew Jędrzejewski-Szmek |
43ff24 |
void journal_print_header(sd_journal *j) {
|