]>
Commit | Line | Data |
---|---|---|
a06225fc | 1 | #compdef udevadm |
7059062c | 2 | # SPDX-License-Identifier: LGPL-2.1+ |
a06225fc | 3 | |
c501ecd7 | 4 | (( $+functions[_udevadm_info] )) || |
a06225fc WG |
5 | _udevadm_info(){ |
6 | _arguments \ | |
7 | '--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)' \ | |
8 | '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \ | |
9 | '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \ | |
10 | '--root[Print absolute paths in name or symlink query.]' \ | |
11 | '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \ | |
12 | '--export[Print output as key/value pairs.]' \ | |
13 | '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \ | |
14 | '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \ | |
15 | '--export-db[Export the content of the udev database.]' \ | |
16 | '--cleanup-db[Cleanup the udev database.]' | |
17 | } | |
18 | ||
c501ecd7 | 19 | (( $+functions[_udevadm_trigger] )) || |
a06225fc WG |
20 | _udevadm_trigger(){ |
21 | _arguments \ | |
22 | '--verbose[Print the list of devices which will be triggered.]' \ | |
23 | '--dry-run[Do not actually trigger the event.]' \ | |
24 | '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \ | |
25 | '--action=[Type of event to be triggered.]:actions:(add change remove)' \ | |
26 | '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \ | |
27 | '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \ | |
28 | '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \ | |
29 | '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \ | |
30 | '--property-match=[Trigger events for devices with a matching property value.]' \ | |
31 | '--tag-match=property[Trigger events for devices with a matching tag.]' \ | |
32 | '--sysname-match=[Trigger events for devices with a matching sys device name.]' \ | |
33 | '--parent-match=[Trigger events for all children of a given device.]' | |
34 | } | |
35 | ||
c501ecd7 | 36 | (( $+functions[_udevadm_settle] )) || |
a06225fc WG |
37 | _udevadm_settle(){ |
38 | _arguments \ | |
39 | '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \ | |
40 | '--seq-start=[Wait only for events after the given sequence number.]' \ | |
41 | '--seq-end=[Wait only for events before the given sequence number.]' \ | |
42 | '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \ | |
43 | '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \ | |
44 | '--help[Print help text.]' | |
45 | } | |
46 | ||
c501ecd7 | 47 | (( $+functions[_udevadm_control] )) || |
a06225fc WG |
48 | _udevadm_control(){ |
49 | _arguments \ | |
50 | '--exit[Signal and wait for systemd-udevd to exit.]' \ | |
51 | '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \ | |
52 | '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \ | |
53 | '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \ | |
54 | '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \ | |
55 | '--property=[Set a global property for all events.]' \ | |
56 | '--children-max=[Set the maximum number of events.]' \ | |
57 | '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \ | |
58 | '--help[Print help text.]' | |
59 | } | |
60 | ||
c501ecd7 | 61 | (( $+functions[_udevadm_monitor] )) || |
a06225fc WG |
62 | _udevadm_monitor(){ |
63 | _arguments \ | |
64 | '--kernel[Print the kernel uevents.]' \ | |
65 | '--udev[Print the udev event after the rule processing.]' \ | |
66 | '--property[Also print the properties of the event.]' \ | |
67 | '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \ | |
68 | '--tag-match=[Filter events by property.]' \ | |
69 | '--help[Print help text.]' | |
70 | } | |
71 | ||
c501ecd7 | 72 | (( $+functions[_udevadm_test] )) || |
a06225fc WG |
73 | _udevadm_test(){ |
74 | _arguments \ | |
75 | '--action=[The action string.]:actions:(add change remove)' \ | |
76 | '--subsystem=[The subsystem string.]' \ | |
77 | '--help[Print help text.]' \ | |
78 | '*::devpath:_files -P /sys/ -W /sys' | |
79 | } | |
80 | ||
c501ecd7 | 81 | (( $+functions[_udevadm_test-builtin] )) || |
a06225fc WG |
82 | _udevadm_test-builtin(){ |
83 | if (( CURRENT == 2 )); then | |
84 | _arguments \ | |
85 | '--help[Print help text]' \ | |
0b99c9f8 | 86 | '*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)' |
a06225fc WG |
87 | elif (( CURRENT == 3 )); then |
88 | _arguments \ | |
89 | '--help[Print help text]' \ | |
90 | '*::syspath:_files -P /sys -W /sys' | |
91 | else | |
92 | _arguments \ | |
93 | '--help[Print help text]' | |
94 | fi | |
95 | } | |
96 | ||
c501ecd7 | 97 | (( $+functions[_udevadm_mounts] )) || |
a06225fc WG |
98 | _udevadm_mounts(){ |
99 | local dev_tmp dpath_tmp mp_tmp mline | |
100 | ||
b3ccac01 | 101 | tmp=( "${(@f)$(< /proc/self/mounts)}" ) |
a06225fc WG |
102 | dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) |
103 | mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) | |
104 | ||
105 | local MATCH | |
106 | mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}") | |
107 | dpath_tmp=( "${(@Mq)dev_tmp:#/*}" ) | |
108 | dev_tmp=( "${(@q)dev_tmp:#/*}" ) | |
109 | ||
110 | _alternative \ | |
111 | 'device-paths: device path:compadd -a dpath_tmp' \ | |
112 | 'directories:mount point:compadd -a mp_tmp' | |
113 | } | |
114 | ||
c501ecd7 | 115 | (( $+functions[_udevadm_commands] )) || |
116 | _udevadm_commands(){ | |
a06225fc WG |
117 | local -a _udevadm_cmds |
118 | _udevadm_cmds=( | |
119 | 'info:query sysfs or the udev database' | |
120 | 'trigger:request events from the kernel' | |
121 | 'settle:wait for the event queue to finish' | |
122 | 'control:control the udev daemon' | |
123 | 'monitor:listen to kernel and udev events' | |
124 | 'test:test an event run' | |
125 | 'test-builtin:test a built-in command' | |
126 | ) | |
127 | ||
128 | if ((CURRENT == 1)); then | |
129 | _describe -t commands 'udevadm commands' _udevadm_cmds | |
130 | else | |
131 | local curcontext="$curcontext" | |
132 | cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}" | |
133 | if (($#cmd)); then | |
134 | if (( $+functions[_udevadm_$cmd] )); then | |
135 | _udevadm_$cmd | |
136 | else | |
137 | _message "no options for $cmd" | |
138 | fi | |
139 | else | |
140 | _message "no more options" | |
141 | fi | |
142 | fi | |
143 | } | |
144 | ||
a06225fc WG |
145 | _arguments \ |
146 | '--debug[Print debug messages to stderr]' \ | |
147 | '--version[Print version number]' \ | |
148 | '--help[Print help text]' \ | |
c501ecd7 | 149 | '*::udevadm commands:_udevadm_commands' |