]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: make --until work again with --after-cursor and --lines
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 20 Mar 2024 19:34:37 +0000 (04:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 20 Mar 2024 19:43:45 +0000 (04:43 +0900)
Fixes a regression introduced by 81fb5375b3b3bfc22d023d7908ad9eee4b3c1ffb.

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 <nrwahl@protonmail.com>
src/journal/journalctl.c

index 6f83585db5ffb4e2225f18ad29bb11cfe0095fce..15f3f0e025dad71eb6c4c550f7c58982f3c076e8 100644 (file)
@@ -2070,6 +2070,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;
@@ -2099,11 +2100,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;
 
@@ -2712,6 +2713,7 @@ static int run(int argc, char *argv[]) {
 
         Context c = {
                 .journal = j,
+                .has_cursor = cursor,
                 .need_seek = need_seek,
                 .since_seeked = since_seeked,
         };