Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Feb 2001 16:43:00 -0800
From:      Dima Dorfman <dima@unixfreak.org>
To:        Robert Watson <rwatson@freebsd.org>
Cc:        Dima Dorfman <dima@unixfreak.org>, freebsd-hackers@freebsd.org, phk@freebsd.org
Subject:   Re: Listing configured md(4) devices 
Message-ID:  <20010223004300.F09643E09@bazooka.unixfreak.org>
In-Reply-To: Message from Robert Watson <rwatson@freebsd.org>  of "Thu, 22 Feb 2001 14:31:29 EST." <Pine.NEB.3.96L.1010222142758.49833G-100000@fledge.watson.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 2) I'm not sure I like the strncmp(.., "md", 2) stuff, as that means that
> it would also match any other device name that might begin with md, which
> potentially might not be provided by the md driver.  This is currently (I
> suspect) hypothetical as we don't have any other drivers beginning with
> md, but it would be nice not to preclude that in the future.  Restricting
> all possible disk device names to two letters, of which the second is
> always d, is not a scalable approach.  That said, writing an easy matching
> function without that assumption probably isn't all that easy, either.

Assuming that a device name must consist of letters (which I suspect
is the case), it's fairly trivial; just check that what follows 'md'
is a number.

Here's a patch against what I sent in previously to do that.  The
original with this included can be found at
http://www.unixfreak.org/~dima/home/md-list3.diff.

Thanks again

					Dima Dorfman
					dima@unixfreak.org


--- mdconfig.c.o2	Thu Feb 21 05:27:00 2001
+++ mdconfig.c	Thu Feb 22 16:32:34 2001
@@ -195,7 +195,7 @@
 int
 list(void)
 {
-	char *disklist, *p, *p2;
+	char *disklist, *p, *p2, *p3;
 	int dll;		/* disklist length */
 	int mds[512], *mdsp, mdsc, i;
 
@@ -211,7 +211,9 @@
 		if (strncmp(p2, "md", 2) != 0)
 			continue;
 		p2 += 2;
-		*mdsp = strtoul(p2, NULL, 10);
+		*mdsp = strtoul(p2, &p3, 10);
+		if (p2 == p3)
+			continue;
 		mdsc++;
 		if (++mdsp >= &mds[sizeof(mds)])
 			break;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010223004300.F09643E09>