Skip to contentSkip to conversation

Create new md devices consistently

PATCH Applied Justin Maggard 2 participants 2 messages Oct 23, 2012 – Oct 24, 2012 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Create new md devices consistently

Creating a new MD device with the name 'd-0' results in some unexpected behavior, since mdadm sees that '-0' is a non-negative integer and therefore makes a "partitionable" device (/dev/md_d0). This is not the expected behavior, since the documentation mentions 'dN' several places, and a reboot brings it up as /dev/md/d-0. Make this consistent by ensuring that the character immediately following 'd' is a digit during creation.

---
 mdopen.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mdopen.c +4 -1
index 61eda81..24188df 100644
@@ -207,7 +207,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 			char *ep;
 			if (cname[0] == 'd')
 				sp++;
-			num = strtoul(sp, &ep, 10);
+			if (isdigit(sp[0]))
+				num = strtoul(sp, &ep, 10);
+			else
+				ep = sp;
 			if (ep == sp || *ep || num < 0)
 				num = -1;
 			else if (cname[0] == 'd')
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 19 lines · On Tue, 23 Oct 2012 15:04:00 -0700 Justin Maggard <[email protected]> wrote:

Creating a new MD device with the name 'd-0' results in some unexpected behavior, since mdadm sees that '-0' is a non-negative integer and therefore makes a "partitionable" device (/dev/md_d0). This is not the expected behavior, since the documentation mentions 'dN' several places, and a reboot brings it up as /dev/md/d-0. Make this consistent by ensuring that the character immediately following 'd' is a digit during creation.

---
 mdopen.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mdopen.c +0 -0
index 61eda81..24188df 100644
@@ -207,7 +207,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 			char *ep;

mdopen.c int create_mddev(char *dev, char *name, int autof, int trustworthy, · line 216

Quoted 10 lines
mdopen.c +4 -1
 			if (cname[0] == 'd')
 				sp++;
-			num = strtoul(sp, &ep, 10);
+			if (isdigit(sp[0]))
+				num = strtoul(sp, &ep, 10);
+			else
+				ep = sp;
 			if (ep == sp || *ep || num < 0)
 				num = -1;
 			else if (cname[0] == 'd')

applied, thanks.

Will be in mdadm-3.2.6 which I plan to release tomorrow.

NeilBrown