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.
This commit is contained in:
parent
e17398c1a8
commit
7ccc05f810
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 strings */
|
||||
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(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;
|
||||
|
Loading…
Reference in New Issue
Block a user