X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udevinfo.c;h=5445b0fcc13e0ad1e6463a9b8439490e0afada35;hb=c7c00276f6f26ff7f38e99d887137bc1f172a978;hp=d1d77152c3ffed3ad82bc4eb305a8508d84c8a06;hpb=11f1bb5ab42571fae5cc607d42b8d918c9e170ab;p=elogind.git diff --git a/udevinfo.c b/udevinfo.c index d1d77152c..5445b0fcc 100644 --- a/udevinfo.c +++ b/udevinfo.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #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"); @@ -168,7 +183,7 @@ int main(int argc, char *argv[], char *envp[]) struct udevice *udev; int root = 0; - struct option options[] = { + static const struct option options[] = { { "name", 1, NULL, 'n' }, { "path", 1, NULL, 'p' }, { "query", 1, NULL, 'q' },