]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_journal_seek_head.xml
man: clarify that sd_journal_seek_head() seeks *before* the first entry
[thirdparty/systemd.git] / man / sd_journal_seek_head.xml
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">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_journal_seek_head" xmlns:xi="http://www.w3.org/2001/XInclude">
10
11 <refentryinfo>
12 <title>sd_journal_seek_head</title>
13 <productname>systemd</productname>
14 </refentryinfo>
15
16 <refmeta>
17 <refentrytitle>sd_journal_seek_head</refentrytitle>
18 <manvolnum>3</manvolnum>
19 </refmeta>
20
21 <refnamediv>
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
28 journal</refpurpose>
29 </refnamediv>
30
31 <refsynopsisdiv>
32 <funcsynopsis>
33 <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
34
35 <funcprototype>
36 <funcdef>int <function>sd_journal_seek_head</function></funcdef>
37 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
38 </funcprototype>
39
40 <funcprototype>
41 <funcdef>int <function>sd_journal_seek_tail</function></funcdef>
42 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
43 </funcprototype>
44
45 <funcprototype>
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>
50 </funcprototype>
51
52 <funcprototype>
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>
56 </funcprototype>
57
58 <funcprototype>
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>
62 </funcprototype>
63 </funcsynopsis>
64 </refsynopsisdiv>
65
66 <refsect1>
67 <title>Description</title>
68
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>
71
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>
74
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>
78
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
82 sought to.</para>
83
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>
90
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>
103 </refsect1>
104
105 <refsect1>
106 <title>Return Value</title>
107
108 <para>The functions return 0 on success or a negative errno-style
109 error code.</para>
110 </refsect1>
111
112 <refsect1>
113 <title>Notes</title>
114
115 <xi:include href="threads-aware.xml" xpointer="strict"/>
116
117 <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
118 </refsect1>
119
120 <refsect1>
121 <title>See Also</title>
122
123 <para>
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>
131 </para>
132 </refsect1>
133
134 </refentry>