Compare commits

...

2 Commits

Author SHA1 Message Date
Yu Watanabe 92eebd77f2
Merge c5a35d3ea9 into d99198819c 2024-11-22 04:33:17 +01:00
Yu Watanabe c5a35d3ea9 journalctl: do not override explicitly specified -b or -n with -e or -k
Fixes #35248.
2024-11-20 23:16:37 +09:00
4 changed files with 22 additions and 25 deletions

View File

@ -474,8 +474,8 @@
<term><option>-k</option></term>
<term><option>--dmesg</option></term>
<listitem><para>Show only kernel messages. This implies <option>-b</option> and adds the match
<literal>_TRANSPORT=kernel</literal>.</para>
<listitem><para>Show only kernel messages. This adds the match <literal>_TRANSPORT=kernel</literal>.
This implies <option>--boot=0</option> unless explicitly specified otherwise.</para>
<xi:include href="version-info.xml" xpointer="v205"/></listitem>
</varlistentry>
@ -809,11 +809,10 @@
<term><option>--pager-end</option></term>
<listitem><para>Immediately jump to the end of the journal inside the implied pager tool. This
implies <option>-n1000</option> to guarantee that the pager will not buffer logs of unbounded
size. This may be overridden with an explicit <option>-n</option> with some other numeric value,
while <option>-nall</option> will disable this cap. Note that this option is only supported for
the <citerefentry
project='man-pages'><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry>
implies <option>--lines=1000</option> and <option>--boot=0</option> unless explicitly specified
otherwise, to guarantee that the pager will not buffer logs of unbounded size. Note that this option
is only supported for the
<citerefentry project='man-pages'><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry>
pager.</para>
<xi:include href="version-info.xml" xpointer="v198"/></listitem>

View File

@ -74,12 +74,8 @@ int journal_acquire_boot(sd_journal *j) {
assert(j);
if (!arg_boot) {
/* Clear relevant field for safety. */
arg_boot_id = SD_ID128_NULL;
arg_boot_offset = 0;
if (!arg_boot)
return 0;
}
/* Take a shortcut and use the current boot_id, which we can do very quickly.
* We can do this only when the logs are coming from the current machine,

View File

@ -45,7 +45,7 @@ bool arg_no_tail = false;
bool arg_truncate_newline = false;
bool arg_quiet = false;
bool arg_merge = false;
bool arg_boot = false;
int arg_boot = -1; /* tristate */
sd_id128_t arg_boot_id = {};
int arg_boot_offset = 0;
bool arg_dmesg = false;
@ -452,12 +452,6 @@ static int parse_argv(int argc, char *argv[]) {
case 'e':
arg_pager_flags |= PAGER_JUMP_TO_END;
if (arg_lines == ARG_LINES_DEFAULT)
arg_lines = 1000;
arg_boot = true;
break;
case 'f':
@ -563,7 +557,7 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'k':
arg_boot = arg_dmesg = true;
arg_dmesg = true;
break;
case ARG_SYSTEM:
@ -987,11 +981,19 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_no_tail)
arg_lines = ARG_LINES_ALL;
if (arg_follow && !arg_since_set && arg_lines == ARG_LINES_DEFAULT)
if (arg_lines == ARG_LINES_DEFAULT) {
if (arg_follow && !arg_since_set)
arg_lines = 10;
else if (FLAGS_SET(arg_pager_flags, PAGER_JUMP_TO_END))
arg_lines = 1000;
}
if (arg_follow && !arg_merge && !arg_boot) {
arg_boot = true;
if (arg_boot < 0)
/* Show the current boot if -f/--follow, -k/--dmesg, or -e/--pager-end is specified unless
* -m/--merge is specified. */
arg_boot = !arg_merge && (arg_follow || arg_dmesg || FLAGS_SET(arg_pager_flags, PAGER_JUMP_TO_END));
if (!arg_boot) {
/* Clear the boot ID and offset if -b/--boot is unspecified for safety. */
arg_boot_id = SD_ID128_NULL;
arg_boot_offset = 0;
}

View File

@ -50,7 +50,7 @@ extern bool arg_no_tail;
extern bool arg_truncate_newline;
extern bool arg_quiet;
extern bool arg_merge;
extern bool arg_boot;
extern int arg_boot;
extern sd_id128_t arg_boot_id;
extern int arg_boot_offset;
extern bool arg_dmesg;