chiark / gitweb /
release 100
[elogind.git] / udevinfo.c
index dca4616958b4eeeb5e662e034af6f58346971c91..5445b0fcc13e0ad1e6463a9b8439490e0afada35 100644 (file)
@@ -26,6 +26,8 @@
 #include <dirent.h>
 #include <errno.h>
 #include <getopt.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "udev.h"
 
@@ -56,10 +58,23 @@ static void print_all_attributes(const char *devpath, const char *key)
        dir = opendir(path);
        if (dir != NULL) {
                for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+                       struct stat statbuf;
+                       char filename[PATH_SIZE];
                        char *attr_value;
                        char value[NAME_SIZE];
                        size_t len;
 
+                       if (dent->d_name[0] == '.')
+                               continue;
+
+                       strlcpy(filename, path, sizeof(filename));
+                       strlcat(filename, "/", sizeof(filename));
+                       strlcat(filename, dent->d_name, sizeof(filename));
+                       if (lstat(filename, &statbuf) != 0)
+                               continue;
+                       if (S_ISLNK(statbuf.st_mode))
+                               continue;
+
                        attr_value = sysfs_attr_get_value(devpath, dent->d_name);
                        if (attr_value == NULL)
                                continue;
@@ -114,7 +129,7 @@ static int print_device_chain(const char *devpath)
                        break;
                printf("  looking at parent device '%s':\n", dev->devpath);
                printf("    KERNELS==\"%s\"\n", dev->kernel);
-               printf("    SUBSYTEMS==\"%s\"\n", dev->subsystem);
+               printf("    SUBSYSTEMS==\"%s\"\n", dev->subsystem);
                printf("    DRIVERS==\"%s\"\n", dev->driver);
 
                print_all_attributes(dev->devpath, "ATTRS");