1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
9 <refentry id=
"sd_journal_seek_head" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
12 <title>sd_journal_seek_head
</title>
13 <productname>systemd
</productname>
17 <refentrytitle>sd_journal_seek_head
</refentrytitle>
18 <manvolnum>3</manvolnum>
22 <refname>sd_journal_seek_head
</refname>
23 <refname>sd_journal_seek_tail
</refname>
24 <refname>sd_journal_seek_monotonic_usec
</refname>
25 <refname>sd_journal_seek_realtime_usec
</refname>
26 <refname>sd_journal_seek_cursor
</refname>
27 <refpurpose>Seek to a position in the
33 <funcsynopsisinfo>#include
<systemd/sd-journal.h
></funcsynopsisinfo>
36 <funcdef>int
<function>sd_journal_seek_head
</function></funcdef>
37 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
41 <funcdef>int
<function>sd_journal_seek_tail
</function></funcdef>
42 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
46 <funcdef>int
<function>sd_journal_seek_monotonic_usec
</function></funcdef>
47 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
48 <paramdef>sd_id128_t
<parameter>boot_id
</parameter></paramdef>
49 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
53 <funcdef>int
<function>sd_journal_seek_realtime_usec
</function></funcdef>
54 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
55 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
59 <funcdef>int
<function>sd_journal_seek_cursor
</function></funcdef>
60 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
61 <paramdef>const char *
<parameter>cursor
</parameter></paramdef>
67 <title>Description
</title>
69 <para><function>sd_journal_seek_head()
</function> seeks to the beginning of the journal, i.e. to the
70 position before the oldest available entry.
</para>
72 <para>Similarly,
<function>sd_journal_seek_tail()
</function> may be used to seek to the end of the
73 journal, i.e. the position after the most recent available entry.
</para>
75 <para><function>sd_journal_seek_monotonic_usec()
</function> seeks to a position with the specified
76 monotonic timestamp, i.e.
<constant>CLOCK_MONOTONIC
</constant>. Since monotonic time restarts on every
77 reboot a boot ID needs to be specified as well.
</para>
79 <para><function>sd_journal_seek_realtime_usec()
</function> seeks to a position with the specified
80 realtime (wallclock) timestamp, i.e.
<constant>CLOCK_REALTIME
</constant>. Note that the realtime clock is
81 not necessarily monotonic. If a realtime timestamp is ambiguous, it is not defined which position is
84 <para><function>sd_journal_seek_cursor()
</function> seeks to the position at the specified cursor
85 string. For details on cursors, see
86 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
87 If no entry matching the specified cursor is found the call will seek to the next closest entry (in terms
88 of time) instead. To verify whether the newly selected entry actually matches the cursor, use
89 <citerefentry><refentrytitle>sd_journal_test_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
91 <para>Note that these calls do not actually make any entry the new current entry, this needs to be done
92 in a separate step with a subsequent
93 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
94 invocation (or a similar call). Only then, entry data may be retrieved via
95 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
96 or an entry cursor be retrieved via
97 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
98 If no entry exists that matches exactly the specified seek address, the next closest is sought to. If
99 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry> is
100 used, the closest following entry will be sought to, if
101 <citerefentry><refentrytitle>sd_journal_previous
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
102 is used the closest preceding entry is sought to.
</para>
106 <title>Return Value
</title>
108 <para>The functions return
0 on success or a negative errno-style
115 <xi:include href=
"threads-aware.xml" xpointer=
"strict"/>
117 <xi:include href=
"libsystemd-pkgconfig.xml" xpointer=
"pkgconfig-text"/>
121 <title>See Also
</title>
124 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
125 <citerefentry><refentrytitle>sd-journal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
126 <citerefentry><refentrytitle>sd_journal_open
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
127 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
128 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
129 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>sd_journal_get_realtime_usec
</refentrytitle><manvolnum>3</manvolnum></citerefentry>