Introduce separate mount/umount functions for low-level API.
authorNikolaus Rath <Nikolaus@rath.org>
Sun, 2 Oct 2016 17:26:40 +0000 (10:26 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Sun, 2 Oct 2016 17:51:34 +0000 (10:51 -0700)
ChangeLog.rst
example/fuse_lo-plus.c
example/hello_ll.c
include/fuse.h
include/fuse_common.h
include/fuse_lowlevel.h
lib/fuse.c
lib/fuse_lowlevel.c
lib/fuse_versionscript
lib/helper.c

index 28888bf5ec8ce2fd97d51ee3543addc8ef1aacce..87ceae9b5763dd1f4e44f762155c723200abf3a2 100644 (file)
@@ -1,6 +1,11 @@
 Unreleased Changes
 ==================
 
+* There are now new `fuse_session_unmount` and `fuse_session_mount`
+  functions that should be used in the low-level API. The
+  `fuse_mount` and `fuse_unmount` functions should be used with the
+  high-level API only.
+
 * The ``fuse_lowlevel_notify_*`` functions now all take a `struct
   fuse_session` parameter instead of a `struct fuse_chan`.
 
index adbbbeecadc12d7add3a94e46823da24649195a5..30ad21e9a4b45877a4503ee1cf2829a167a5869d 100644 (file)
@@ -95,7 +95,7 @@ static struct lo_inode *lo_inode(fuse_req_t req, fuse_ino_t ino)
        if (ino == FUSE_ROOT_ID)
                return &lo_data(req)->root;
        else
-               return (struct lo_inode *) (uintptr_t) ino; 
+               return (struct lo_inode *) (uintptr_t) ino;
 }
 
 static int lo_fd(fuse_req_t req, fuse_ino_t ino)
@@ -469,7 +469,7 @@ int main(int argc, char *argv[])
                err(1, "open(\"/\", O_PATH)");
 
        if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != -1 &&
-           (ch = fuse_mount(mountpoint, &args)) != NULL) {
+           (ch = fuse_session_mount(mountpoint, &args)) != NULL) {
                struct fuse_session *se;
                se = fuse_lowlevel_new(&args, &lo_oper, sizeof(lo_oper), &lo);
                if (se != NULL) {
@@ -481,7 +481,7 @@ int main(int argc, char *argv[])
                        }
                        fuse_session_destroy(se);
                }
-               fuse_unmount(mountpoint, ch);
+               fuse_session_unmount(mountpoint, ch);
                free(mountpoint);
        }
        fuse_opt_free_args(&args);
index 1bf715542603dfc54813c2663ceff8d581f38e76..3c87bc658aa0c315a0203dd89a16b212f8bb12da 100755 (executable)
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
        int err = -1;
 
        if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != -1 &&
-           (ch = fuse_mount(mountpoint, &args)) != NULL) {
+           (ch = fuse_session_mount(mountpoint, &args)) != NULL) {
                struct fuse_session *se;
 
                se = fuse_lowlevel_new(&args, &hello_ll_oper,
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
                        }
                        fuse_session_destroy(se);
                }
-               fuse_unmount(mountpoint, ch);
+               fuse_session_unmount(mountpoint, ch);
        }
        fuse_opt_free_args(&args);
 
index 5721caa9a0a25b83e57019a74aabb0e31dc51405..948442c6408b7206fb48c6d0dd0744db3962469a 100644 (file)
@@ -658,6 +658,32 @@ struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
                      const struct fuse_operations *op, size_t op_size,
                      void *user_data);
 
+/**
+ * Create a FUSE mountpoint
+ *
+ * Returns a control file descriptor suitable for passing to
+ * fuse_new(). Unknown parameters in `args` are passed through
+ * unchanged. Known parameters (with the exception of --help and
+ * --version) are removed from `args`.
+ *
+ * If the --help or --version parameters are specified, the function
+ * prints the requested information to stdout and returns a valid
+ * pointer. However, it does not actually perform the mount.
+ *
+ * @param mountpoint the mount point path
+ * @param args argument vector
+ * @return the communication channel on success, NULL on failure
+ */
+struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
+
+/**
+ * Umount a FUSE mountpoint
+ *
+ * @param mountpoint the mount point path
+ * @param ch the communication channel
+ */
+void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
+
 /**
  * Destroy the FUSE handle.
  *
index df92e8e7e97aba23469ddca225ae1e2e571b058f..bab2a5bddbad4b9aab57945424c4343462862013 100644 (file)
@@ -209,32 +209,6 @@ struct fuse_session;
 struct fuse_chan;
 struct fuse_pollhandle;
 
-/**
- * Create a FUSE mountpoint
- *
- * Returns a control file descriptor suitable for passing to
- * fuse_new(). Unknown parameters in `args` are passed through
- * unchanged. Known parameters (with the exception of --help and
- * --version) are removed from `args`.
- *
- * If the --help or --version parameters are specified, the function
- * prints the requested information to stdout and returns a valid
- * pointer. However, it does not actually perform the mount.
- *
- * @param mountpoint the mount point path
- * @param args argument vector
- * @return the communication channel on success, NULL on failure
- */
-struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
-
-/**
- * Umount a FUSE mountpoint
- *
- * @param mountpoint the mount point path
- * @param ch the communication channel
- */
-void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
-
 /**
  * Utility functions for simple file systems to parse common options.
  *
index ce3990602c09105fd03d4d34f3189a7962fb6e26..e6520589329c10aa02d975ca511e6c445c113aca 100644 (file)
@@ -1705,6 +1705,33 @@ int fuse_session_loop(struct fuse_session *se);
  */
 int fuse_session_loop_mt(struct fuse_session *se);
 
