summaryrefslogtreecommitdiffstats
path: root/src/udev/udevadm-wait.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-04-22 20:01:25 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-04-23 01:45:01 +0200
commitb1aca4da60ce4b82e3b0d3a1583f0edeb5bd9766 (patch)
treec24acdc385b47ad1a933acb8ed17b7eb52ad23dc /src/udev/udevadm-wait.c
parentcryptenroll,homectl: Introduce --fido2-credential-algorithm option (diff)
downloadsystemd-b1aca4da60ce4b82e3b0d3a1583f0edeb5bd9766.tar.xz
systemd-b1aca4da60ce4b82e3b0d3a1583f0edeb5bd9766.zip
udevadm: wait: check if specified path not exist on --remove
Even if the corresponding device node or syspath are already removed, the specified symlink to the device node may still exist. Fixes #23166.
Diffstat (limited to 'src/udev/udevadm-wait.c')
-rw-r--r--src/udev/udevadm-wait.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/udev/udevadm-wait.c b/src/udev/udevadm-wait.c
index 0ea0ed501b..29c8ee5cf4 100644
--- a/src/udev/udevadm-wait.c
+++ b/src/udev/udevadm-wait.c
@@ -10,6 +10,7 @@
#include "device-util.h"
#include "errno-util.h"
#include "fd-util.h"
+#include "fs-util.h"
#include "inotify-util.h"
#include "parse-util.h"
#include "path-util.h"
@@ -48,22 +49,25 @@ static int check_device(const char *path) {
assert(path);
+ if (arg_wait_until == WAIT_UNTIL_REMOVED) {
+ r = laccess(path, F_OK);
+ if (r == -ENOENT)
+ return true;
+ if (r < 0)
+ return r;
+ return false;
+ }
+
r = sd_device_new_from_path(&dev, path);
if (r == -ENODEV)
- return arg_wait_until == WAIT_UNTIL_REMOVED;
+ return false;
if (r < 0)
return r;
- switch (arg_wait_until) {
- case WAIT_UNTIL_INITIALIZED:
+ if (arg_wait_until == WAIT_UNTIL_INITIALIZED)
return sd_device_get_is_initialized(dev);
- case WAIT_UNTIL_ADDED:
- return true;
- case WAIT_UNTIL_REMOVED:
- return false;
- default:
- assert_not_reached();
- }
+
+ return true;
}
static bool check(void) {