linux: Remove invalid block OS devices on old kernels
2.6.9/RHEL4 (on eddie) have a "block" symlink in their device
subdirectory of PCI sysfs devices (and nothing for other classes).
We only handle block/<name> (modern kernels) and block:<name>
(old but not so ancient kernels).
Our code confuses this 2.6.9 case with the modern one, causing
crazy OS device such as "queue" to appear.
Fix that case by just not creating anything in these PCI devices
since there's no easy way to find the OS device name,
and we don't care much about these kernels anyway.
This commit was SVN r5668.
DIR *dir;
struct dirent *dirent;
hwloc_obj_t obj;
- int res = 0;
+ int res = 0, err;
if (hwloc_linux_deprecated_classlinks_model == -2)
hwloc_linux_check_deprecated_classlinks_model();
if (hwloc_linux_deprecated_classlinks_model != 1) {
/* modern sysfs: <device>/<class>/<name> */
+ struct stat st;
snprintf(path, sizeof(path), "%s/%s", devicepath, classname);
+
+ /* some very host kernel (2.6.9/RHEL4) have <device>/<class> symlink without any way to find <name>.
+ * make sure <device>/<class> is a directory to avoid this case.
+ */
+ err = lstat(path, &st);
+ if (err < 0 || !S_ISDIR(st.st_mode))
+ return 0;
+
dir = opendir(path);
if (dir) {
hwloc_linux_deprecated_classlinks_model = 0;