diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-07-16 14:54:45 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-07-16 14:54:45 +0000 |
commit | 667f94e4543832186ed073bbefa5873096f9c369 (patch) | |
tree | 710ffff3a79b3f4d99ce1940079c154bf7da1348 | |
parent | f37544e3e0ec9f33b8440dac9fba28637415d494 (diff) | |
download | ldetect-667f94e4543832186ed073bbefa5873096f9c369.tar ldetect-667f94e4543832186ed073bbefa5873096f9c369.tar.gz ldetect-667f94e4543832186ed073bbefa5873096f9c369.tar.bz2 ldetect-667f94e4543832186ed073bbefa5873096f9c369.tar.xz ldetect-667f94e4543832186ed073bbefa5873096f9c369.zip |
- move usb devices proc entry path into
libldetect-private.h::proc_usb_path
- add -u option so that lspcidrake can read usb devices from a file in
order to understand what happened to remote testers
- make if (test) action clearer by rejecting action singleton in next
line
- lspcidrake: describe all options
-rw-r--r-- | libldetect-private.h | 3 | ||||
-rw-r--r-- | lspcidrake.c | 13 | ||||
-rw-r--r-- | usb.c | 9 |
3 files changed, 18 insertions, 7 deletions
diff --git a/libldetect-private.h b/libldetect-private.h index 9addd46..7f6d82b 100644 --- a/libldetect-private.h +++ b/libldetect-private.h @@ -3,3 +3,6 @@ extern void pciusb_initialize(struct pciusb_entry *e); #define MAX_DEVICES 100 #define BUF_SIZE 512 + + +extern char *proc_usb_path; diff --git a/lspcidrake.c b/lspcidrake.c index fccecb3..ace91e4 100644 --- a/lspcidrake.c +++ b/lspcidrake.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> #include "libldetect.h" +#include "libldetect-private.h" static int verboze = 0; @@ -14,7 +15,8 @@ static void printit(struct pciusb_entries entries, const char *(find_class)(unsi else printf("unknown (%04x/%04x/%04x/%04x)", e->vendor, e->device, e->subvendor, e->subdevice); if (e->class_) { const char *class_ = find_class(e->class_); - if (strcmp(class_, "NOT_DEFINED") != 0) printf(" [%s]", class_); + if (strcmp(class_, "NOT_DEFINED") != 0) + printf(" [%s]", class_); } if (verboze && e->text) { printf(" (vendor:%04x device:%04x", e->vendor, e->device); @@ -25,7 +27,6 @@ static void printit(struct pciusb_entries entries, const char *(find_class)(unsi printf("\n"); } pciusb_free(&entries); - } @@ -35,7 +36,11 @@ int main(int argc, char **argv) { while (ptr && *ptr) { if (!strcmp(*ptr, "-h") || !strcmp(*ptr, "--help")) { - printf("usage: lspcidrake [-v] [-f]\n"); + printf("usage: lspcidrake [-v|-f|-u]\n" + "-f : full probe\n" + "-u : usb devices source [/proc/usb/devices by default\n" + "-v : verbose mode [print ids and sub-ids], implies full probe\n" + ); return 0; } if (!strcmp(*ptr, "-v")) { @@ -44,6 +49,8 @@ int main(int argc, char **argv) { } if (!strcmp(*ptr, "-f")) full_probe = 1; + if (!strcmp(*ptr, "-u")) + proc_usb_path = *++ptr; ptr++; } @@ -5,17 +5,18 @@ #include "libldetect-private.h" #include "common.h" +char *proc_usb_path = "/proc/bus/usb/devices"; + extern struct pciusb_entries usb_probe(void) { FILE *f; char buf[BUF_SIZE]; int line; - const char *file = "/proc/bus/usb/devices"; struct pciusb_entry t[MAX_DEVICES]; struct pciusb_entries r; struct pciusb_entry *e = NULL; - if (!(f = fopen(file, "r"))) + if (!(f = fopen(proc_usb_path, "r"))) exit(1); for(r.nb = line = 0; fgets(buf, sizeof(buf) - 1, f) && r.nb < psizeof(t); line++) { @@ -24,7 +25,7 @@ extern struct pciusb_entries usb_probe(void) { pciusb_initialize(e); if (sscanf(buf, "P: Vendor=%hx ProdID=%hx", &e->vendor, &e->device) != 2) { - fprintf(stderr, "%s %d: unknown ``P'' line\n", file, line); + fprintf(stderr, "%s %d: unknown ``P'' line\n", proc_usb_path, line); pciusb_initialize(e); } } else if (e && buf[0] == 'I' && e->class_ == 0) { @@ -32,7 +33,7 @@ extern struct pciusb_entries usb_probe(void) { if (sscanf(buf, "I: If#=%*2d Alt=%*2d #EPs=%*2d Cls=%02x(%*5c) Sub=%02x Prot=%02x", &class_, &sub, &prot) == 3) { e->class_ = (class_ * 0x100 + sub) * 0x100 + prot; } else { - fprintf(stderr, "%s %d: unknown ``I'' line\n", file, line); + fprintf(stderr, "%s %d: unknown ``I'' line\n", proc_usb_path, line); } } else if (e && buf[0] == 'S') { int offset; |