aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-03-16 14:19:25 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2006-03-16 14:19:25 +0000
commitf51e43f35db18048d3b97e2bd13e51a9a594b782 (patch)
tree5c5e05fe14b63016f45262c8a40b3c36cc12fd3a
parent2c1381f3dec5df230db96f30c918802d68a257c5 (diff)
downloadlibfuse-f51e43f35db18048d3b97e2bd13e51a9a594b782.tar.gz
fix
-rw-r--r--ChangeLog7
-rw-r--r--lib/mount.c13
2 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5fb7183..08c2c54 100644
--- 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
diff --git a/lib/mount.c b/lib/mount.c
index a1875f0..5c568e9 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -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