From owner-freebsd-hackers Thu Feb 22 16:43: 4 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id DB40337B491; Thu, 22 Feb 2001 16:43:01 -0800 (PST) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id F09643E09; Thu, 22 Feb 2001 16:43:00 -0800 (PST) To: Robert Watson Cc: Dima Dorfman , freebsd-hackers@freebsd.org, phk@freebsd.org Subject: Re: Listing configured md(4) devices In-Reply-To: Message from Robert Watson of "Thu, 22 Feb 2001 14:31:29 EST." Date: Thu, 22 Feb 2001 16:43:00 -0800 From: Dima Dorfman Message-Id: <20010223004300.F09643E09@bazooka.unixfreak.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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