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 This file is part of systemd.
10 Copyright 2012 Lennart Poettering
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 <refentry id=
"sd_journal_seek_head">
29 <title>sd_journal_seek_head
</title>
30 <productname>systemd
</productname>
34 <contrib>Developer
</contrib>
35 <firstname>Lennart
</firstname>
36 <surname>Poettering
</surname>
37 <email>lennart@poettering.net
</email>
43 <refentrytitle>sd_journal_seek_head
</refentrytitle>
44 <manvolnum>3</manvolnum>
48 <refname>sd_journal_seek_head
</refname>
49 <refname>sd_journal_seek_tail
</refname>
50 <refname>sd_journal_seek_monotonic_usec
</refname>
51 <refname>sd_journal_seek_realtime_usec
</refname>
52 <refname>sd_journal_seek_cursor
</refname>
53 <refpurpose>Seek to a position in the
59 <funcsynopsisinfo>#include
<systemd/sd-journal.h
></funcsynopsisinfo>
62 <funcdef>int
<function>sd_journal_seek_head
</function></funcdef>
63 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
67 <funcdef>int
<function>sd_journal_seek_tail
</function></funcdef>
68 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
72 <funcdef>int
<function>sd_journal_seek_monotonic_usec
</function></funcdef>
73 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
74 <paramdef>sd_id128_t
<parameter>boot_id
</parameter></paramdef>
75 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
79 <funcdef>int
<function>sd_journal_seek_realtime_usec
</function></funcdef>
80 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
81 <paramdef>uint64_t
<parameter>usec
</parameter></paramdef>
85 <funcdef>int
<function>sd_journal_seek_cursor
</function></funcdef>
86 <paramdef>sd_journal *
<parameter>j
</parameter></paramdef>
87 <paramdef>const char *
<parameter>cursor
</parameter></paramdef>
93 <title>Description
</title>
95 <para><function>sd_journal_seek_head()
</function> seeks to the
96 beginning of the journal, i.e. the oldest available entry.
</para>
98 <para>Similarly,
<function>sd_journal_seek_tail()
</function> may
99 be used to seek to the end of the journal, i.e. the most recent
100 available entry.
</para>
102 <para><function>sd_journal_seek_monotonic_usec()
</function> seeks
103 to the entry with the specified monotonic timestamp, i.e.
104 <constant>CLOCK_MONOTONIC
</constant>. Since monotonic time
105 restarts on every reboot a boot ID needs to be specified as
108 <para><function>sd_journal_seek_realtime_usec()
</function> seeks
109 to the entry with the specified realtime (wallclock) timestamp,
110 i.e.
<constant>CLOCK_REALTIME
</constant>. Note that the realtime
111 clock is not necessarily monotonic. If a realtime timestamp is
112 ambiguous, it is not defined which position is sought to.
</para>
114 <para><function>sd_journal_seek_cursor()
</function> seeks to the
115 entry located at the specified cursor string. For details on
117 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
118 If no entry matching the specified cursor is found the call will
119 seek to the next closest entry (in terms of time) instead. To
120 verify whether the newly selected entry actually matches the
122 <citerefentry><refentrytitle>sd_journal_test_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
124 <para>Note that these calls do not actually make any entry the new
125 current entry, this needs to be done in a separate step with a
127 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
128 invocation (or a similar call). Only then, entry data may be
130 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
131 If no entry exists that matches exactly the specified seek
132 address, the next closest is sought to. If
133 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
134 is used, the closest following entry will be sought to, if
135 <citerefentry><refentrytitle>sd_journal_previous
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
136 is used the closest preceding entry is sought to.
</para>
140 <title>Return Value
</title>
142 <para>The functions return
0 on success or a negative errno-style
149 <para>All functions listed here are thread-agnostic and only a single thread may operate
150 on a given
<structname>sd_journal
</structname> object.
</para>
152 <para>The
<function>sd_journal_seek_head()
</function>,
153 <function>sd_journal_seek_tail()
</function>,
154 <function>sd_journal_seek_monotonic_usec()
</function>,
155 <function>sd_journal_seek_realtime_usec()
</function>,
156 and
<function>sd_journal_seek_cursor()
</function>
157 interfaces are available as a shared library, which can
158 be compiled and linked to with the
159 <constant>libsystemd
</constant> <citerefentry project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
164 <title>See Also
</title>
167 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
168 <citerefentry><refentrytitle>sd-journal
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
169 <citerefentry><refentrytitle>sd_journal_open
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>sd_journal_next
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>sd_journal_get_data
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
172 <citerefentry><refentrytitle>sd_journal_get_cursor
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
173 <citerefentry><refentrytitle>sd_journal_get_realtime_usec
</refentrytitle><manvolnum>3</manvolnum></citerefentry>