summaryrefslogtreecommitdiff
path: root/src/udev/udevadm-trigger.c
Commit message (Collapse)AuthorAgeFilesLines
* udevadm: add todo to remind us to remove compat codeZbigniew Jędrzejewski-Szmek2023-01-241-1/+5
| | | | https://github.com/systemd/systemd/pull/25145#issuecomment-1397606521
* udevadm-trigger: also check with the original syspath if device is renamedYu Watanabe2023-01-191-0/+26
| | | | | | | | For older kernels that synthetic UUID is not supported, we need to also check the original device name, as udevd broadcasts uevent with new sysname. Fixes #25115.
* udevadm-trigger: settle with synthetic UUID if the kernel support itYu Watanabe2023-01-191-42/+40
| | | | | | | | If the kernel support synthetic UUID in uevent, then let's assume that the UUID is unique, and check only if the received UUID matches we specified. Partially fixes #25115.
* udevadm-trigger: allow to fallback without synthetic UUID only first timeYu Watanabe2023-01-191-8/+14
| | | | | | If a device is successfully triggered with synthetic UUID, then that means the kernel support it. Hence, it is not necessary to fallback without UUID for later devices.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-2/+1
|
* udevadm: trigger: implement --initialized-match/nomatch argumentsDanilo Krummrich2022-03-221-0/+13
| | | | | | | | | | | | | | | | | | | | systemd-udev-trigger.service by default triggeres all devices regardless of whether they were already recognized by systemd-udevd. There are machines (especially in embedded environments) where systemd-udev-trigger.service is configured to run at a later stage of the boot sequence, which can lead to quite a lot of devices being triggered although they were already recognized by systemd-udevd. Re-triggering a lot of devices is a relatively expensive operation and therefore should be avoided if unnecessary. Therefore this patch introduces --initialized-nomatch, which filters out devices that are already present in the udev database. For consistance reasons --initialized-match is implemented as well, which filters out devices that are *not* already present in the udev database. Replaces #19949.
* udevadm trigger: introduce --type=all optionYu Watanabe2022-03-221-0/+8
|
* udevadm trigger: introduce --prioritized-subsystem optionYu Watanabe2022-03-221-20/+38
|
* udevadm: trigger: drop unnecessary slashYu Watanabe2022-02-021-1/+1
|
* udevadm: introduce parse_device_action() helper functionYu Watanabe2021-08-171-9/+5
|
* udev: also rename struct udev_ctrl -> UdevCtrlYu Watanabe2021-08-101-1/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-2/+2
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* udevadm: fix --tag-match help + descriptionLennart Poettering2021-06-081-1/+1
|
* udevadm: output trigger UUID in UUID format, instead of ID128Lennart Poettering2021-06-011-2/+2
| | | | | | The SYNTH_UUID property also shows it in UUID format, and so does the kernel and its docs otherwise, hence accept our fate and also output it in UUID.
* udevadm: make use of the new uuid-enabled triggering for "udevadm trigger"Lennart Poettering2021-05-261-23/+95
| | | | | | | | | | | | | | This adds two things: - A new switch --uuid is added to "udevadm trigger". If specified a random UUID is associated with the synthettic uevent and it is printed to stdout. It may then be used manually to match up uevents as they propagate through the system. - The UUID logic is now implicitly enabled if "udevadm trigger --settle" is used, in order to wait for precisely the uevents we actually trigger. Fallback support is kept for pre-4.13 kernels (where the requests for trigger uevents with uuids results in EINVAL).
* udevadm-trigger: introduce --quiet optionYu Watanabe2021-02-211-1/+8
| | | | This may be useful to invoke the command by non-privileged users.
* udevadm-trigger: do not return immediately on EACCESYu Watanabe2021-02-211-3/+29
| | | | Prompted by https://github.com/systemd/systemd/pull/18559.
* udevadm-trigger: use sd_device_trigger() for triggering ueventYu Watanabe2021-02-211-19/+15
|
* udevadm: after validating action, use our internal string instead of optargLennart Poettering2021-02-181-1/+1
| | | | | | | | This doesn't really change anything, but feels nicer, since it abstracts away what device_action_from_string()/device_action_to_string() do internally, and always uses a normalized action string (yes, there's no ambiguity, but it's nice to stay abstract, maybe one day there is ambiguity around this)
* sd-device: add sd_device_get_action() + sd_device_get_seqnum() + ↵Lennart Poettering2021-02-181-1/+1
| | | | | | | | | | | | | | | | sd_device_new_from_stat_rdev() To make sd-device properly usable for all programs we need to provide an API for the "action" field of an event, it's one of the most relevant ones, and it was so far missing. This also adds sd_device_get_seqnum(), which isn't that interesting, except for generating pretty debug output, which we use it ourselves for. This also makes device_new_from_stat_rdev() public, as it is truly useful, as we can see in our own uses of it, and I think is fairly generic to show up in the public APIs.
* tree-wide: propagate error in xxx_from-string()Yu Watanabe2021-02-121-3/+8
|
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-2/+2
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* tree-wide: fix typoYu Watanabe2020-12-141-1/+1
|
* license: GPL-2.0+ -> GPL-2.0-or-laterYu Watanabe2020-11-091-1/+1
|
* udevadm: ignore -ENODEV on triggerYu Watanabe2020-10-061-2/+2
| | | | | | | | The commit 88da55e28b467999da005591d3252a98f4436522 erroneously makes `udevadm trigger` treat -ENODEV error critical. This makes -ENODEV ignored again. Fixes #17250.
* udevadm: do not ignroe error caused by unpriviledged user invoking the commandYu Watanabe2020-09-291-3/+4
| | | | | | | | | | | This effectively reverts commit 67acde4869a9505f9721e31fa5167c82445e0e12. After commits 569ad251adde02dc0915758fe027e0346e50738a and 67acde4869a9505f9721e31fa5167c82445e0e12, -EACCES errors are ignored, and thus 'udevadm trigger' succeeds even when it is invoked by non-root users. Moreover, on -EACCES error, log messages are shown in debug level, so usually we see no message, and users are easily confused why uevents for devices are not triggered.
* basic/set: let set_put_strdup() create the set with string hash opsZbigniew Jędrzejewski-Szmek2020-05-061-4/+5
| | | | | | | | | | | | | | | | | | If we're using a set with _put_strdup(), most of the time we want to use string hash ops on the set, and free the strings when done. This defines the appropriate a new string_hash_ops_free structure to automatically free the keys when removing the set, and makes set_put_strdup() and set_put_strdupv() instantiate the set with those hash ops. hashmap_put_strdup() was already doing something similar. (It is OK to instantiate the set earlier, possibly with a different hash ops structure. set_put_strdup() will then use the existing set. It is also OK to call set_free_free() instead of set_free() on a set with string_hash_ops_free, the effect is the same, we're just overriding the override of the cleanup function.) No functional change intended.
* udevadm: ignore EROFS and return earlierYu Watanabe2019-11-181-2/+5
| | | | Fixes #14060.
* udevadm trigger: do not propagate EACCES and ENODEVYu Watanabe2019-10-021-2/+4
| | | | | | | | Inside container, writing file returns EACCESS. Moreover, some devices return ENODEV rather than EACCES. So, let's also ignore these two error causes. Closes #13652.
* udevadm: support special value 'help' for --action optionYu Watanabe2019-06-291-1/+5
|
* udevadm trigger: log errors and return first failureZbigniew Jędrzejewski-Szmek2019-06-051-3/+6
| | | | | | | | | | | When udevadm trigger is called, the list of devices to trigger is always generated through enumeration, and devices can come and go, so we should not treat -ENOENT as a failure. But other types of failure should be logged. It seems they were logged until baa30fbc2c04b23209d0b8fb3c86cd15ef9ea81a. Also, return the first error. (I'm not sure if there are other failure modes which we want to ignore. If they are, they'll need to be whitelisted like -ENOENT.).
* udevadm: drop pointless must_be_root() checksZbigniew Jędrzejewski-Szmek2019-05-081-6/+0
| | | | | | | | | | | | | | | Checking if we are root on the client side is generally pointless, since the privileged operation will fail anyway and we can than log what precisly went wrong. A check like this makes sense only if: - we need to do some expensive unprivileged operation before attempting the privileged operation, and the check allows us avoid wasting resources. - the privileged operation would fail but in an unclear way. Neither of those cases applies here. This fixes calls like 'udevadm control -h' as unprivileged user.
* udev: fix memleak in 'udevadm trigger --settle'Yu Watanabe2019-03-121-1/+3
| | | | Fixes #11966.
* udevadm trigger: make --action option support all possible actionsYu Watanabe2019-03-071-4/+4
| | | | This also make udevadm abort operations if invalid action is specified.
* udev-ctrl: split out logic of waiting for reply to udev_ctrl_wait()Yu Watanabe2019-02-201-1/+5
| | | | | This makes `udevadm control` can send multiple commands in one connection.
* udev-ctrl: make udev_ctrl_new() return negative errno on failureYu Watanabe2019-02-201-3/+3
|
* udevadm: trigger: support multiple argumentsYu Watanabe2019-01-231-3/+3
| | | | Closes #6098.
* udevadm: add --wait-daemon option to 'trigger' commandYu Watanabe2019-01-181-1/+36
|
* udevadm: use SYNTHETIC_ERRNO() macroYu Watanabe2019-01-131-8/+4
|
* udevadm: refuse to run trigger, control, settle and monitor commands in chrootYu Watanabe2019-01-081-0/+6
| | | | Closes #11333.
* tree-wide: rename path_join_many() to path_join()Zbigniew Jędrzejewski-Szmek2018-11-301-1/+1
| | | | | | $ git grep -e path_join_many -l|xargs sed -r -i 's/path_join_many/path_join/g' The two test functions are merged into one.
* tree-wide: replace path_join with path_join_manyZbigniew Jędrzejewski-Szmek2018-11-301-1/+1
|
* sd-device: drop priority and description from ↵Yu Watanabe2018-11-101-2/+2
| | | | | | | sd_device_monitor_attach_event() and sd_device_monitor_start() Now we have sd_device_monitor_get_event_soruce(). So, it is not necessary to include these parameters in the functions for sd_device_monitor.
* udevadm: use write_string_file() helper functionYu Watanabe2018-11-061-6/+5
|
* udevadm-trigger: use sd_event_loop()Yu Watanabe2018-10-171-60/+43
|
* udevadm-trigger: modernize code a bitYu Watanabe2018-10-171-34/+48
|
* udevadm-trigger: replace udev_monitor by sd_device_monitorYu Watanabe2018-10-171-19/+19
|
* udevadm-info,trigger: replace udev_device by sd_deviceYu Watanabe2018-10-171-59/+77
|
* udevadm: show only version number for '--version' optionYu Watanabe2018-09-211-1/+1
| | | | | | | | This effectively reverts 2bc54be485def3d1697a00209ff73ae21aa7f268 and relevant changes in #9920, as it is used to determine the version of udev, e.g., dracut. Fixes dracutdevs/dracut#468.
* udevadm-trigger: make trigger_main() returns negative value on errorYu Watanabe2018-09-101-82/+51
|