+/**
+ * Create a FUSE mountpoint
+ *
+ * Returns a control file descriptor suitable for passing to
+ * fuse_new(). Unknown parameters in `args` are passed through
+ * unchanged. Known parameters (with the exception of --help and
+ * --version) are removed from `args`.
+ *
+ * If the --help or --version parameters are specified, the function
+ * prints the requested information to stdout and returns a valid
+ * pointer. However, it does not actually perform the mount.
+ *
+ * @param mountpoint the mount point path
+ * @param args argument vector
+ * @return the communication channel on success, NULL on failure
+ */
+struct fuse_chan *fuse_session_mount(const char *mountpoint,
+                                    struct fuse_args *args);
+
+/**
+ * Umount a FUSE mountpoint
+ *
+ * @param mountpoint the mount point path
+ * @param ch the communication channel
+ */
+void fuse_session_unmount(const char *mountpoint, struct fuse_chan *ch);
+
 /* ----------------------------------------------------------- *
  * Channel interface                                          *
  * ----------------------------------------------------------- */
index f9347476b0dfefc0155b0085ed37ca935952b2c5..e17b6b37fa34e4b790002dd885227660293acaf8 100644 (file)
@@ -4836,3 +4836,13 @@ void fuse_destroy(struct fuse *f)
        free(f);
        fuse_delete_context_key();
 }
+
+struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
+{
+       return fuse_session_mount(mountpoint, args);
+}
+
+void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
+{
+       fuse_session_unmount(mountpoint, ch);
+}
index 8b08f3a71c2652b8a0cb1e0ddd8adb8e4540747b..ad10175041b21f6b84373ea9d709d19578f0d6eb 100755 (executable)
@@ -2938,6 +2938,42 @@ out:
        return NULL;
 }
 
+struct fuse_chan *fuse_session_mount(const char *mountpoint,
+                                    struct fuse_args *args)
+{
+       struct fuse_chan *ch;
+       int fd;
+
+       /*
+        * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
+        * would ensue.
+        */
+       do {
+               fd = open("/dev/null", O_RDWR);
+               if (fd > 2)
+                       close(fd);
+       } while (fd >= 0 && fd <= 2);
+
+       fd = fuse_kern_mount(mountpoint, args);
+       if (fd == -1)
+               return NULL;
+
+       ch = fuse_chan_new(fd);
+       if (!ch)
+               fuse_kern_unmount(mountpoint, fd);
+
+       return ch;
+}
+
+void fuse_session_unmount(const char *mountpoint, struct fuse_chan *ch)
+{
+       if (mountpoint) {
+               int fd = ch ? fuse_chan_clearfd(ch) : -1;
+               fuse_kern_unmount(mountpoint, fd);
+               fuse_chan_put(ch);
+       }
+}
+
 #ifdef linux
 int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
 {
index 716330fa822ce967f6ed7168d2286055f8abdd4d..9c29669d8105e1d467155f699aa14ef3d5ba2e3d 100644 (file)
@@ -42,6 +42,7 @@ FUSE_3.0 {
                fuse_lowlevel_new;
                fuse_main_real;
                fuse_mount;
+               fuse_session_mount;
                fuse_new;
                fuse_opt_insert_arg;
                fuse_reply_lock;
@@ -49,6 +50,7 @@ FUSE_3.0 {
                fuse_req_interrupted;
                fuse_session_remove_chan;
                fuse_unmount;
+               fuse_session_unmount;
                fuse_fs_access;
                fuse_fs_bmap;
                fuse_fs_chmod;
index 6a55269ff450ad2f6c70e67b9f68f2d7598a2fe8..cd1a54bb31301e064411135e8db465c68b7594bc 100644 (file)
@@ -227,41 +227,6 @@ int fuse_daemonize(int foreground)
        return 0;
 }
 
-struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
-{
-       struct fuse_chan *ch;
-       int fd;
-
-       /*
-        * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
-        * would ensue.
-        */
-       do {
-               fd = open("/dev/null", O_RDWR);
-               if (fd > 2)
-                       close(fd);
-       } while (fd >= 0 && fd <= 2);
-
-       fd = fuse_kern_mount(mountpoint, args);
-       if (fd == -1)
-               return NULL;
-
-       ch = fuse_chan_new(fd);
-       if (!ch)
-               fuse_kern_unmount(mountpoint, fd);
-
-       return ch;
-}
-
-void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
-{
-       if (mountpoint) {
-               int fd = ch ? fuse_chan_clearfd(ch) : -1;
-               fuse_kern_unmount(mountpoint, fd);
-               fuse_chan_put(ch);
-       }
-}
-
 static struct fuse *fuse_setup(int argc, char *argv[],
                        const struct fuse_operations *op, size_t op_size,
                        char **mountpoint, int *multithreaded, void *user_data)