[systemd-commits] 2 commits - shell-completion/systemd-bash-completion.sh src/journal
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Tue Feb 26 20:20:24 PST 2013
shell-completion/systemd-bash-completion.sh | 14 ++++++++++++++
src/journal/sd-journal.c | 4 +++-
2 files changed, 17 insertions(+), 1 deletion(-)
New commits:
commit d95b1fb315f62313be5bee5bee3b2d1467868a7d
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Feb 25 05:51:41 2013 +0100
log-show: look at everything in /run/log/journal
Logs written by journald from the initramfs may be written to a
directory with the name created from a random machine-id. Afterwards,
when the root filesystem has been mounted and machine-id reinitalized,
logs will be written to the directory with a name created from the
proper machine-id. When logs are flushed to /var/log/journal,
everything is copied to one output directory.
When journalctl without '-m' is run after the logs have been flushed
to /var/log/journal, all messages are shown. However, when run while
logs are still in /run/log/journal, those stored under the random
machine-id will not be shown.
Make journalctl behave the same regardless whether persistent storage
has been enabled or not, and slurp all files from /run/log/journal
even without '-m'.
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 8904560..1912354 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1321,10 +1321,12 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
assert(prefix);
assert(dirname);
+ log_debug("Considering %s/%s.", prefix, dirname);
+
if ((j->flags & SD_JOURNAL_LOCAL_ONLY) &&
(sd_id128_from_string(dirname, &id) < 0 ||
sd_id128_get_machine(&mid) < 0 ||
- !sd_id128_equal(id, mid)))
+ !(sd_id128_equal(id, mid) || path_startswith(prefix, "/run"))))
return 0;
path = strjoin(prefix, "/", dirname, NULL);
commit 1883552c3d80d44f4cb368874d54c1cb15b83e61
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Feb 25 15:24:10 2013 +0100
bash-completion: journalctl query by binary and device
The approach taken is different between the two:
- since there are many files in /usr, but messages appear
only for a tiny subset, the completion is performed
only for stuff shown by journalctl -F _EXE. This makes
sense because the list is already in proper form.
- since it is hard to convert _KERNEL_DEVICE to device
file name, simply all files in /dev/ are used as possible
completions.
Unfortunately zsh completion requires more work and is not
covered by this commit.
diff --git a/shell-completion/systemd-bash-completion.sh b/shell-completion/systemd-bash-completion.sh
index 1132b3c..7848baf 100644
--- a/shell-completion/systemd-bash-completion.sh
+++ b/shell-completion/systemd-bash-completion.sh
@@ -334,6 +334,20 @@ _journalctl() {
elif [[ $cur = *=* ]]; then
mapfile -t field_vals < <(journalctl -F "${prev%=}" 2>/dev/null)
COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
+ elif [[ $cur = /dev* ]]; then
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- "${cur}") )
+ elif [[ $cur = /* ]]; then
+ # Append /dev/ to the list of completions, so that
+ # after typing /<TAB><TAB> the user sees /dev/ as one
+ # of the alternatives. Later on the rule above will
+ # take care of showing device files in /dev/.
+ mapfile -t field_vals < <(journalctl -F "_EXE" 2>/dev/null; echo '/dev/')
+ COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur}") )
+ if [[ "${COMPREPLY[@]}" = '/dev/' ]]; then
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- "${cur}") )
+ fi
elif [[ $prev = '=' ]]; then
mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
More information about the systemd-commits
mailing list