Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

journalctl -r -n flags incorrectly processed #1596

Closed
ceecko opened this issue Oct 17, 2015 · 4 comments
Closed

journalctl -r -n flags incorrectly processed #1596

ceecko opened this issue Oct 17, 2015 · 4 comments

Comments

@ceecko
Copy link

@ceecko ceecko commented Oct 17, 2015

I'm running version 208 - unfortunately I can't install the latest version but the issues seems to be present in the master as well as of writing.

journalctl --version
systemd 208
+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ

Consider the following log entries:

2015-01-01 log1
2015-02-02 log2
2015-03-03 log3
2015-04-04 log4

Issuing journalctl -n 2 properly shows this:

2015-03-03 log3
2015-04-04 log4

However issuing journalctl -r -n 2 shows this:

2015-02-02 log2
2015-01-01 log1

This is because in journalctl.c line 2087 skips journal by arg_lines but doesn't take into account arg_reverse. Consequently on line 2153 the journal is read from arg_lines backwards which ultimately skips first arg_lines lines.

The expected output of journalctl -r -n 2 is:

2015-04-04 log4
2015-03-03 log3
@fwjavox
Copy link

@fwjavox fwjavox commented Apr 10, 2019

This still applies to version 239. A workaround is to specify the cursor of the point where you want to start reading.
Edit: I also checked version 241, same behaviour.

@timo-schluessler
Copy link

@timo-schluessler timo-schluessler commented Jul 18, 2019

I can confirm this bug in 242.
It is fixed by first checking for arg_reverse and then for arg_lines. The following patch fixes this.

fix-nr-of-lines-when-reversing.diff.gz

@dtardon
Copy link
Contributor

@dtardon dtardon commented Nov 4, 2019

@timo-schluessler Could you submit your patch as a pull request?

@timo-schluessler
Copy link

@timo-schluessler timo-schluessler commented Jan 13, 2020

Sorry for my late reply. Please find the pull request at #14552.

flokli pushed a commit to flokli/systemd that referenced this issue Feb 18, 2020
bluca pushed a commit to bluca/systemd that referenced this issue Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants