chiark / gitweb /
sd-device: set_syspath - return ENODEV when passed something that is not a device
authorTom Gundersen <teg@jklm.no>
Tue, 21 Apr 2015 12:41:13 +0000 (14:41 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 07:07:33 +0000 (08:07 +0100)
src/libelogind/sd-device/sd-device.c

index 2e30b85..7a7b323 100644 (file)
@@ -184,15 +184,17 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
                         path = strjoina(syspath, "/uevent");
                         r = access(path, F_OK);
                         if (r < 0) {
+                                if (errno == ENOENT)
+                                        /* this is not a valid device */
+                                        return -ENODEV;
+
                                 log_debug("sd-device: %s does not have an uevent file: %m", syspath);
                                 return -errno;
                         }
                 } else {
                         /* everything else just just needs to be a directory */
-                        if (!is_dir(syspath, false)) {
-                                log_debug("sd-device: %s is not a directory", syspath);
-                                return -EINVAL;
-                        }
+                        if (!is_dir(syspath, false))
+                                return -ENODEV;
                 }
         } else {
                 syspath = strdup(_syspath);