summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pccard
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-07-14 19:46:35 +0000
committerimp <imp@FreeBSD.org>2000-07-14 19:46:35 +0000
commitacd7546a67db1926696e754ee739eb1ae893bd06 (patch)
treee8ea964b249d1cdce92b464e6602957a2176aa4a /usr.sbin/pccard
parent93834f413c7f91e7f12f82e673769c9501f56bca (diff)
downloadFreeBSD-src-acd7546a67db1926696e754ee739eb1ae893bd06.zip
FreeBSD-src-acd7546a67db1926696e754ee739eb1ae893bd06.tar.gz
Add new keyword "logstr". By default, we now use syslog outselves to
log insert/remove events using the logstr, if specified for that card, or the manufacturer + version strings from the cis if not. This eliminates the need to have logger in the pccard.conf file which makes it easier to move pcardd to /sbin later if we need to. This also reduces the pccard.conf file size from 53k to 28k, which will help the install disk a little. Also, minor cleanup of free usage (if (x != NULL) free(x); is identical to free(x); for all versions of C that we care about). Reviewed by: iwasaki (who proposed the logstr keyword). Documentation and fixes to pccard.conf to follow.
Diffstat (limited to 'usr.sbin/pccard')
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c5
-rw-r--r--usr.sbin/pccard/pccardd/cardd.h1
-rw-r--r--usr.sbin/pccard/pccardd/file.c24
3 files changed, 21 insertions, 9 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index c8a5756..0f65460 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -188,6 +188,9 @@ card_removed(struct slot *sp)
struct card *cp;
int in_use = 0;
+ if (sp->config && sp->config->driver && sp->card)
+ logmsg("%s%d: %s removed.", sp->config->driver->kernel,
+ sp->config->driver->unit, sp->card->logstr);
if (sp->cis)
freecis(sp->cis);
if (sp->config) {
@@ -836,5 +839,7 @@ setup_slot(struct slot *sp)
break;
}
}
+ logmsg("%s%d: %s inserted.", sp->config->driver->kernel,
+ sp->config->driver->unit, sp->card->logstr);
return (1);
}
diff --git a/usr.sbin/pccard/pccardd/cardd.h b/usr.sbin/pccard/pccardd/cardd.h
index 675cc5a..b6dde10 100644
--- a/usr.sbin/pccard/pccardd/cardd.h
+++ b/usr.sbin/pccard/pccardd/cardd.h
@@ -77,6 +77,7 @@ struct card {
struct card_config *config; /* List of configs */
struct cmd *insert; /* Insert commands */
struct cmd *remove; /* Remove commands */
+ char *logstr; /* String for logger */
};
struct driver {
diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c
index db96e62..ec3010c 100644
--- a/usr.sbin/pccard/pccardd/file.c
+++ b/usr.sbin/pccard/pccardd/file.c
@@ -63,6 +63,7 @@ static char *keys[] = {
"debuglevel", /* 13 */
"include", /* 14 */
"function", /* 15 */
+ "logstr", /* 16 */
0
};
@@ -81,6 +82,7 @@ static char *keys[] = {
#define KWD_DEBUGLEVEL 13
#define KWD_INCLUDE 14
#define KWD_FUNCTION 15
+#define KWD_LOGSTR 16
/* for keyword compatibility with PAO/plain FreeBSD */
static struct {
@@ -124,15 +126,12 @@ delete_card(struct card *cp)
struct card_config *configp, *config_next;
struct cmd *cmdp, *cmd_next;
- /* free characters */
- if (cp->manuf != NULL)
- free(cp->manuf);
- if (cp->version != NULL)
- free(cp->version);
- if (cp->add_info1 != NULL)
- free(cp->add_info1);
- if (cp->add_info2 != NULL)
- free(cp->add_info2);
+ /* free strings */
+ free(cp->manuf);
+ free(cp->version);
+ free(cp->add_info1);
+ free(cp->add_info2);
+ free(cp->logstr);
/* free structures */
for (etherp = cp->ether; etherp; etherp = ether_next) {
@@ -434,11 +433,14 @@ parse_card(int deftype)
}
cp->manuf = man;
cp->version = vers;
+ cp->logstr = NULL;
+ asprintf(&cp->logstr, "%s (%s)", man, vers);
cp->func_id = 0;
break;
case DT_FUNC:
cp->manuf = NULL;
cp->version = NULL;
+ cp->logstr = NULL;
cp->func_id = (u_char) func_tok();
break;
default:
@@ -542,6 +544,10 @@ parse_card(int deftype)
}
cp->iosize = iosize;
break;
+ case KWD_LOGSTR:
+ free(cp->logstr);
+ cp->logstr = newstr(next_tok());
+ break;
default:
pusht = 1;
return;
OpenPOWER on IntegriCloud