mschorm / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
894b42f
--- util-linux-2.13-pre6/disk-utils/raw.c.kzak	2006-11-21 21:56:40.000000000 +0100
894b42f
+++ util-linux-2.13-pre6/disk-utils/raw.c	2006-11-21 22:35:11.000000000 +0100
894b42f
@@ -66,6 +66,7 @@
894b42f
 	int  err;
894b42f
 	int  block_major, block_minor;	
894b42f
 	int  i;
894b42f
+	int  rc;
894b42f
 
894b42f
 	struct stat statbuf;
894b42f
 	
894b42f
@@ -108,19 +109,23 @@
894b42f
 		usage(1);
894b42f
 	raw_name = argv[optind++];
894b42f
 
894b42f
+	rc = sscanf(raw_name, RAWDEVDIR "raw%d", &raw_minor);
894b42f
+	if (rc != 1) {
894b42f
+		fprintf (stderr, 
894b42f
+			 "Unsupported raw device name '%s' (format is " RAWDEVDIR "rawN))\n",
894b42f
+			 raw_name);
894b42f
+		exit(2);
894b42f
+	}
894b42f
+	if (raw_minor == 0) {
894b42f
+		fprintf (stderr,
894b42f
+			"Unsupported raw device name '%s' (minor number cannot be zero)\n",
894b42f
+			raw_name);
894b42f
+		exit(2);
894b42f
+	}
894b42f
+
894b42f
 	err = stat(raw_name, &statbuf);
894b42f
-	if (err) {
894b42f
-		int rc;
894b42f
-		
894b42f
-		rc = sscanf(raw_name, RAWDEVDIR "raw%d", &raw_minor);
894b42f
-		if (rc != 1) {
894b42f
-			fprintf (stderr, 
894b42f
-				 "Cannot locate raw device '%s' (%s)\n",
894b42f
-				 raw_name, strerror(errno));
894b42f
-			exit(2);
894b42f
-		}
894b42f
+	if (err) 
894b42f
 		goto skip_test_rawdev;
894b42f
-	}
894b42f
 	
894b42f
 	if (!S_ISCHR(statbuf.st_mode)) {
894b42f
 		fprintf (stderr, "raw device '%s' is not a character dev\n",