+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
#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>
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