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 /usb.c | |
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)
Diffstat (limited to 'usb.c')
-rw-r--r-- | usb.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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') { |