summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shared/logs-show.c35
-rw-r--r--src/shared/logs-show.h9
2 files changed, 29 insertions, 15 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index e1d59209d7..50326fde5d 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -1119,14 +1119,15 @@ static int maybe_print_begin_newline(FILE *f, OutputFlags *flags) {
return 0;
}
-static int show_journal(FILE *f,
- sd_journal *j,
- OutputMode mode,
- unsigned n_columns,
- usec_t not_before,
- unsigned how_many,
- OutputFlags flags,
- bool *ellipsized) {
+int show_journal(
+ FILE *f,
+ sd_journal *j,
+ OutputMode mode,
+ unsigned n_columns,
+ usec_t not_before,
+ unsigned how_many,
+ OutputFlags flags,
+ bool *ellipsized) {
int r;
unsigned line = 0;
@@ -1137,14 +1138,18 @@ static int show_journal(FILE *f,
assert(mode >= 0);
assert(mode < _OUTPUT_MODE_MAX);
- /* Seek to end */
- r = sd_journal_seek_tail(j);
- if (r < 0)
- return log_error_errno(r, "Failed to seek to tail: %m");
+ if (how_many == (unsigned) -1)
+ need_seek = true;
+ else {
+ /* Seek to end */
+ r = sd_journal_seek_tail(j);
+ if (r < 0)
+ return log_error_errno(r, "Failed to seek to tail: %m");
- r = sd_journal_previous_skip(j, how_many);
- if (r < 0)
- return log_error_errno(r, "Failed to skip previous: %m");
+ r = sd_journal_previous_skip(j, how_many);
+ if (r < 0)
+ return log_error_errno(r, "Failed to skip previous: %m");
+ }
for (;;) {
for (;;) {
diff --git a/src/shared/logs-show.h b/src/shared/logs-show.h
index 49caa4cb39..68e234a0ef 100644
--- a/src/shared/logs-show.h
+++ b/src/shared/logs-show.h
@@ -28,6 +28,15 @@ int show_journal_entry(
char **output_fields,
size_t highlight[2],
bool *ellipsized);
+int show_journal(
+ FILE *f,
+ sd_journal *j,
+ OutputMode mode,
+ unsigned n_columns,
+ usec_t not_before,
+ unsigned how_many,
+ OutputFlags flags,
+ bool *ellipsized);
int add_match_this_boot(sd_journal *j, const char *machine);