1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id=
"sd_journal_seek_head" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
9 <title>sd_journal_seek_head
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>sd_journal_seek_head
</refentrytitle>
15 <manvolnum>3</manvolnum>
19 <refname>sd_journal_seek_head
</refname>
20 <refname>sd_journal_seek_tail
</refname>
21 <refname>sd_journal_seek_monotonic_usec
</refname>
22 <refname>sd_journal_seek_realtime_usec
</refname>
23 <refname>sd_journal_seek_cursor
</refname>
24 <refpurpose>Seek to a position in the
30 <funcsynopsisinfo>#include
<systemd/sd-journal.h
></funcsynopsisinfo>
33 <funcdef>int
<function>sd_journal_seek_head
</function></funcdef>
34 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
38 <funcdef>int
<function>sd_journal_seek_tail
</function></funcdef>
39 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
43 <funcdef>int
<function>sd_journal_seek_monotonic_usec
</function></funcdef>
44 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
45 <paramdef>sd_id128_t
<parameter>boot_id
</parameter></paramdef>
46 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
50 <funcdef>int
<function>sd_journal_seek_realtime_usec
</function></funcdef>
51 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
52 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
56 <funcdef>int
<function>sd_journal_seek_cursor
</function></funcdef>
57 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
58 <paramdef>const char *
<parameter>cursor
</parameter></paramdef>
64 <title>Description
</title>
66 <para><function>sd_journal_seek_head()
</function> seeks to the beginning of the journal, i.e. to the
67 position before the oldest available entry.
</para>
69 <para>Similarly,
<function>sd_journal_seek_tail()
</function> may be used to seek to the end of the
70 journal, i.e. the position after the most recent available entry.
</para>
72 <para><function>sd_journal_seek_monotonic_usec()
</function> seeks to a position with the specified
73 monotonic timestamp, i.e.
<constant>CLOCK_MONOTONIC
</constant>. Since monotonic time restarts on every
74 reboot a boot ID needs to be specified as well.
</para>
76 <para><function>sd_journal_seek_realtime_usec()
</function> seeks to a position with the specified
77 realtime (wallclock) timestamp, i.e.
<constant>CLOCK_REALTIME
</constant>. Note that the realtime clock is
78 not necessarily monotonic. If a realtime timestamp is ambiguous, it is not defined which position is
81 <para><function>sd_journal_seek_cursor()
</function> seeks to the position at the specified cursor
82 string. For details on cursors, see
83 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
84 If no entry matching the specified cursor is found the call will seek to the next closest entry (in terms
85 of time) instead.
</para>
87 <para>Note that these calls do not actually make any entry the new current entry, this needs to be done
88 in a separate step with a subsequent
89 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
90 invocation (or a similar call). Only then, entry data may be retrieved via
91 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
92 or an entry cursor be retrieved via
93 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
94 If no entry exists that matches exactly the specified seek address, the next closest is sought to. If
95 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry> is
96 used, the closest following entry will be sought to, if
97 <citerefentry><refentrytitle>sd_journal_previous
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
98 is used the closest preceding entry is sought to.
</para>
100 <para>After the seek is done, and
101 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
102 or a similar call has been made,
103 <citerefentry><refentrytitle>sd_journal_test_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
104 may be used to verify whether the newly selected entry actually matches the cursor.
109 <title>Return Value
</title>
111 <para>The functions return
0 on success or a negative errno-style
118 <xi:include href=
"threads-aware.xml" xpointer=
"strict"/>
120 <xi:include href=
"libsystemd-pkgconfig.xml" xpointer=
"pkgconfig-text"/>
124 <title>History
</title>
125 <para><function>sd_journal_seek_head()
</function>,
126 <function>sd_journal_seek_tail()
</function>,
127 <function>sd_journal_seek_monotonic_usec()
</function>,
128 <function>sd_journal_seek_realtime_usec()
</function>, and
129 <function>sd_journal_seek_cursor()
</function> were added in version
187.
</para>
133 <title>See Also
</title>
135 <para><simplelist type=
"inline">
136 <member><citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
137 <member><citerefentry><refentrytitle>sd-journal
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
138 <member><citerefentry><refentrytitle>sd_journal_open
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
139 <member><citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
140 <member><citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
141 <member><citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
142 <member><citerefentry><refentrytitle>sd_journal_get_realtime_usec
</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>