chiark / gitweb /
libudev: add udev_device_new_from_devnum()
[elogind.git] / udev / lib / libudev-util.c
index 6ec835e62445695dc05a4432819e6a09102f5007..aa544fea2291da4be0c20642f70fee3c3e89c717 100644 (file)
@@ -17,8 +17,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -66,12 +64,17 @@ ssize_t util_get_sys_driver(struct udev *udev, const char *syspath, char *driver
 
 int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size)
 {
+       struct stat statbuf;
        char link_target[UTIL_PATH_SIZE];
 
        int len;
        int i;
        int back;
 
+       if (lstat(syspath, &statbuf) < 0)
+               return -1;
+       if (!S_ISLNK(statbuf.st_mode))
+               return -1;
        len = readlink(syspath, link_target, sizeof(link_target));
        if (len <= 0)
                return -1;