From 648b26a9d0ca38c5a1dea63d4410764f83c4a226 Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Fri, 14 Jun 2013 12:01:40 +0000 Subject: [PATCH] linux: Remove invalid block OS devices on old k... 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/ (modern kernels) and block: (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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/topology-linux.c b/src/topology-linux.c index 1487224c..de664181 100644 --- a/src/topology-linux.c +++ b/src/topology-linux.c @@ -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: // */ + struct stat st; snprintf(path, sizeof(path), "%s/%s", devicepath, classname); + + /* some very host kernel (2.6.9/RHEL4) have / symlink without any way to find . + * make sure / 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; -- 2.39.5