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+
8 Copyright 2012 Lennart Poettering
11 <refentry id=
"sd_journal_seek_head" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
14 <title>sd_journal_seek_head
</title>
15 <productname>systemd
</productname>
19 <contrib>Developer
</contrib>
20 <firstname>Lennart
</firstname>
21 <surname>Poettering
</surname>
22 <email>lennart@poettering.net
</email>
28 <refentrytitle>sd_journal_seek_head
</refentrytitle>
29 <manvolnum>3</manvolnum>
33 <refname>sd_journal_seek_head
</refname>
34 <refname>sd_journal_seek_tail
</refname>
35 <refname>sd_journal_seek_monotonic_usec
</refname>
36 <refname>sd_journal_seek_realtime_usec
</refname>
37 <refname>sd_journal_seek_cursor
</refname>
38 <refpurpose>Seek to a position in the
44 <funcsynopsisinfo>#include
<systemd/sd-journal.h
></funcsynopsisinfo>
47 <funcdef>int
<function>sd_journal_seek_head
</function></funcdef>
48 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
52 <funcdef>int
<function>sd_journal_seek_tail
</function></funcdef>
53 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
57 <funcdef>int
<function>sd_journal_seek_monotonic_usec
</function></funcdef>
58 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
59 <paramdef>sd_id128_t
<parameter>boot_id
</parameter></paramdef>
60 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
64 <funcdef>int
<function>sd_journal_seek_realtime_usec
</function></funcdef>
65 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
66 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
70 <funcdef>int
<function>sd_journal_seek_cursor
</function></funcdef>
71 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
72 <paramdef>const char *
<parameter>cursor
</parameter></paramdef>
78 <title>Description
</title>
80 <para><function>sd_journal_seek_head()
</function> seeks to the
81 beginning of the journal, i.e. the oldest available entry.
</para>
83 <para>Similarly,
<function>sd_journal_seek_tail()
</function> may
84 be used to seek to the end of the journal, i.e. the most recent
85 available entry.
</para>
87 <para><function>sd_journal_seek_monotonic_usec()
</function> seeks
88 to the entry with the specified monotonic timestamp, i.e.
89 <constant>CLOCK_MONOTONIC
</constant>. Since monotonic time
90 restarts on every reboot a boot ID needs to be specified as
93 <para><function>sd_journal_seek_realtime_usec()
</function> seeks
94 to the entry with the specified realtime (wallclock) timestamp,
95 i.e.
<constant>CLOCK_REALTIME
</constant>. Note that the realtime
96 clock is not necessarily monotonic. If a realtime timestamp is
97 ambiguous, it is not defined which position is sought to.
</para>
99 <para><function>sd_journal_seek_cursor()
</function> seeks to the
100 entry located at the specified cursor string. For details on
102 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
103 If no entry matching the specified cursor is found the call will
104 seek to the next closest entry (in terms of time) instead. To
105 verify whether the newly selected entry actually matches the
107 <citerefentry><refentrytitle>sd_journal_test_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
109 <para>Note that these calls do not actually make any entry the new
110 current entry, this needs to be done in a separate step with a
112 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
113 invocation (or a similar call). Only then, entry data may be
115 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
116 If no entry exists that matches exactly the specified seek
117 address, the next closest is sought to. If
118 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
119 is used, the closest following entry will be sought to, if
120 <citerefentry><refentrytitle>sd_journal_previous
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
121 is used the closest preceding entry is sought to.
</para>
125 <title>Return Value
</title>
127 <para>The functions return
0 on success or a negative errno-style
134 <para>All functions listed here are thread-agnostic and only a single thread may operate
135 on a given
<structname>sd_journal
</structname> object.
</para>
137 <xi:include href=
"libsystemd-pkgconfig.xml" xpointer=
"pkgconfig-text"/>
141 <title>See Also
</title>
144 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
145 <citerefentry><refentrytitle>sd-journal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
146 <citerefentry><refentrytitle>sd_journal_open
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
147 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
148 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
149 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
150 <citerefentry><refentrytitle>sd_journal_get_realtime_usec
</refentrytitle><manvolnum>3</manvolnum></citerefentry>