Skip to content

Commit

Permalink
journalctl: make --until work again with --after-cursor and --lines
Browse files Browse the repository at this point in the history
Fixes a regression introduced by 81fb537.

If one of the cursor option is specified, we first seek to the cursor position.
So, the current position may be out of the time range specified by --until,
and we need to verify the timestamp of the current position.

Fixes #31776.

Co-authored-by: Reid Wahl <[email protected]>
(cherry picked from commit cb2be36)

Related: RHEL-30567
  • Loading branch information
yuwata authored and dtardon committed Jun 12, 2024
1 parent 7769da6 commit 4f7f720
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/journal/journalctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,7 @@ static int update_cursor(sd_journal *j) {

typedef struct Context {
sd_journal *journal;
bool has_cursor;
bool need_seek;
bool since_seeked;
bool ellipsized;
Expand Down Expand Up @@ -2184,11 +2185,11 @@ static int show(Context *c) {
break;
}

if (arg_until_set && !arg_reverse && (arg_lines < 0 || arg_since_set)) {
/* If --lines= is set, we usually rely on the n_shown to tell us
* when to stop. However, if --since= is set too, we may end up
* having less than --lines= to output. In this case let's also
* check if the entry is in range. */
if (arg_until_set && !arg_reverse && (arg_lines < 0 || arg_since_set || c->has_cursor)) {
/* If --lines= is set, we usually rely on the n_shown to tell us when to stop.
* However, if --since= or one of the cursor argument is set too, we may end up
* having less than --lines= to output. In this case let's also check if the entry
* is in range. */

usec_t usec;

Expand Down Expand Up @@ -2817,6 +2818,7 @@ static int run(int argc, char *argv[]) {

Context c = {
.journal = j,
.has_cursor = cursor,
.need_seek = need_seek,
.since_seeked = since_seeked,
};
Expand Down

0 comments on commit 4f7f720

Please sign in to comment.