| 1 |
#compdef udevadm |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
(( $+functions[_udevadm_info] )) || |
| 5 |
_udevadm_info(){ |
| 6 |
_arguments \ |
| 7 |
'(-)'{-h,--help}'[Print help]' \ |
| 8 |
'(-)'{-V,--version}'[Print version of the program]' \ |
| 9 |
'--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \ |
| 10 |
'--path=[The devpath of the device to query.]:sys files:_files -W /sys' \ |
| 11 |
'--name=[The name of the device node or a symlink to query]:device files:_files -W /dev' \ |
| 12 |
'--root[Print absolute paths in name or symlink query.]' \ |
| 13 |
'--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \ |
| 14 |
'--export[Print output as key/value pairs.]' \ |
| 15 |
'--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \ |
| 16 |
'--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \ |
| 17 |
'--export-db[Export the content of the udev database.]' \ |
| 18 |
'--cleanup-db[Cleanup the udev database.]' \ |
| 19 |
'--value[When showing properties, print only their values.]' \ |
| 20 |
'--property=[Show only properties by this name.]:NAME' \ |
| 21 |
'*::devpath:_path_files -g "*(-/,-%)"' |
| 22 |
} |
| 23 |
|
| 24 |
(( $+functions[_udevadm_trigger] )) || |
| 25 |
_udevadm_trigger(){ |
| 26 |
_arguments \ |
| 27 |
'(-)'{-h,--help}'[Show help]' \ |
| 28 |
'(-)'{-V,--version}'[Show package version]' \ |
| 29 |
'--verbose[Print the list of devices which will be triggered.]' \ |
| 30 |
'--dry-run[Do not actually trigger the event.]' \ |
| 31 |
'--quiet[Suppress error logging in triggering events.]' \ |
| 32 |
'--type=[Trigger a specific type of devices.]:types:(all devices subsystems failed)' \ |
| 33 |
'--action=[Type of event to be triggered.]:actions:(add change remove move online offline bind unbind)' \ |
| 34 |
'--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]:SUBSYSTEM' \ |
| 35 |
'--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]:SUBSYSTEM' \ |
| 36 |
'--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]:FILE' \ |
| 37 |
'--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]:FILE' \ |
| 38 |
'--property-match=[Trigger events for devices with a matching property value.]:KEY=VALUE' \ |
| 39 |
'--tag-match=[Trigger events for devices with a matching tag.]:TAG' \ |
| 40 |
'--sysname-match=[Trigger events for devices with a matching sys device name.]:NAME' \ |
| 41 |
'--parent-match=[Trigger events for all children of a given device.]:NAME' \ |
| 42 |
'--include-parents[Also trigger parent devices of found devices.]' \ |
| 43 |
'--initialized-match[Trigger events for devices that are already initialized.]' \ |
| 44 |
'--initialized-nomatch[Trigger events for devices that are not initialized yet.]' \ |
| 45 |
'--uuid[Print synthetic uevent UUID.]' \ |
| 46 |
'--prioritized-subsystem=[Trigger events for devices which belong to a matching subsystem earlier.]:SUBSYSTEM' \ |
| 47 |
'*::devpath:_path_files -g "*(-/,-%)"' |
| 48 |
} |
| 49 |
|
| 50 |
(( $+functions[_udevadm_settle] )) || |
| 51 |
_udevadm_settle(){ |
| 52 |
_arguments \ |
| 53 |
'(-)'{-h,--help}'[Print help]' \ |
| 54 |
'(-)'{-V,--version}'[Print version of the program]' \ |
| 55 |
'(-t --timeout)'{-t,--timeout=}'[Maximum number of seconds to wait for the event queue to become empty.]:SEC' \ |
| 56 |
'(-E --exit-if-exists)'{-E,--exit-if-exists=}'[Stop waiting if file exists.]:files:_files' |
| 57 |
} |
| 58 |
|
| 59 |
(( $+functions[_udevadm_control] )) || |
| 60 |
_udevadm_control(){ |
| 61 |
_arguments \ |
| 62 |
'(-)'{-h,--help}'[Show help]' \ |
| 63 |
'(-)'{-V,--version}'[Show package version]' \ |
| 64 |
'(-e --exit)'{-e,--exit}'[Signal and wait for systemd-udevd to exit.]' \ |
| 65 |
'(-l --log-level)'{-l,--log-level=}'[Set the internal log level of systemd-udevd.]:LEVEL:(err info debug)' \ |
| 66 |
'(-s --stop-exec-queue)'{-s,--stop-exec-queue}'[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \ |
| 67 |
'(-S --start-exec-queue)'{-S,--start-exec-queue}'[Signal systemd-udevd to enable the execution of events.]' \ |
| 68 |
'(-R --reload)'{-R,--reload}'[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \ |
| 69 |
'(-p --property)'{-p,--property=}'[Set a global property for all events.]:KEY=VALUE' \ |
| 70 |
'(-m --children-max=)'{-m,--children-max=}'[Set the maximum number of events.]:N' \ |
| 71 |
'--trace=[Enable/disable trace logging.]:BOOL' \ |
| 72 |
'--revert[Revert previously set configurations.]' \ |
| 73 |
'(-t --timeout=)'{-t,--timeout=}'[The maximum number of seconds to wait for a reply from systemd-udevd.]:SECONDS' |
| 74 |
} |
| 75 |
|
| 76 |
(( $+functions[_udevadm_monitor] )) || |
| 77 |
_udevadm_monitor(){ |
| 78 |
_arguments \ |
| 79 |
'(-)'{-h,--help}'[Show help]' \ |
| 80 |
'(-)'{-V,--version}'[Show package version]' \ |
| 81 |
'(-k --kernel)'{-k,--kernel}'[Print the kernel uevents.]' \ |
| 82 |
'(-u --udev)'{-u,--udev}'[Print the udev event after the rule processing.]' \ |
| 83 |
'(-p --property)'{-p,--property}'[Also print the properties of the event.]' \ |
| 84 |
'(-s --subsystem-match)'{-s,--subsystem-match=}'[Filter events by subsystem/\[devtype\].]:SUBSYSTEM' \ |
| 85 |
'(-t --tag-match)'{-t,--tag-match=}'[Filter events by property.]:TAG' |
| 86 |
} |
| 87 |
|
| 88 |
(( $+functions[_udevadm_test] )) || |
| 89 |
_udevadm_test(){ |
| 90 |
_arguments \ |
| 91 |
'(-)'{-h,--help}'[Show help]' \ |
| 92 |
'(-)'{-V,--version}'[Show package version]' \ |
| 93 |
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \ |
| 94 |
'(-N --resolve-names)'{-N,--resolve-names=}'[When to resolve names.]:resolve:(early late never)' \ |
| 95 |
'--subsystem=[The subsystem string.]' \ |
| 96 |
'(-D --extra-rules-dir=)'{-D,--extra-rules-dir=}'[Also load rules from the directory.]' \ |
| 97 |
'(-v --verbose)'{-v,--verbose}'[Show verbose logs.]' \ |
| 98 |
'--json=[Generate JSON output]:MODE:(pretty short off)' \ |
| 99 |
'*::devpath:_files -W /sys' |
| 100 |
} |
| 101 |
|
| 102 |
(( $+functions[_udevadm_test-builtin] )) || |
| 103 |
_udevadm_test-builtin(){ |
| 104 |
if (( CURRENT == 2 )); then |
| 105 |
_arguments \ |
| 106 |
'(- *)'{-h,--help}'[Print help]' \ |
| 107 |
'(- *)'{-V,--version}'[Print version of the program]' \ |
| 108 |
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \ |
| 109 |
'*::builtins:(blkid btrfs dissect_image factory_reset hwdb input_id keyboard kmod net_driver net_id net_setup_link path_id uaccess usb_id)' |
| 110 |
elif (( CURRENT == 3 )); then |
| 111 |
_arguments \ |
| 112 |
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \ |
| 113 |
'(- *)--help[Print help text]' \ |
| 114 |
'*::syspath:_files -W /sys' |
| 115 |
else |
| 116 |
_arguments \ |
| 117 |
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \ |
| 118 |
'(- *)--help[Print help text]' |
| 119 |
fi |
| 120 |
} |
| 121 |
|
| 122 |
(( $+functions[_udevadm_verify] )) || |
| 123 |
_udevadm_verify(){ |
| 124 |
_arguments \ |
| 125 |
'(- *)'{-h,--help}'[Show help]' \ |
| 126 |
'(- *)'{-V,--version}'[Show package version]' \ |
| 127 |
'(-N --resolve-names)'{-N,--resolve-names=}'[When to resolve names.]:resolve:(early late never)' \ |
| 128 |
'--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \ |
| 129 |
--no-summary'[Do not show summary.]' \ |
| 130 |
--no-style'[Ignore style issues.]' \ |
| 131 |
'*::files:_files' |
| 132 |
} |
| 133 |
|
| 134 |
(( $+functions[_udevadm_cat] )) || |
| 135 |
_udevadm_cat(){ |
| 136 |
_arguments \ |
| 137 |
'(- *)'{-h,--help}'[Show help]' \ |
| 138 |
'(- *)'{-V,--version}'[Show package version]' \ |
| 139 |
'--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \ |
| 140 |
--tldr'[Skip comments and empty lines.]' \ |
| 141 |
--config'[Show udev.conf.]' \ |
| 142 |
'*::files:_files' |
| 143 |
} |
| 144 |
|
| 145 |
(( $+functions[_udevadm_wait] )) || |
| 146 |
_udevadm_wait(){ |
| 147 |
_arguments \ |
| 148 |
'(- *)'{-h,--help}'[Print help]' \ |
| 149 |
'(- *)'{-V,--version}'[Print version of the program]' \ |
| 150 |
'--timeout=[Maximum number of seconds to wait for the devices being created.]:SEC' \ |
| 151 |
'--initialized=[Wait for devices being initialized by systemd-udevd.]:boolean:(yes no)' \ |
| 152 |
'--removed[Wait for devices being removed.]' \ |
| 153 |
'--settle[Also wait for udev queue being empty.]' \ |
| 154 |
'*::devpath:_files -W /dev' |
| 155 |
} |
| 156 |
|
| 157 |
(( $+functions[_udevadm_lock] )) || |
| 158 |
_udevadm_lock(){ |
| 159 |
_arguments \ |
| 160 |
'(- *)'{-h,--help}'[Print help]' \ |
| 161 |
'(- *)'{-V,--version}'[Print version of the program]' \ |
| 162 |
'(-t --timeout)'{-t,--timeout=}'[Maximum number of seconds to wait for the devices being locked.]:SECS' \ |
| 163 |
'(-d --device)'{-d,--device=}'[Block device to lock.]:DEVICE' \ |
| 164 |
'(-b --backing)'{-b,--backing=}'[File whose backing block device to lock.]:FILE' \ |
| 165 |
'(-p --print)'{-p,--print}'[Only show which block device the lock would be taken on.]' |
| 166 |
} |
| 167 |
|
| 168 |
(( $+functions[_udevadm_mounts] )) || |
| 169 |
_udevadm_mounts(){ |
| 170 |
local dev_tmp dpath_tmp mp_tmp mline |
| 171 |
|
| 172 |
tmp=( "${(@f)$(< /proc/self/mounts)}" ) |
| 173 |
dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) |
| 174 |
mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) |
| 175 |
|
| 176 |
local MATCH |
| 177 |
mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}") |
| 178 |
dpath_tmp=( "${(@Mq)dev_tmp:#/*}" ) |
| 179 |
dev_tmp=( "${(@q)dev_tmp:#/*}" ) |
| 180 |
|
| 181 |
_alternative \ |
| 182 |
'device-paths: device path:compadd -a dpath_tmp' \ |
| 183 |
'directories:mount point:compadd -a mp_tmp' |
| 184 |
} |
| 185 |
|
| 186 |
(( $+functions[_udevadm_commands] )) || |
| 187 |
_udevadm_commands(){ |
| 188 |
local -a _udevadm_cmds |
| 189 |
_udevadm_cmds=( |
| 190 |
'info:query sysfs or the udev database' |
| 191 |
'trigger:request events from the kernel' |
| 192 |
'settle:wait for the event queue to finish' |
| 193 |
'control:control the udev daemon' |
| 194 |
'monitor:listen to kernel and udev events' |
| 195 |
'test:test an event run' |
| 196 |
'test-builtin:test a built-in command' |
| 197 |
'verify:verify udev rules files' |
| 198 |
'wait:wait for devices or device symlinks being created' |
| 199 |
'lock:lock a block device and run a command' |
| 200 |
) |
| 201 |
|
| 202 |
if ((CURRENT == 1)); then |
| 203 |
_describe -t commands 'udevadm commands' _udevadm_cmds |
| 204 |
else |
| 205 |
local curcontext="$curcontext" |
| 206 |
cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}" |
| 207 |
if (($#cmd)); then |
| 208 |
if (( $+functions[_udevadm_$cmd] )); then |
| 209 |
_udevadm_$cmd |
| 210 |
else |
| 211 |
_message "no options for $cmd" |
| 212 |
fi |
| 213 |
else |
| 214 |
_message "no more options" |
| 215 |
fi |
| 216 |
fi |
| 217 |
} |
| 218 |
|
| 219 |
_arguments \ |
| 220 |
'--debug[Print debug messages to stderr]' \ |
| 221 |
'(- *)--version[Print version number]' \ |
| 222 |
'(- *)--help[Print help text]' \ |
| 223 |
'*::udevadm commands:_udevadm_commands' |