]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
linux: Remove invalid block OS devices on old k...
authorBrice Goglin <brice.goglin@inria.fr>
Fri, 14 Jun 2013 12:01:40 +0000 (12:01 +0000)
committerBrice Goglin <brice.goglin@inria.fr>
Fri, 14 Jun 2013 12:01:40 +0000 (12:01 +0000)
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.

src/topology-linux.c

index 1487224c3cb0ffa5e9f7af0b6b903bcc3d03cb0d..de664181bca2b0fafc02dd7f4f1102f3c2664d45 100644 (file)
@@ -3542,14 +3542,23 @@ hwloc_linux_class_readdir(struct hwloc_topology *topology, struct hwloc_obj *pci
   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;