X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Flogs-show.c;h=540b5a2a2cb3770416afea05745df470996c3846;hp=4c59ca34cd55d8b132682b52ba8fe9024e130007;hb=e02d1cf72d115d1d61defdca5b551672d876c6bd;hpb=7ea07dcddafe573c699fc48171b57b912897e7e2 diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 4c59ca34c..540b5a2a2 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -551,12 +551,12 @@ int show_journal_by_unit( usec_t not_before, unsigned how_many, bool show_all, - bool follow) { + bool follow, + bool warn_cutoff) { char *m = NULL; sd_journal *j = NULL; int r; - int fd; unsigned line = 0; bool need_seek = false; @@ -582,10 +582,6 @@ int show_journal_by_unit( if (r < 0) goto finish; - fd = sd_journal_get_fd(j); - if (fd < 0) - goto finish; - r = sd_journal_add_match(j, m, strlen(m)); if (r < 0) goto finish; @@ -639,14 +635,30 @@ int show_journal_by_unit( goto finish; } + if (warn_cutoff && line < how_many && not_before > 0) { + sd_id128_t boot_id; + usec_t cutoff; + + /* Check whether the cutoff line is too early */ + + r = sd_id128_get_boot(&boot_id); + if (r < 0) + goto finish; + + r = sd_journal_get_cutoff_monotonic_usec(j, boot_id, &cutoff, NULL); + if (r < 0) + goto finish; + + if (not_before < cutoff) + printf("Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.\n"); + + warn_cutoff = false; + } + if (!follow) break; - r = fd_wait_for_event(fd, POLLIN, (usec_t) -1); - if (r < 0) - goto finish; - - r = sd_journal_process(j); + r = sd_journal_wait(j, (usec_t) -1); if (r < 0) goto finish;