diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-04-25 16:23:29 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-25 16:34:55 +0200 |
commit | c4fbc6b6e4017199717b2b8dac3d790ffd8934cc (patch) | |
tree | e15c92a01ef1dbf475a3ce9f2d8f203f61a7d554 /src | |
parent | 4f4d6ee4be1c5d3bb2f3ebce7d2d332285963830 (diff) | |
download | systemd-c4fbc6b6e4017199717b2b8dac3d790ffd8934cc.tar.gz |
journalctl: add some explanatory comments to get_boots()
Diffstat (limited to 'src')
-rw-r--r-- | src/journal/journalctl.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index c9a2c3812d..d764ba12aa 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1103,16 +1103,16 @@ static int get_boots( return r; if (advance_older) - r = sd_journal_seek_head(j); + r = sd_journal_seek_head(j); /* seek to oldest */ else - r = sd_journal_seek_tail(j); + r = sd_journal_seek_tail(j); /* seek to newest */ if (r < 0) return r; if (advance_older) - r = sd_journal_next(j); + r = sd_journal_next(j); /* read the oldest entry */ else - r = sd_journal_previous(j); + r = sd_journal_previous(j); /* read the most recently added entry */ if (r < 0) return r; else if (r == 0) @@ -1121,15 +1121,24 @@ static int get_boots( count = 1; goto finish; } + + /* At this point the read pointer is positioned at the oldest/newest occurence of the reference boot + * ID. After flushing the matches, one more invocation of _previous()/_next() will hence place us at + * the following entry, which must then have an older/newer boot ID */ } else { + if (advance_older) - r = sd_journal_seek_tail(j); + r = sd_journal_seek_tail(j); /* seek to newest */ else - r = sd_journal_seek_head(j); + r = sd_journal_seek_head(j); /* seek to oldest */ if (r < 0) return r; - /* No sd_journal_next/previous here. */ + /* No sd_journal_next()/_previous() here. + * + * At this point the read pointer is positioned after the newest/before the oldest entry in the whole + * journal. The next invocation of _previous()/_next() will hence position us at the newest/oldest + * entry we have. */ } for (;;) { |