fix
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 8 May 2006 12:35:04 +0000 (12:35 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 8 May 2006 12:35:04 +0000 (12:35 +0000)
ChangeLog
lib/Makefile.am
lib/fuse.c
lib/fuse_loop_mt.c
lib/fuse_lowlevel.c
lib/mount.c

index 1d34b577799ea51c28a5f1567195ab296a2f6a59..5a65080070fbfce4dbafa3f70b68e0b7e377e1e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-08  Miklos Szeredi <miklos@szeredi.hu>
+
+       * lib: search fusermount in installation directory (bindir) as
+       well as in PATH.
+
 2006-05-03  Miklos Szeredi <miklos@szeredi.hu>
 
        * lib: fix compilation if CLOCK_MONOTONIC is not defined.
index 287371dfd1e44577a2a62b133e5f92dbf3cfb131..049589c9eb986ea36840dbc1b893b777bf8333d2 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS = -I$(top_srcdir)/include -DFUSERMOUNT_DIR=\"$(bindir)\"
 lib_LTLIBRARIES = libfuse.la
 
 if BSD
index 3a7371d873299d4f5700bc1adc52d99aee048c1d..fcacd702b26eaed7750d96e4c83801d69a6c0838 100644 (file)
@@ -10,6 +10,7 @@
 /* For pthread_rwlock_t */
 #define _GNU_SOURCE
 
+#include "config.h"
 #include "fuse_i.h"
 #include "fuse_lowlevel.h"
 #include "fuse_opt.h"
index fc8f892f02955e9cc33baa5fccf8b7afc4d2f6d4..8327f125766a471f9497bdd1184f0298e2a6fa03 100644 (file)
@@ -6,6 +6,7 @@
     See the file COPYING.LIB.
 */
 
+#include "config.h"
 #include "fuse_lowlevel.h"
 
 #include <stdio.h>
index 7b5cb7b06a84d757f7a01dc3f0e43ca33166a431..20436ed97a4c36fd2a4fe5073164fb4f7991dfdd 100644 (file)
@@ -6,7 +6,7 @@
     See the file COPYING.LIB
 */
 
-#include <config.h>
+#include "config.h"
 #include "fuse_lowlevel.h"
 #include "fuse_kernel.h"
 #include "fuse_opt.h"
index 045a4a6677657c1ab8575f8b50357f016869a55c..6fc9b69e1418e2d011361b2f56968d0cc12eb614 100644 (file)
@@ -6,6 +6,7 @@
     See the file COPYING.LIB.
 */
 
+#include "config.h"
 #include "fuse_i.h"
 #include "fuse_opt.h"
 
 #define FUSERMOUNT_PROG         "fusermount"
 #define FUSE_COMMFD_ENV         "_FUSE_COMMFD"
 
+#ifndef HAVE_FORK
+#define fork() vfork()
+#endif
+
 enum {
     KEY_KERN,
     KEY_ALLOW_ROOT,
@@ -84,9 +89,21 @@ static void mount_help(void)
             );
 }
 
+static void exec_fusermount(const char *argv[])
+{
+    execv(FUSERMOUNT_DIR "/" FUSERMOUNT_PROG, (char **) argv);
+    execvp(FUSERMOUNT_PROG, (char **) argv);
+}
+
 static void mount_version(void)
 {
-    system(FUSERMOUNT_PROG " --version");
+    int pid = fork();
+    if (!pid) {
+        const char *argv[] = { FUSERMOUNT_PROG, "--version", NULL };
+        exec_fusermount(argv);
+        _exit(1);
+    } else if (pid != -1)
+        waitpid(pid, NULL, 0);
 }
 
 static int fuse_mount_opt_proc(void *data, const char *arg, int key,
@@ -168,7 +185,6 @@ static int receive_fd(int fd)
 
 void fuse_kern_unmount(const char *mountpoint, int fd)
 {
-    const char *mountprog = FUSERMOUNT_PROG;
     int pid;
 
     if (!mountpoint)
@@ -187,28 +203,16 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
             return;
     }
 
-#ifdef HAVE_FORK
     pid = fork();
-#else
-    pid = vfork();
-#endif
     if(pid == -1)
         return;
 
     if(pid == 0) {
-        const char *argv[32];
-        int a = 0;
-
-        argv[a++] = mountprog;
-        argv[a++] = "-u";
-        argv[a++] = "-q";
-        argv[a++] = "-z";
-        argv[a++] = "--";
-        argv[a++] = mountpoint;
-        argv[a++] = NULL;
+        const char *argv[] =
+            { FUSERMOUNT_PROG, "-u", "-q", "-z", "--", mountpoint, NULL };
 
-        execvp(mountprog, (char **) argv);
-        exit(1);
+        exec_fusermount(argv);
+        _exit(1);
     }
     waitpid(pid, NULL, 0);
 }
@@ -220,7 +224,6 @@ void fuse_unmount_compat22(const char *mountpoint)
 
 int fuse_mount_compat22(const char *mountpoint, const char *opts)
 {
-    const char *mountprog = FUSERMOUNT_PROG;
     int fds[2], pid;
     int res;
     int rv;
@@ -236,11 +239,7 @@ int fuse_mount_compat22(const char *mountpoint, const char *opts)
         return -1;
     }
 
-#ifdef HAVE_FORK
     pid = fork();
-#else
-    pid = vfork();
-#endif
     if(pid == -1) {
         perror("fuse: fork() failed");
         close(fds[0]);
@@ -253,7 +252,7 @@ int fuse_mount_compat22(const char *mountpoint, const char *opts)
         const char *argv[32];
         int a = 0;
 
-        argv[a++] = mountprog;
+        argv[a++] = FUSERMOUNT_PROG;
         if (opts) {
             argv[a++] = "-o";
             argv[a++] = opts;
@@ -266,9 +265,9 @@ int fuse_mount_compat22(const char *mountpoint, const char *opts)
         fcntl(fds[0], F_SETFD, 0);
         snprintf(env, sizeof(env), "%i", fds[0]);
         setenv(FUSE_COMMFD_ENV, env, 1);
-        execvp(mountprog, (char **) argv);
+        exec_fusermount(argv);
         perror("fuse: failed to exec fusermount");
-        exit(1);
+        _exit(1);
     }
 
     close(fds[0]);