[Ocfs-tools-commits] smushran commits r219 - in trunk: format libocfs

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Oct 7 15:55:29 CDT 2004


Author: smushran
Date: 2004-10-07 15:55:26 -0500 (Thu, 07 Oct 2004)
New Revision: 219

Modified:
   trunk/format/Cscope.make
   trunk/libocfs/bindraw.c
Log:
bug#3924112 fixed
bind_raw now ensures that the raw device it is binding to exists :-)

Modified: trunk/format/Cscope.make
===================================================================
--- trunk/format/Cscope.make	2004-09-22 22:27:49 UTC (rev 218)
+++ trunk/format/Cscope.make	2004-10-07 20:55:26 UTC (rev 219)
@@ -6,4 +6,5 @@
 	find . -maxdepth 2 -name '*.c' -print >>cscope.files
 	find . -maxdepth 2 -name '*.h' -print >>cscope.files
 	find ../libocfs -name '*.h' -print >>cscope.files
+	find ../libocfs -name '*.c' -print >>cscope.files
 	cscope -b

Modified: trunk/libocfs/bindraw.c
===================================================================
--- trunk/libocfs/bindraw.c	2004-09-22 22:27:49 UTC (rev 218)
+++ trunk/libocfs/bindraw.c	2004-10-07 20:55:26 UTC (rev 219)
@@ -39,6 +39,7 @@
 	int i;
 	struct raw_config_request rcs;
 	struct stat statbuf;
+	dev_t st_rdev = 0;
 	int ret = -1;
 
 	memset(&statbuf, 0, sizeof(struct stat));
@@ -47,7 +48,8 @@
 		goto bail;
 	}
 
-	if (MAJOR(statbuf.st_rdev) == 0) {
+	st_rdev = statbuf.st_rdev;
+	if (MAJOR(st_rdev) == 0) {
 		LOG_ERROR("Invalid device %s", blk_dev);
 		goto bail;
 	}
@@ -65,6 +67,12 @@
 		}
 
 		for (i = 1; i < 255; ++i) {
+			snprintf(raw_dev, rdlen, "/dev/raw/raw%d", i);
+			memset(&statbuf, 0, sizeof(struct stat));
+			if (stat(raw_dev, &statbuf) == -1)
+				continue;
+			if (!S_ISCHR(statbuf.st_mode))
+				continue;
 			memset(&rcs, 0, sizeof(struct raw_config_request));
 			rcs.raw_minor = i;
 			if (ioctl(fd, RAW_GETBIND, &rcs) == -1)
@@ -79,11 +87,10 @@
 		}
 
 		*raw_minor = i;
-		snprintf(raw_dev, rdlen, "/dev/raw/raw%d", i);
 
 		rcs.raw_minor = i;
-		rcs.block_major = (__u64)MAJOR(statbuf.st_rdev);
-		rcs.block_minor = (__u64)MINOR(statbuf.st_rdev);
+		rcs.block_major = (__u64)MAJOR(st_rdev);
+		rcs.block_minor = (__u64)MINOR(st_rdev);
 		if (ioctl(fd, RAW_SETBIND, &rcs) == -1) {
 			LOG_ERROR("%s", strerror(errno));
 			*raw_minor = 0;



More information about the Ocfs-tools-commits mailing list