sd-journal: introduce sd_journal_step_one()
After the commit 7a4ee86161,
sd_journal_next() following sd_journal_seek_tail() takes no-op,
and we need to call sd_journal_previous(). This may be useful in
some cases, e.g. to fix the issue explained in the previous commit.
This commit is contained in:
@@ -825,4 +825,5 @@ global:
|
||||
sd_event_trim_memory;
|
||||
sd_pid_notify_barrier;
|
||||
sd_event_source_leave_ratelimit;
|
||||
sd_journal_step_one;
|
||||
} LIBSYSTEMD_253;
|
||||
|
||||
@@ -979,6 +979,16 @@ _public_ int sd_journal_previous(sd_journal *j) {
|
||||
return real_journal_next(j, DIRECTION_UP);
|
||||
}
|
||||
|
||||
_public_ int sd_journal_step_one(sd_journal *j, int advanced) {
|
||||
assert_return(j, -EINVAL);
|
||||
|
||||
if (j->current_location.type == LOCATION_HEAD)
|
||||
return sd_journal_next(j);
|
||||
if (j->current_location.type == LOCATION_TAIL)
|
||||
return sd_journal_previous(j);
|
||||
return real_journal_next(j, advanced ? DIRECTION_DOWN : DIRECTION_UP);
|
||||
}
|
||||
|
||||
static int real_journal_next_skip(sd_journal *j, direction_t direction, uint64_t skip) {
|
||||
int c = 0, r;
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ void sd_journal_close(sd_journal *j);
|
||||
|
||||
int sd_journal_previous(sd_journal *j);
|
||||
int sd_journal_next(sd_journal *j);
|
||||
int sd_journal_step_one(sd_journal *j, int advanced);
|
||||
|
||||
int sd_journal_previous_skip(sd_journal *j, uint64_t skip);
|
||||
int sd_journal_next_skip(sd_journal *j, uint64_t skip);
|
||||
|
||||
Reference in New Issue
Block a user