sd_journal_seek_head.xml revision 12b42c76672a66c2d4ea7212c14f8f1b5a62b78d
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluem This file is part of systemd.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend Copyright 2012 Lennart Poettering
b4a00883f358625923365ca1560c96edec172a52sf systemd is free software; you can redistribute it and/or modify it
50c04f297d76a57ead2fa6b73845f7563b1fc788sf under the terms of the GNU Lesser General Public License as published by
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend the Free Software Foundation; either version 2.1 of the License, or
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend (at your option) any later version.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend systemd is distributed in the hope that it will be useful, but
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes WITHOUT ANY WARRANTY; without even the implied warranty of
909ce17e2bd0faef7b1c294f2307f009793fd493nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend Lesser General Public License for more details.
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick You should have received a copy of the GNU Lesser General Public License
42af92a661a06b3cebc88d585aad75064a309d51nd along with systemd; If not, see <http://www.gnu.org/licenses/>.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <refentryinfo>
43f6cc6aa3312619633538b8978619a48c0ce52eminfrin <authorgroup>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </authorgroup>
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin </refentryinfo>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </refmeta>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <refnamediv>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <refpurpose>Seek to a position in the
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend journal</refpurpose>
03a4ff9ac4c9b8009249010e7c53bb86ff05915and </refnamediv>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <refsynopsisdiv>
1e367a83311e5243e04d68857d007d04765a48f9chrisd <funcsynopsis>
1e367a83311e5243e04d68857d007d04765a48f9chrisd <funcsynopsisinfo>#include <systemd/sd-journal.h></funcsynopsisinfo>
7d15331eeb5429d7148d13d6fd914a641bf1c000pquerna <funcprototype>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <funcdef>int <function>sd_journal_seek_head</function></funcdef>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <paramdef>sd_journal *<parameter>j</parameter></paramdef>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </funcprototype>
2704de98885368683621b01c8f8f4e4b01557611takashi <funcprototype>
2704de98885368683621b01c8f8f4e4b01557611takashi <funcdef>int <function>sd_journal_seek_tail</function></funcdef>
1e367a83311e5243e04d68857d007d04765a48f9chrisd <paramdef>sd_journal *<parameter>j</parameter></paramdef>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </funcprototype>
c819c19c2f1ffbf3a3f12a4070cc6c3f4ea2a6f2sf <funcprototype>
d2b809e5d72658bff23819d8b77f20e4939af541nd <funcdef>int <function>sd_journal_seek_monotonic_usec</function></funcdef>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <paramdef>sd_journal *<parameter>j</parameter></paramdef>
fb51a6b789d85113d0976148685b0063c294220drbowen <paramdef>sd_id128_t <parameter>boot_id</parameter></paramdef>
cfbca4e518f4981f435e93e434f17271e6efc138rbowen <paramdef>uint64_t <parameter>usec</parameter></paramdef>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </funcprototype>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <funcprototype>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <funcdef>int <function>sd_journal_seek_realtime_usec</function></funcdef>
e81d1e4f661023c964899abcbf2a60c2f8278f4aminfrin <paramdef>sd_journal *<parameter>j</parameter></paramdef>
27d778df0b517e1578f907d2e51eb961cd8ee5fbjim <paramdef>uint64_t <parameter>usec</parameter></paramdef>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </funcprototype>
6b0fe1f447ba35827cd5cf1d2a703bd8517f33ffmturk <funcprototype>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <funcdef>int <function>sd_journal_seek_cursor</function></funcdef>
438b4817913a5ff55d9cad4c7ddf133330b4466ejim <paramdef>sd_journal *<parameter>j</parameter></paramdef>
e5ce3ac0e9b720c0fa23782e29168a0810697fdetakashi <paramdef>const char *<parameter>cursor</parameter></paramdef>
f73390048b37c973a8016ffd22108d7a73c6cc22pquerna </funcprototype>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </funcsynopsis>
4126704c4950bfd46d32ad54e3b106ac6d868a73sf </refsynopsisdiv>
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd <refsect1>
5f4e50966b2b9b58436a1651cbe588d1b595657ewrowe <para><function>sd_journal_seek_head()</function> seeks to the
5332c9934b1c0136e9cd4815fe7d70b79d83fddcsf beginning of the journal, i.e. the oldest available entry.</para>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <para>Similarly, <function>sd_journal_seek_tail()</function> may
79b024b81f6bb3c44dce77a7552191daf8b522d2jim be used to seek to the end of the journal, i.e. the most recent
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin available entry.</para>
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin <para><function>sd_journal_seek_monotonic_usec()</function> seeks
f195a136dcd90148b116fdae8ce95b41ba92b87eminfrin to the entry with the specified monotonic timestamp, i.e.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <constant>CLOCK_MONOTONIC</constant>. Since monotonic time
1de1266f0ea387d6373be8415745dfd2ab876341jim restarts on every reboot a boot ID needs to be specified as
1de1266f0ea387d6373be8415745dfd2ab876341jim well.</para>
856894d144a15ef1671032a17965bd00b430d311minfrin <para><function>sd_journal_seek_realtime_usec()</function> seeks
856894d144a15ef1671032a17965bd00b430d311minfrin to the entry with the specified realtime (wallclock) timestamp,
856894d144a15ef1671032a17965bd00b430d311minfrin i.e. <constant>CLOCK_REALTIME</constant>. Note that the realtime
856894d144a15ef1671032a17965bd00b430d311minfrin clock is not necessarily monotonic. If a realtime timestamp is
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend ambiguous, it is not defined which position is sought to.</para>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <para><function>sd_journal_seek_cursor()</function> seeks to the
10eed2803538d660048f6e733602e82a75ef6885noodl entry located at the specified cursor string. For details on
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend cursors, see
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl If no entry matching the specified cursor is found the call will
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend seek to the next closest entry (in terms of time) instead. To
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend verify whether the newly selected entry actually matches the
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd cursor, use
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <citerefentry><refentrytitle>sd_journal_test_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
4126704c4950bfd46d32ad54e3b106ac6d868a73sf <para>Note that these calls do not actually make any entry the new
0ce5630695a7aa568811a9dd0aceedd685f040dend current entry, this needs to be done in a separate step with a
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
316f02e3836836c82e19019ff23f90a7ebc65289nilgun invocation (or a similar call). Only then, entry data may be
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend retrieved via
0ce5630695a7aa568811a9dd0aceedd685f040dend <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
0ce5630695a7aa568811a9dd0aceedd685f040dend If no entry exists that matches exactly the specified seek
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend address, the next closest is sought to. If
<citerefentry><refentrytitle>sd_journal_previous</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_journal_get_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,