summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2001-04-11 16:53:18 +0000
committerFrancois Pons <fpons@mandriva.com>2001-04-11 16:53:18 +0000
commitee28b109e91016449ae2fa1e6dbfb7ef5d0da2c3 (patch)
tree87493da13e719de823880dbbf31c4595bba64ba5
parent7026c4726fc3f8d1cf7a2ee6a369e651c3de0974 (diff)
downloadldetect-ee28b109e91016449ae2fa1e6dbfb7ef5d0da2c3.tar
ldetect-ee28b109e91016449ae2fa1e6dbfb7ef5d0da2c3.tar.gz
ldetect-ee28b109e91016449ae2fa1e6dbfb7ef5d0da2c3.tar.bz2
ldetect-ee28b109e91016449ae2fa1e6dbfb7ef5d0da2c3.tar.xz
ldetect-ee28b109e91016449ae2fa1e6dbfb7ef5d0da2c3.zip
*** empty log message ***
-rw-r--r--ldetect.spec5
-rw-r--r--pciusb.c45
2 files changed, 36 insertions, 14 deletions
diff --git a/ldetect.spec b/ldetect.spec
index a5f0feb..367cfd4 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 11mdk
+%define release 12mdk
Name: %{name}
Version: %{version}
@@ -53,6 +53,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/*
%changelog
+* Wed Apr 11 2001 François Pons <fpons@mandrakesoft.com> 0.2.3-12mdk
+- fixed to use LD_LOADER if defined.
+
* Thu Mar 29 2001 Pixel <pixel@mandrakesoft.com> 0.2.3-11mdk
- fix some memory leak and a few segfaults
diff --git a/pciusb.c b/pciusb.c
index e5cf391..18abdc0 100644
--- a/pciusb.c
+++ b/pciusb.c
@@ -1,14 +1,18 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+
#include "libldetect.h"
#include "libldetect-private.h"
#include "common.h"
typedef struct {
FILE *f;
- enum { fh_normal, fh_pipe } type;
+ pid_t pid;
} fh;
static fh fh_open(char *fname) {
@@ -19,12 +23,30 @@ static fh fh_open(char *fname) {
if (access(fname, R_OK) == 0) {
ret.f = fopen(fname, "r");
- ret.type = fh_normal;
- } 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);
- ret.f = popen(cmd, "r");
- ret.type = fh_pipe;
+ ret.pid = 0;
+ } else if (access(fname_gz, R_OK) == 0) {
+ int fdno[2];
+ if (pipe(fdno)) { perror("pciusb"); exit(1); }
+ if ((ret.pid = fork()) != 0) {
+ ret.f = fdopen(fdno[0], "r");
+ close(fdno[1]);
+ } else {
+ char *cmd[8];
+ int ip = 0;
+ char *ld_loader = getenv("LD_LOADER");
+
+ if (ld_loader && *ld_loader) {
+ cmd[ip++] = ld_loader;
+ }
+ cmd[ip++] = "gzip";
+ cmd[ip++] = "-dc";
+ cmd[ip++] = fname_gz;
+ cmd[ip++] = NULL;
+
+ dup2(fdno[1], STDOUT_FILENO);
+ execvp(cmd[0], cmd);
+ perror("pciusb"); exit(2);
+ }
} else {
fprintf(stderr, "Missing pciusbtable (should be %s)\n", fname);
exit(1);
@@ -33,11 +55,8 @@ static fh fh_open(char *fname) {
}
static void fh_close(fh f) {
- switch (f.type)
- {
- case fh_normal: fclose(f.f); break;
- case fh_pipe: pclose(f.f); break;
- }
+ fclose(f.f);
+ if (f.pid > 0) waitpid(f.pid, NULL, 0);
}
extern int pciusb_find_modules(struct pciusb_entries entries, const char *fpciusbtable, int no_subid) {