diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-07-16 15:29:55 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-07-16 15:29:55 +0000 |
commit | 3dfdaa1a0d7148f925339f060f9ccbc8ce3a7bc3 (patch) | |
tree | 440a8eaf9bb1bc82507c71d8b883b944f03cbeea | |
parent | 3f6174dc0fcbfbd9a8e66220e6f166180eb4302c (diff) | |
download | ldetect-3dfdaa1a0d7148f925339f060f9ccbc8ce3a7bc3.tar ldetect-3dfdaa1a0d7148f925339f060f9ccbc8ce3a7bc3.tar.gz ldetect-3dfdaa1a0d7148f925339f060f9ccbc8ce3a7bc3.tar.bz2 ldetect-3dfdaa1a0d7148f925339f060f9ccbc8ce3a7bc3.tar.xz ldetect-3dfdaa1a0d7148f925339f060f9ccbc8ce3a7bc3.zip |
- print error message if unable to open the arguement passed to -u,-p
- print error message if usb service isn't started (commented for now
to follow previous behaviour)
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | pci.c | 10 | ||||
-rw-r--r-- | usb.c | 22 |
3 files changed, 40 insertions, 2 deletions
@@ -1,3 +1,13 @@ +2002-07-16 17:07 tvignaud + + * ChangeLog, ldetect.spec, libldetect-private.h, lspcidrake.c, + pci.c: - pci.c: add the ability to read pci devices list from a + file instead of /proc/bus/pci/devices + + - spec: prepare for next release + + - add ChangeLog + 2002-07-16 16:54 tvignaud * libldetect-private.h, lspcidrake.c, usb.c: - move usb devices @@ -1,3 +1,5 @@ +#include <unistd.h> +#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -16,8 +18,14 @@ extern struct pciusb_entries pci_probe(int probe_type) { struct pciusb_entries r; r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES); - if (!(f = fopen(proc_pci_path, "r"))) + if (!(f = fopen(proc_pci_path, "r"))) { + char *err_msg; + asprintf(&err_msg, "unable to open \"%s\"\n" + "You may have passed a wrong argument to the \"-p\" option.\n" + "fopen() sets errno to", proc_pci_path); + perror(err_msg); exit(1); + } for (r.nb = 0; fgets(buf, sizeof(buf) - 1, f) && r.nb < MAX_DEVICES; r.nb++) { struct pciusb_entry *e = &r.entries[r.nb]; @@ -1,3 +1,5 @@ +#include <unistd.h> +#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -16,8 +18,26 @@ extern struct pciusb_entries usb_probe(void) { struct pciusb_entries r; struct pciusb_entry *e = NULL; - if (!(f = fopen(proc_usb_path, "r"))) + if (access(proc_pci_path, R_OK) != 0) { + printf( "TOTO\n"); exit(1); + } + + if (!(f = fopen(proc_usb_path, "r"))) { + char *err_msg; + if (proc_usb_path==NULL || strcmp(proc_usb_path, "/proc/bus/usb/devices")) { + asprintf(&err_msg, "unable to open \"%s\"\n" + "You may have passed a wrong argument to the \"-u\" option.\n" + "fopen() sets errno to", proc_usb_path); + perror(err_msg); + } /*else { + asprintf(&err_msg, "unable to open \"%s\"\n" + "You should enable the usb service (as root, type 'service usb start'.\n" + "fopen() sets errno to", proc_usb_path); + perror(err_msg); + } */ + exit(1); + } for(r.nb = line = 0; fgets(buf, sizeof(buf) - 1, f) && r.nb < psizeof(t); line++) { if (buf[0] == 'P') { |