fix
authorMiklos Szeredi <miklos@szeredi.hu>
Thu, 16 Mar 2006 14:19:25 +0000 (14:19 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Thu, 16 Mar 2006 14:19:25 +0000 (14:19 +0000)
ChangeLog
lib/mount.c

index 5fb7183a335f1f11a7b79ecf4948010e473b3a14..08c2c54c219fef8bc2a7dcdfd0bcf6ebedd65186 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-16  Miklos Szeredi <miklos@szeredi.hu>
+
+       * Don't unmount if already unmounted.  This fixes a problem seen
+       in the following situation: Lazy unmount a busy filesystem; Mount
+       a new one in top; When the first finally unmounts, the second also
+       unmounts.  Reported by Franco Broi
+
 2006-03-15  Miklos Szeredi <miklos@szeredi.hu>
 
        * lowlevel lib: use indirect function calls instead of a
index a1875f0082d97c52d042d2bfb141db5ee09c7538..5c568e913a3d3c2ea40238d618171044337de4db 100644 (file)
@@ -16,6 +16,7 @@
 #include <stddef.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/poll.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/wait.h>
@@ -174,13 +175,21 @@ void fuse_unmount_compat22(const char *mountpoint)
 void fuse_unmount(const char *mountpoint, int fd)
 {
     const char *mountprog = FUSERMOUNT_PROG;
+    struct pollfd pfd;
+    int res;
     int pid;
 
-    (void) fd;
-
     if (!mountpoint)
         return;
 
+    pfd.fd = fd;
+    pfd.events = 0;
+    res = poll(&pfd, 1, 0);
+    /* If file poll returns POLLERR on the device file descriptor,
+       then the filesystem is already unmounted */
+    if (res == 1 && (pfd.revents & POLLERR))
+        return;
+
 #ifdef HAVE_FORK
     pid = fork();
 #else