1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

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.
This commit is contained in:
Yu Watanabe 2022-04-23 03:01:25 +09:00
parent 70e723c000
commit b1aca4da60

View File

@ -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) {