[PATCH] Use lstat() instead of stat() in sysfs lookup
Otherwise we cannot detect the symlinks, and the directory
lookup will get into an infinite loop.
diff --git a/stat.c b/stat.c
index 4cc3b7e..7f38d96 100644
--- a/stat.c
+++ b/stat.c
@@ -156,8 +156,6 @@
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
- if (!strcmp(dir->d_name, "device"))
- continue;
sprintf(full_path, "%s/%s", path, dir->d_name);
@@ -168,7 +166,7 @@
}
}
- if (stat(full_path, &st) == -1) {
+ if (lstat(full_path, &st) == -1) {
perror("stat");
break;
}