diff options
author | Danilo Krummrich <danilo.krummrich@bmw.de> | 2021-06-14 17:46:00 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-22 07:54:10 +0100 |
commit | 678f2b16676cd566c50bdec78350f732a9a3ee41 (patch) | |
tree | 9ccea2693aa03b61766f8597f2a459a701d34d2f /src/udev/udevadm-trigger.c | |
parent | sd-device-enumerator: support to list only initialized or uninitialized devices (diff) | |
download | systemd-678f2b16676cd566c50bdec78350f732a9a3ee41.tar.xz systemd-678f2b16676cd566c50bdec78350f732a9a3ee41.zip |
udevadm: trigger: implement --initialized-match/nomatch arguments
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.
Diffstat (limited to 'src/udev/udevadm-trigger.c')
-rw-r--r-- | src/udev/udevadm-trigger.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index e4b3150e60..56921e2cc6 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -11,6 +11,7 @@ #include "device-util.h" #include "fd-util.h" #include "fileio.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "set.h" @@ -226,6 +227,8 @@ static int help(void) { " -y --sysname-match=NAME Trigger devices with this /sys path\n" " --name-match=NAME Trigger devices with this /dev name\n" " -b --parent-match=NAME Trigger devices with that parent device\n" + " --initialized-match Trigger devices that are already initialized\n" + " --initialized-nomatch Trigger devices that are not initialized yet\n" " -w --settle Wait for the triggered events to complete\n" " --wait-daemon[=SECONDS] Wait for udevd daemon to be initialized\n" " before triggering uevents\n" @@ -243,6 +246,8 @@ int trigger_main(int argc, char *argv[], void *userdata) { ARG_PING, ARG_UUID, ARG_PRIORITIZED_SUBSYSTEM, + ARG_INITIALIZED_MATCH, + ARG_INITIALIZED_NOMATCH, }; static const struct option options[] = { @@ -260,6 +265,8 @@ int trigger_main(int argc, char *argv[], void *userdata) { { "sysname-match", required_argument, NULL, 'y' }, { "name-match", required_argument, NULL, ARG_NAME }, { "parent-match", required_argument, NULL, 'b' }, + { "initialized-match", no_argument, NULL, ARG_INITIALIZED_MATCH }, + { "initialized-nomatch", no_argument, NULL, ARG_INITIALIZED_NOMATCH }, { "settle", no_argument, NULL, 'w' }, { "wait-daemon", optional_argument, NULL, ARG_PING }, { "version", no_argument, NULL, 'V' }, @@ -426,6 +433,12 @@ int trigger_main(int argc, char *argv[], void *userdata) { } break; } + case ARG_INITIALIZED_MATCH: + case ARG_INITIALIZED_NOMATCH: + r = device_enumerator_add_match_is_initialized(e, c == ARG_INITIALIZED_MATCH ? MATCH_INITIALIZED_YES : MATCH_INITIALIZED_NO); + if (r < 0) + return log_error_errno(r, "Failed to set initialized filter: %m"); + break; case 'V': return print_version(); case 'h': |