Re: Suggested patch against raidtools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simon Edwards wrote:

> if you try and use "md1" and "md10"
> you'll get an error saying the device is already running.

Hmm...coincidentally, I just reported this same bug to Red Hat a couple
of days ago. The patch that I came up with is attached...although, yours
seems to be a little simpler.

--
Paul
diff -urN raidtools-1.00.2/raid_io.c raidtools-1.00.2steeleye/raid_io.c
--- raidtools-1.00.2/raid_io.c	Mon Apr 15 04:09:11 2002
+++ raidtools-1.00.2steeleye/raid_io.c	Thu Feb 27 15:22:07 2003
@@ -515,8 +515,10 @@
 }
 
 
+
 int check_active (md_cfg_entry_t *p)
 {
+	char md_dev_chars[] = "0123456789md";
 	char buffer[MAX_LINE_LENGTH], line[MAX_LINE_LENGTH], *ch;
 	FILE *fp;
 
@@ -528,11 +530,15 @@
 	while (1) {
 		if ((fgets(line, MAX_LINE_LENGTH, fp)) == NULL)
 			break;
-		if (strstr(line, buffer) && !strstr(line, "inactive")) {
-			fprintf(stderr, "%s: array is active -- run raidstop first.\n", p->md_name);
-			fclose(fp);
-			return 1;
-		}
+		if (!(ch = strstr(line, buffer)))
+			continue;
+		if (strspn(ch, md_dev_chars) != strspn(buffer, md_dev_chars))
+			continue;
+		if (strstr(line, "inactive"))
+			continue;
+		fprintf(stderr, "%s: array is active -- run raidstop first.\n", p->md_name);
+		fclose(fp);
+		return 1;
 	}
 	fclose(fp);
 	return 0;

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux