diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-03-23 15:17:43 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-03-23 15:17:43 +0000 |
commit | 48d194b2bac10dfb92707d4e7578ba58b09bc18b (patch) | |
tree | da75b56a535e35c2ba1835f1c2df8a08204f2a76 | |
parent | 8a69bcc11199f9b5091ebbfa644c3968299d9e25 (diff) | |
download | ldetect-48d194b2bac10dfb92707d4e7578ba58b09bc18b.tar ldetect-48d194b2bac10dfb92707d4e7578ba58b09bc18b.tar.gz ldetect-48d194b2bac10dfb92707d4e7578ba58b09bc18b.tar.bz2 ldetect-48d194b2bac10dfb92707d4e7578ba58b09bc18b.tar.xz ldetect-48d194b2bac10dfb92707d4e7578ba58b09bc18b.zip |
handle gzip'ed pcitable/usbtable
-rw-r--r-- | ldetect.spec | 5 | ||||
-rw-r--r-- | pciusb.c | 20 |
2 files changed, 19 insertions, 6 deletions
diff --git a/ldetect.spec b/ldetect.spec index dd75e69..ac3cdeb 100644 --- a/ldetect.spec +++ b/ldetect.spec @@ -1,7 +1,7 @@ # !! DON'T MODIFY HERE, MODIFY IN THE CVS !! %define name ldetect %define version 0.2.3 -%define release 8mdk +%define release 9mdk Name: %{name} Version: %{version} @@ -53,6 +53,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/* %changelog +* Fri Mar 23 2001 Pixel <pixel@mandrakesoft.com> 0.2.3-9mdk +- handle gzip'ed pcitable/usbtable + * Wed Mar 21 2001 Pixel <pixel@mandrakesoft.com> 0.2.3-8mdk - use subids if they are needed @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "libldetect.h" #include "libldetect-private.h" #include "common.h" @@ -8,16 +9,25 @@ extern int pciusb_find_modules(struct pciusb_entries entries, const char *fpciusbtable, int no_subid) { FILE *f; char buf[2048]; - int line; + int line, length; char *share_path = getenv("SHARE_PATH"); - char *fname; + char *fname, *fname_gz; 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); + length = strlen(share_path) + sizeof("/ldetect-lst/") + strlen(fpciusbtable); + fname = alloca(length); + fname_gz = alloca(length + sizeof(".gz")); + sprintf(fname, "%s/ldetect-lst/%s", share_path, fpciusbtable); + sprintf(fname_gz, "%s/ldetect-lst/%s.gz", share_path, fpciusbtable); - if (!(f = fopen(fname, "r"))) { + if (access(fname, R_OK) == 0) { + f = fopen(fname, "r"); + } else if (access(fname_gz, R_OK) == 0) { + char *cmd = alloca(sizeof("gzip -dc %s") + strlen(fname_gz)); + sprintf(cmd, "gzip -dc %s", fname_gz); + f = popen(cmd, "r"); + } else { fprintf(stderr, "Missing pciusbtable (should be %s)\n", fname); exit(1); } |