Bug 85313 - mkraid fails to create /dev/md1 if /dev/md10 exists
Summary: mkraid fails to create /dev/md1 if /dev/md10 exists
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: raidtools
Version: 7.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Doug Ledford
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-02-27 21:53 UTC by Paul Clements
Modified: 2007-04-18 16:51 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-11-27 23:24:45 UTC


Attachments (Terms of Use)

Description Paul Clements 2003-02-27 21:53:12 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.7 [en] (X11; I; Linux 2.2.13 i686)

Description of problem:
I've verified that this problem affects at least raidtools 0.90 through 1.00
(Red Hat 7.2, 7.3, 8.0, and Advanced Server 2.1, at least).

In the code that checks to see if the array is already active (check_active(),
raid_io.c), the device matching is not done properly, and substring matches are
mistakenly considered matches. 

The patch (against raidtools-1.00.2-1.3, from Red Hat 7.3) for the fix is:

--- 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 fir
st.\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;





Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. mkraid -c <conf_file> /dev/md10

2. mkraid -c <conf_file> /dev/md1     **ALWAYS FAILS**
    

Additional info:


Note You need to log in before you can comment on or make changes to this bug.