Improve documentation of fuse_session_unmount
authorNikolaus Rath <Nikolaus@rath.org>
Wed, 23 Nov 2016 23:59:52 +0000 (15:59 -0800)
committerNikolaus Rath <Nikolaus@rath.org>
Tue, 29 Nov 2016 16:25:52 +0000 (08:25 -0800)
include/fuse.h
include/fuse_lowlevel.h
lib/fuse_lowlevel.c
lib/mount.c

index a9e569ec46d41ea486ddc54e11ebbd5ec6570a64..89798eff6d056b03c2684e6df4c9340aec04753d 100644 (file)
@@ -819,6 +819,8 @@ int fuse_mount(struct fuse *f, const char *mountpoint);
 /**
  * Unmount a FUSE file system.
  *
+ * See fuse_session_unmount() for additional information.
+ *
  * @param f the FUSE handle
  **/
 void fuse_unmount(struct fuse *f);
index af3063f3ef92cb1c0e4bf4d2809134efc68e16b6..835b4208fb68a031c1089f013fade933c671393a 100644 (file)
@@ -1850,7 +1850,26 @@ void fuse_session_reset(struct fuse_session *se);
 int fuse_session_exited(struct fuse_session *se);
 
 /**
- * Unmount the file system
+ * Ensure that file system is unmounted.
+ *
+ * In regular operation, the file system is typically unmounted by the
+ * user calling umount(8) or fusermount(1), which then terminates the
+ * FUSE session loop. However, the session loop may also terminate as
+ * a result of an explicit call to fuse_session_exit() (e.g. by a
+ * signal handler installed by fuse_set_signal_handler()). In this
+ * case the filesystem remains mounted, but any attempt to access it
+ * will block (while the filesystem process is still running) or give
+ * an ESHUTDOWN error (after the filesystem process has terminated).
+ *
+ * If the communication channel with the FUSE kernel module is still
+ * open (i.e., if the session loop was terminated by an explicit call
+ * to fuse_session_exit()), this function will close it and unmount
+ * the filesystem. If the communication channel has been closed by the
+ * kernel, this method will do (almost) nothing.
+ *
+ * NOTE: The above semantics mean that if the connection to the kernel
+ * is terminated via the ``/sys/fs/fuse/connections/NNN/abort`` file,
+ * this method will *not* unmount the filesystem.
  *
  * @param se the session
  */
index 48559615cfab985be70c13642a5ae69c8bbd5091..a960123e18d77c82288ecf405c05b6dad301b47b 100644 (file)
@@ -2655,6 +2655,8 @@ int fuse_session_receive_buf_int(struct fuse_session *se, struct fuse_buf *buf,
 
        if (res == -1) {
                if (err == ENODEV) {
+                       /* Filesystem was unmounted, or connection was aborted
+                          via /sys/fs/fuse/connections */
                        fuse_session_exit(se);
                        return 0;
                }
@@ -2743,6 +2745,8 @@ restart:
                        goto restart;
 
                if (err == ENODEV) {
+                       /* Filesystem was unmounted, or connection was aborted
+                          via /sys/fs/fuse/connections */
                        fuse_session_exit(se);
                        return 0;
                }
index d19242eaba98a8811eb57cdb3be82dc85c376b16..2f7e0687841e9815b9b6b47dcde1d8116ec0a09d 100644 (file)
@@ -275,7 +275,8 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
                close(fd);
 
                /* If file poll returns POLLERR on the device file descriptor,
-                  then the filesystem is already unmounted */
+                  then the filesystem is already unmounted or the connection
+                  was severed via /sys/fs/fuse/connections/NNN/abort */
                if (res == 1 && (pfd.revents & POLLERR))
                        return;
        }