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 This file is part of systemd.
8 Copyright 2012 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_journal_seek_head">
27 <title>sd_journal_seek_head</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_journal_seek_head</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_journal_seek_head</refname>
47 <refname>sd_journal_seek_tail</refname>
48 <refname>sd_journal_seek_monotonic_usec</refname>
49 <refname>sd_journal_seek_realtime_usec</refname>
50 <refname>sd_journal_seek_cursor</refname>
51 <refpurpose>Seek to a position in the
57 <funcsynopsisinfo>#include <systemd/sd-journal.h></funcsynopsisinfo>
60 <funcdef>int <function>sd_journal_seek_head</function></funcdef>
61 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
65 <funcdef>int <function>sd_journal_seek_tail</function></funcdef>
66 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
70 <funcdef>int <function>sd_journal_seek_monotonic_usec</function></funcdef>
71 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
72 <paramdef>sd_id128_t <parameter>boot_id</parameter></paramdef>
73 <paramdef>uint64_t <parameter>usec</parameter></paramdef>
77 <funcdef>int <function>sd_journal_seek_realtime_usec</function></funcdef>
78 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
79 <paramdef>uint64_t <parameter>usec</parameter></paramdef>
83 <funcdef>int <function>sd_journal_seek_cursor</function></funcdef>
84 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
85 <paramdef>const char *<parameter>cursor</parameter></paramdef>
91 <title>Description</title>
93 <para><function>sd_journal_seek_head()</function>
94 seeks to the beginning of the journal, i.e. the oldest
95 available entry.</para>
98 <function>sd_journal_seek_tail()</function> may be
99 used to seek to the end of the journal, i.e. the most
100 recent available entry.</para>
102 <para><function>sd_journal_seek_monotonic_usec()</function>
103 seeks to the entry with the specified monotonic
105 i.e. <constant>CLOCK_MONOTONIC</constant>. Since
106 monotonic time restarts on every reboot a boot ID
107 needs to be specified as well.</para>
109 <para><function>sd_journal_seek_realtime_usec()</function>
110 seeks to the entry with the specified realtime
111 (wallclock) timestamp,
112 i.e. <constant>CLOCK_REALTIME</constant>. Note that
113 the realtime clock is not necessarily monotonic. If a
114 realtime timestamp is ambiguous, it is not defined
115 which position is sought to.</para>
117 <para><function>sd_journal_seek_cursor()</function>
118 seeks to the entry located at the specified cursor
119 string. For details on cursors, see
120 <citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If
121 no entry matching the specified cursor is found the
122 call will seek to the next closest entry (in terms of
123 time) instead. To verify whether the newly selected
124 entry actually matches the cursor, use
125 <citerefentry><refentrytitle>sd_journal_test_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
127 <para>Note that these calls do not actually make any
128 entry the new current entry, this needs to be done in
129 a separate step with a subsequent
130 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
131 invocation (or a similar call). Only then, entry data
133 <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If
134 no entry exists that matches exactly the specified
135 seek address, the next closest is sought to. If
136 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
137 is used, the closest following entry will be sought to,
139 <citerefentry><refentrytitle>sd_journal_previous</refentrytitle><manvolnum>3</manvolnum></citerefentry>
140 is used the closest preceding entry is sought
145 <title>Return Value</title>
147 <para>The functions return 0 on success or a negative
148 errno-style error code.</para>
154 <para>The <function>sd_journal_seek_head()</function>,
155 <function>sd_journal_seek_tail()</function>,
156 <function>sd_journal_seek_monotonic_usec()</function>,
157 <function>sd_journal_seek_realtime_usec()</function>,
158 and <function>sd_journal_seek_cursor()</function>
159 interfaces are available as a shared library, which can
160 be compiled and linked to with the
161 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
166 <title>See Also</title>
169 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
172 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
173 <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
174 <citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
175 <citerefentry><refentrytitle>sd_journal_get_realtime_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>