fix
diff --git a/ChangeLog b/ChangeLog
index 1d34b57..5a65080 100644
--- 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.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 287371d..049589c 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -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
diff --git a/lib/fuse.c b/lib/fuse.c
index 3a7371d..fcacd70 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -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"
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c
index fc8f892..8327f12 100644
--- a/lib/fuse_loop_mt.c
+++ b/lib/fuse_loop_mt.c
@@ -6,6 +6,7 @@
     See the file COPYING.LIB.
 */
 
+#include "config.h"
 #include "fuse_lowlevel.h"
 
 #include <stdio.h>
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 7b5cb7b..20436ed 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -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"
diff --git a/lib/mount.c b/lib/mount.c
index 045a4a6..6fc9b69 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -6,6 +6,7 @@
     See the file COPYING.LIB.
 */
 
+#include "config.h"
 #include "fuse_i.h"
 #include "fuse_opt.h"
 
@@ -23,6 +24,10 @@
 #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 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 @@
 
 void fuse_kern_unmount(const char *mountpoint, int fd)
 {
-    const char *mountprog = FUSERMOUNT_PROG;
     int pid;
 
     if (!mountpoint)
@@ -187,28 +203,16 @@
             return;
     }
 
-#ifdef HAVE_FORK
     pid = fork();
-#else
-    pid = vfork();
-#endif
     if(pid == -1)
         return;
 
     if(pid == 0) {
-        const char *argv[32];
-        int a = 0;
+        const char *argv[] =
+            { FUSERMOUNT_PROG, "-u", "-q", "-z", "--", mountpoint, NULL };
 
-        argv[a++] = mountprog;
-        argv[a++] = "-u";
-        argv[a++] = "-q";
-        argv[a++] = "-z";
-        argv[a++] = "--";
-        argv[a++] = mountpoint;
-        argv[a++] = NULL;
-
-        execvp(mountprog, (char **) argv);
-        exit(1);
+        exec_fusermount(argv);
+        _exit(1);
     }
     waitpid(pid, NULL, 0);
 }
@@ -220,7 +224,6 @@
 
 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 @@
         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 @@
         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 @@
         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]);