diff options
-rw-r--r-- | pci.c | 19 | ||||
-rw-r--r-- | usb.c | 13 |
2 files changed, 16 insertions, 16 deletions
@@ -7,7 +7,8 @@ #include "libldetect-private.h" #include "common.h" -char *proc_pci_path = "/proc/bus/pci/devices"; +char *proc_pci_path_default = "/proc/bus/pci/devices"; +char *proc_pci_path = NULL; extern struct pciusb_entries pci_probe(int probe_type) { FILE *f, *devf; @@ -19,13 +20,15 @@ extern struct pciusb_entries pci_probe(int probe_type) { char file[25]; r.nb = 0; - 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); - free(err_msg); + if (!(f = fopen(proc_pci_path ? proc_pci_path : proc_pci_path_default, "r"))) { + if (proc_pci_path) { + 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); + free(err_msg); + } r.entries = NULL; return r; } @@ -7,7 +7,8 @@ #include "libldetect-private.h" #include "common.h" -char *proc_usb_path = "/proc/bus/usb/devices"; +char *proc_usb_path_default = "/proc/bus/usb/devices"; +char *proc_usb_path = NULL; extern struct pciusb_entries usb_probe(void) { @@ -17,14 +18,10 @@ extern struct pciusb_entries usb_probe(void) { struct pciusb_entries r; struct pciusb_entry *e = NULL; r.nb = 0; - if (access(proc_usb_path, R_OK) != 0) { - r.entries = NULL; - return r; - } - if (!(f = fopen(proc_usb_path, "r"))) { - char *err_msg; - if (proc_usb_path==NULL || strcmp(proc_usb_path, "/proc/bus/usb/devices")) { + if (!(f = fopen(proc_usb_path ? proc_usb_path : proc_usb_path_default, "r"))) { + if (proc_usb_path) { + char *err_msg; 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); |