From d8b462341b5cee958671aaeb8718fc0b3c92a78f Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 21 Mar 2001 18:03:32 +0000 Subject: if subid can be useful, use them. use probe_type==-1 to ensure no subid is used --- pciusb.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'pciusb.c') diff --git a/pciusb.c b/pciusb.c index 29b1d99..b023181 100644 --- a/pciusb.c +++ b/pciusb.c @@ -5,13 +5,20 @@ #include "libldetect-private.h" #include "common.h" -extern void pciusb_find_modules(struct pciusb_entries entries, const char *fpciusbtable) { +extern int pciusb_find_modules(struct pciusb_entries entries, const char *fpciusbtable, int no_subid) { FILE *f; char buf[2048]; int line; - if (!(f = fopen(fpciusbtable, "r"))) { - fprintf(stderr, "Missing pciusbtable (should be %s)\n", fpciusbtable); + char *share_path = getenv("SHARE_PATH"); + char *fname; + if (!share_path || !*share_path) share_path = "/usr/share"; + + fname = alloca(strlen(share_path) + sizeof("/ldetect-lst/") + strlen(fpciusbtable)); + sprintf(fname, "%s/ldetect-lst/%s", share_path, fpciusbtable); + + if (!(f = fopen(fname, "r"))) { + fprintf(stderr, "Missing pciusbtable (should be %s)\n", fname); exit(1); } for (line = 1; fgets(buf, sizeof(buf) - 1, f); line++) { @@ -27,8 +34,14 @@ extern void pciusb_find_modules(struct pciusb_entries entries, const char *fpciu } for (i = 0; i < entries.nb; i++) { struct pciusb_entry *e = &entries.entries[i]; - if (vendor == e->vendor && device == e->device && - (nb != 4 || (subvendor == e->subvendor && subdevice == e->subdevice)) && !e->module) { + if (vendor == e->vendor && device == e->device) { + if (nb == 4 && e->subvendor == 0xffff && e->subdevice == 0xffff && !no_subid) { + pciusb_free(entries); + fclose(f); + return 0; /* leave, let the caller call again with subids */ + } + + if ((nb != 4 || (subvendor == e->subvendor && subdevice == e->subdevice)) && !e->module) { char *p = buf + offset + 1; char *q = strchr(p, '\t'); if (q) { @@ -37,10 +50,12 @@ extern void pciusb_find_modules(struct pciusb_entries entries, const char *fpciu e->module = strcmp(p, "unknown") ? strdup(p) : NULL; e->text = strdup(q+2); } - } - } + } + } + } } fclose(f); + return 1; } extern void pciusb_initialize(struct pciusb_entry *e) { -- cgit v1.2.1