udevadm-wait: let --removed override initialization
The documentation says --initialized= is ignored when --removed is
specified.
Track --removed separately so it wins regardless of option order.
Reproducer:
udevadm wait --timeout=0 --removed --initialized=no /dev/no-such-test-device
Before:
Timed out for waiting devices being added.
Follow-up:
aa2b0d8d29
This commit is contained in:
@@ -32,6 +32,7 @@ typedef enum WaitUntil {
|
||||
|
||||
static WaitUntil arg_wait_until = WAIT_UNTIL_INITIALIZED;
|
||||
static usec_t arg_timeout_usec = USEC_INFINITY;
|
||||
static bool arg_removed = false;
|
||||
static bool arg_settle = false;
|
||||
static char **arg_devices = NULL;
|
||||
|
||||
@@ -350,7 +351,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
OPTION_LONG("removed", NULL, "Wait for devices being removed"):
|
||||
arg_wait_until = WAIT_UNTIL_REMOVED;
|
||||
arg_removed = true;
|
||||
break;
|
||||
|
||||
OPTION_LONG("settle", NULL, "Also wait for all queued events being processed"):
|
||||
@@ -358,6 +359,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (arg_removed)
|
||||
arg_wait_until = WAIT_UNTIL_REMOVED;
|
||||
|
||||
char **args = option_parser_get_args(&opts);
|
||||
if (strv_isempty(args))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
|
||||
@@ -303,6 +303,9 @@ udevadm wait -t 5 /sys/class/net/$netdev
|
||||
udevadm wait --initialized true /sys/class/net/$netdev
|
||||
udevadm wait --initialized false /sys/class/net/$netdev
|
||||
(! udevadm wait --initialized hello /sys/class/net/$netdev)
|
||||
udevadm wait --timeout=0 --removed /dev/no-such-test-device
|
||||
udevadm wait --timeout=0 --removed --initialized=no /dev/no-such-test-device
|
||||
udevadm wait --timeout=0 --initialized=no --removed /dev/no-such-test-device
|
||||
assert_rc 124 timeout 5 udevadm wait --removed /sys/class/net/$netdev
|
||||
udevadm wait --settle /sys/class/net/$netdev
|
||||
udevadm wait -h
|
||||
|
||||
Reference in New Issue
Block a user