Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 3f45271d10a73cfaf7cbf86979da0f6d > files > 6

device-mapper-multipath-0.4.7-34.el5_5.4.src.rpm

---
 libmultipath/discovery.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Index: multipath-tools-599053/libmultipath/discovery.c
===================================================================
--- multipath-tools-599053.orig/libmultipath/discovery.c
+++ multipath-tools-599053/libmultipath/discovery.c
@@ -171,11 +171,14 @@ out:
 #define WAIT_LOOP_PER_SECOND 5
 
 static int
-wait_for_file (char * filename)
+wait_for_file (char * filename, char * sysfs_path, char * dev)
 {
 	int loop;
 	struct stat stats;
-	
+	char dev_dir[SYSFS_PATH_SIZE];
+
+	if (sysfs_path && safe_sprintf(dev_dir, "%s/block/%s", sysfs_path, dev))
+		return 1;
 	loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
 	
 	while (--loop) {
@@ -185,13 +188,16 @@ wait_for_file (char * filename)
 		if (errno != ENOENT)
 			return 1;
 
+		if (sysfs_path && stat(dev_dir, &stats) != 0)
+			return 1;
+
 		usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
 	}
 	return 1;
 }
 #else
 static int
-wait_for_file (char * filename)
+wait_for_file (char * filename, char * sysfs_path, char * dev)
 {
 	return 0;
 }
@@ -207,7 +213,7 @@ sysfs_get_##fname (char * sysfs_path, ch
 	if (safe_sprintf(attr_path, fmt, sysfs_path, dev)) \
 		return 1; \
 \
-	if (dowait && wait_for_file(attr_path)) \
+	if (dowait && wait_for_file(attr_path, sysfs_path, dev)) \
 		return 1; \
 \
 	if (!(attr = sysfs_open_attribute(attr_path))) \
@@ -320,7 +326,7 @@ opennode (char * dev, int mode)
 		return -1;
 	}
 
-	if (wait_for_file(devpath)) {
+	if (wait_for_file(devpath, NULL, NULL)) {
 		condlog(3, "failed to open %s", devpath);
 		return -1;
 	}