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
70 beginning of the journal, i.e. the oldest available entry.
</para>
72 <para>Similarly,
<function>sd_journal_seek_tail()
</function> may
73 be used to seek to the end of the journal, i.e. the most recent
74 available entry.
</para>
76 <para><function>sd_journal_seek_monotonic_usec()
</function> seeks
77 to the entry with the specified monotonic timestamp, i.e.
78 <constant>CLOCK_MONOTONIC
</constant>. Since monotonic time
79 restarts on every reboot a boot ID needs to be specified as
82 <para><function>sd_journal_seek_realtime_usec()
</function> seeks
83 to the entry with the specified realtime (wallclock) timestamp,
84 i.e.
<constant>CLOCK_REALTIME
</constant>. Note that the realtime
85 clock is not necessarily monotonic. If a realtime timestamp is
86 ambiguous, it is not defined which position is sought to.
</para>
88 <para><function>sd_journal_seek_cursor()
</function> seeks to the
89 entry located at the specified cursor string. For details on
91 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
92 If no entry matching the specified cursor is found the call will
93 seek to the next closest entry (in terms of time) instead. To
94 verify whether the newly selected entry actually matches the
96 <citerefentry><refentrytitle>sd_journal_test_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
98 <para>Note that these calls do not actually make any entry the new
99 current entry, this needs to be done in a separate step with a
101 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
102 invocation (or a similar call). Only then, entry data may be
104 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
105 If no entry exists that matches exactly the specified seek
106 address, the next closest is sought to. If
107 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
108 is used, the closest following entry will be sought to, if
109 <citerefentry><refentrytitle>sd_journal_previous
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
110 is used the closest preceding entry is sought to.
</para>
114 <title>Return Value
</title>
116 <para>The functions return
0 on success or a negative errno-style
123 <para>All functions listed here are thread-agnostic and only a single thread may operate
124 on a given
<structname>sd_journal
</structname> object.
</para>
126 <xi:include href=
"libsystemd-pkgconfig.xml" xpointer=
"pkgconfig-text"/>
130 <title>See Also
</title>
133 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>sd-journal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>sd_journal_open
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
139 <citerefentry><refentrytitle>sd_journal_get_realtime_usec
</refentrytitle><manvolnum>3</manvolnum></citerefentry>