Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 May 2000 21:08:00 +0900
From:      Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
To:        dcs@newsguy.com
Cc:        imp@freebsd.org, iwasaki@freebsd.org, mobile@freebsd.org
Subject:   Re: Bug on readcis.c r1.19
Message-ID:  <20000510210800Y.iwasaki@jp.FreeBSD.org>
In-Reply-To: <200005100540.OAA00517@daniel.sobral>
References:  <200005100540.OAA00517@daniel.sobral>

next in thread | previous in thread | raw e-mail | index | archive | help
> My pccardd has been core dumping since my last upgrade. I think the
> following change (revision 1.19 or readcis.c) is the responsible:

Yes, CardBus cards make pccardd core dumped as you pointed out.
The following cis_ctrcmp() was supposed to merge replacing strcmp()
but I hesitated about rewriting entries in pccard.conf to use regex.

Index: cardd.c
===================================================================
RCS file: /miserv/home/ncvs/src/usr.sbin/pccard/pccardd/cardd.c,v
retrieving revision 1.51
diff -u -r1.51 cardd.c
--- cardd.c	2000/05/09 22:01:16	1.51
+++ cardd.c	2000/05/10 12:01:54
@@ -206,6 +206,41 @@
 		pool_irq[sp->irq] = 1;
 }
 
+/* regex CIS string comparison (hosokawa) */
+
+#define	REGCOMP_FLAGS	(REG_EXTENDED | REG_NOSUB)
+#define	REGEXEC_FLAGS	(0)
+
+static int
+cis_strcmp(char *db, char *cis)
+{
+	int     res, err;
+	char    buf[256];
+	regex_t rx;
+	char *	p;
+	size_t	n;
+
+	if (!db || !cis) {
+		return -1;
+	}
+	n = strlen(db);
+	p = xmalloc(n + 2);
+	strcpy(p + 1, db);
+	*p = '^';
+	db = p;
+	if ((err = regcomp(&rx, p, REGCOMP_FLAGS))) {
+		regerror(err, &rx, buf, sizeof buf);
+		logmsg("Warning: REGEX error for\"%s\" -- %s\n", p, buf);
+		regfree(&rx);
+		free(p);
+		return -1;
+	}
+	res = regexec(&rx, cis, 0, NULL, REGEXEC_FLAGS);
+	regfree(&rx);
+	free(p);
+	return res;
+}
+
 /*
  * card_inserted - Card has been inserted;
  *	- Read the CIS
@@ -235,8 +270,8 @@
 	for (cp = cards; cp; cp = cp->next) {
 		switch (cp->deftype) {
 		case DT_VERS:
-			if (strcmp(cp->manuf, sp->cis->manuf) == 0 &&
-			    strcmp(cp->version, sp->cis->vers) == 0) {
+			if (cis_strcmp(cp->manuf, sp->cis->manuf) == 0 &&
+			    cis_strcmp(cp->version, sp->cis->vers) == 0) {
 				logmsg("Card \"%s\"(\"%s\") "
 					"matched \"%s\" (\"%s\") ",
 					sp->cis->manuf, sp->cis->vers,

So I'm thinking introduce 'regex' prefix for strings such as 
manufacturer, card version, etc. for new entries, like this.
	card "SunDisk" "regex:SDP*"

Without 'regex' prefix, we just use strcmp() in cis_strcmp().

Any comments?



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




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