diff options
author | Dmitry V. Levin <ldv@strace.io> | 2023-03-02 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-03-08 18:55:40 +0000 |
commit | acdba85e0e2bf229f356ad09a2b880e89224715d (patch) | |
tree | c070f6407dd1bd639708e1c7dfb5243478f4dd05 /shell-completion | |
parent | 4f5de157316f00e046bc43687144fb8a6a81808f (diff) | |
download | systemd-acdba85e0e2bf229f356ad09a2b880e89224715d.tar.gz |
udevadm: introduce new 'verify' command
We seem to have no tool to verify udev rule files. There is a simple
udev rules syntax checker in the tree, test/rule-syntax-check.py, but
it is too simple to detect less trivial issues not detected by udev,
e.g. redundant comparisons (#26593) or labels without references.
Such a tool would be beneficial not only for maintaining udev rules
distributed along with udev, but also and even more so for maintaining
third party udev rules that are more likely to have issues with syntax
and semantic correctness.
Implement a udev rules syntax and semantics checker in the form of
'udevadm verify [OPTIONS] FILE...' command that is based on
udev_rules_parse_file() interface and would apply further checks
on top of it in subsequent commits.
Resolves: #26606
Diffstat (limited to 'shell-completion')
-rw-r--r-- | shell-completion/bash/udevadm | 24 | ||||
-rw-r--r-- | shell-completion/zsh/_udevadm | 9 |
2 files changed, 32 insertions, 1 deletions
diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm index 99d4aa55c9..b6e14e1d36 100644 --- a/shell-completion/bash/udevadm +++ b/shell-completion/bash/udevadm @@ -64,11 +64,12 @@ _udevadm() { [MONITOR_ARG]='-s --subsystem-match -t --tag-match' [TEST]='-a --action -N --resolve-names' [TEST_BUILTIN]='-a --action' + [VERIFY]='-N --resolve-names' [WAIT]='-t --timeout --initialized=no --removed --settle' [LOCK]='-t --timeout -d --device -b --backing -p --print' ) - local verbs=(info trigger settle control monitor test-builtin test wait lock) + local verbs=(info trigger settle control monitor test-builtin test verify wait lock) local builtins=(blkid btrfs hwdb input_id keyboard kmod net_id net_setup_link path_id usb_id uaccess) for ((i=0; i < COMP_CWORD; i++)); do @@ -247,6 +248,27 @@ _udevadm() { fi ;; + 'verify') + if __contains_word "$prev" ${OPTS[VERIFY]}; then + case $prev in + -N|--resolve-names) + comps='early never' + ;; + *) + comps='' + ;; + esac + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 + fi + + if [[ $cur = -* ]]; then + comps="${OPTS[COMMON]} ${OPTS[VERIFY]}" + else + comps=$( compgen -A file -- "$cur" ) + fi + ;; + 'wait') if __contains_word "$prev" ${OPTS[WAIT]}; then case $prev in diff --git a/shell-completion/zsh/_udevadm b/shell-completion/zsh/_udevadm index f7c3384eae..074d367a9d 100644 --- a/shell-completion/zsh/_udevadm +++ b/shell-completion/zsh/_udevadm @@ -104,6 +104,14 @@ _udevadm_test-builtin(){ fi } +(( $+functions[_udevadm_verify] )) || +_udevadm_verify(){ + _arguments \ + {-N+,--resolve-names=}'[When to resolve names.]:resolve:(early never)' \ + {-h,--help}'[Print help text.]' \ + '*::files:_files' +} + (( $+functions[_udevadm_wait] )) || _udevadm_wait(){ _arguments \ @@ -154,6 +162,7 @@ _udevadm_commands(){ 'monitor:listen to kernel and udev events' 'test:test an event run' 'test-builtin:test a built-in command' + 'verify:verify udev rules files' 'wait:wait for devices or device symlinks being created' 'lock:lock a block device and run a comand' ) |