From: Yu Watanabe Date: Thu, 29 Sep 2022 17:03:32 +0000 (+0900) Subject: udevadm: do not try to find device unit when a path like string is provided X-Git-Tag: v252-rc1~64^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4273a041f1ff735606f656ff6e60991d38568ba8;p=thirdparty%2Fsystemd.git udevadm: do not try to find device unit when a path like string is provided Otherwise, we provide misleading error message. Before: --- $ udevadm info /sys/class/foo Bad argument "/sys/class/foo", expected an absolute path in /dev/ or /sys/ or a unit name: Invalid argument --- After: --- $ udevadm info /sys/class/foo Unknown device "/sys/class/foo": No such device --- --- diff --git a/src/udev/udevadm-util.c b/src/udev/udevadm-util.c index 4081976ca31..2447edad192 100644 --- a/src/udev/udevadm-util.c +++ b/src/udev/udevadm-util.c @@ -72,6 +72,10 @@ int find_device(const char *id, const char *prefix, sd_device **ret) { return 0; } + /* if a path is provided, then it cannot be a unit name. Let's return earlier. */ + if (is_path(id)) + return -ENODEV; + /* Check if the argument looks like a device unit name. */ return find_device_from_unit(id, ret); }