aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fuse.h27
-rw-r--r--include/fuse_common.h43
-rw-r--r--include/fuse_common_compat.h2
-rw-r--r--include/fuse_compat.h2
-rw-r--r--include/fuse_lowlevel.h42
5 files changed, 70 insertions, 46 deletions
diff --git a/include/fuse.h b/include/fuse.h
index 065ae75..f7dba7f 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -404,13 +404,15 @@ struct fuse_context {
* @param argc the argument counter passed to the main() function
* @param argv the argument vector passed to the main() function
* @param op the file system operation
+ * @param user_data user data set in context for init() method
* @return 0 on success, nonzero on failure
*/
/*
-int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
+int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
+ void *user_data);
*/
-#define fuse_main(argc, argv, op) \
- fuse_main_real(argc, argv, op, sizeof(*(op)))
+#define fuse_main(argc, argv, op, user_data) \
+ fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)
/* ----------------------------------------------------------- *
* More detailed API *
@@ -419,14 +421,16 @@ int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
/**
* Create a new FUSE filesystem.
*
- * @param fd the control file descriptor
+ * @param ch the communication channel
* @param args argument vector
* @param op the operations
* @param op_size the size of the fuse_operations structure
+ * @param user_data user data set in context for init() method
* @return the created FUSE handle
*/
-struct fuse *fuse_new(int fd, struct fuse_args *args,
- const struct fuse_operations *op, size_t op_size);
+struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
+ const struct fuse_operations *op, size_t op_size,
+ void *user_data);
/**
* Destroy the FUSE handle.
@@ -497,7 +501,7 @@ int fuse_is_lib_option(const char *opt);
* Do not call this directly, use fuse_main()
*/
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
- size_t op_size);
+ size_t op_size, void *user_data);
/* ----------------------------------------------------------- *
* Advanced API for event handling, don't worry about this... *
@@ -509,10 +513,11 @@ typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);
/** This is the part of fuse_main() before the event loop */
struct fuse *fuse_setup(int argc, char *argv[],
const struct fuse_operations *op, size_t op_size,
- char **mountpoint, int *multithreaded, int *fd);
+ char **mountpoint, int *multithreaded,
+ void *user_data);
/** This is the part of fuse_main() after the event loop */
-void fuse_teardown(struct fuse *fuse, int fd, char *mountpoint);
+void fuse_teardown(struct fuse *fuse, char *mountpoint);
/** Read a single command. If none are read, return NULL */
struct fuse_cmd *fuse_read_cmd(struct fuse *f);
@@ -531,6 +536,9 @@ int fuse_exited(struct fuse *f);
/** Set function which can be used to get the current context */
void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
+/** Get session from fuse object */
+struct fuse_session *fuse_get_session(struct fuse *f);
+
/* ----------------------------------------------------------- *
* Compatibility stuff *
* ----------------------------------------------------------- */
@@ -543,6 +551,7 @@ void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
fuse_main_real_compat25(argc, argv, op, sizeof(*(op)))
# define fuse_new fuse_new_compat25
# define fuse_setup fuse_setup_compat25
+# define fuse_teardown fuse_teardown_compat25
# define fuse_operations fuse_operations_compat25
# elif FUSE_USE_VERSION == 22
# define fuse_main(argc, argv, op) \
diff --git a/include/fuse_common.h b/include/fuse_common.h
index 056b92b..c1b2806 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -75,6 +75,9 @@ struct fuse_conn_info {
unsigned reserved[27];
};
+struct fuse_session;
+struct fuse_chan;
+
/**
* Create a FUSE mountpoint
*
@@ -83,17 +86,17 @@ struct fuse_conn_info {
*
* @param mountpoint the mount point path
* @param args argument vector
- * @return the control file descriptor on success, -1 on failure
+ * @return the communication channel on success, NULL on failure
*/
-int fuse_mount(const char *mountpoint, struct fuse_args *args);
+struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
/**
* Umount a FUSE mountpoint
*
* @param mountpoint the mount point path
- * @param the control file descriptor
+ * @param ch the communication channel
*/
-void fuse_unmount(const char *mountpoint, int fd);
+void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
/**
* Parse common options
@@ -120,6 +123,37 @@ int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
int *multithreaded, int *foreground);
+int fuse_daemonize(int foreground);
+
+/* ----------------------------------------------------------- *
+ * Signal handling *
+ * ----------------------------------------------------------- */
+
+/**
+ * Exit session on HUP, TERM and INT signals and ignore PIPE signal
+ *
+ * Stores session in a global variable. May only be called once per
+ * process until fuse_remove_signal_handlers() is called.
+ *
+ * @param se the session to exit
+ * @return 0 on success, -1 on failure
+ */
+int fuse_set_signal_handlers(struct fuse_session *se);
+
+/**
+ * Restore default signal handlers
+ *
+ * Resets global session. After this fuse_set_signal_handlers() may
+ * be called again.
+ *
+ * @param se the same session as given in fuse_set_signal_handlers()
+ */
+void fuse_remove_signal_handlers(struct fuse_session *se);
+
+/* ----------------------------------------------------------- *
+ * Compatibility stuff *
+ * ----------------------------------------------------------- */
+
#if FUSE_USE_VERSION < 26
# ifdef __FreeBSD__
# if FUSE_USE_VERSION < 25
@@ -129,6 +163,7 @@ int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
# include "fuse_common_compat.h"
# undef FUSE_MINOR_VERSION
# undef fuse_main
+# define fuse_mount fuse_mount_compat25
# define fuse_unmount fuse_unmount_compat22
# if FUSE_USE_VERSION == 25
# define FUSE_MINOR_VERSION 5
diff --git a/include/fuse_common_compat.h b/include/fuse_common_compat.h
index ce54fdf..6b6bf32 100644
--- a/include/fuse_common_compat.h
+++ b/include/fuse_common_compat.h
@@ -9,6 +9,8 @@
/* these definitions provide source compatibility to prior versions.
Do not include this file directly! */
+int fuse_mount_compat25(const char *mountpoint, struct fuse_args *args);
+
int fuse_mount_compat22(const char *mountpoint, const char *opts);
int fuse_mount_compat1(const char *mountpoint, const char *args[]);
diff --git a/include/fuse_compat.h b/include/fuse_compat.h
index a2144f0..c896373 100644
--- a/include/fuse_compat.h
+++ b/include/fuse_compat.h
@@ -62,6 +62,8 @@ struct fuse *fuse_setup_compat25(int argc, char *argv[],
size_t op_size, char **mountpoint,
int *multithreaded, int *fd);
+void fuse_teardown_compat25(struct fuse *fuse, int fd, char *mountpoint);
+
#ifndef __FreeBSD__
#include <sys/statfs.h>
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index 3cfff32..da12152 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -943,14 +943,6 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
const struct fuse_lowlevel_ops *op,
size_t op_size, void *userdata);
-/**
- * Create a kernel channel
- *
- * @param fd the file descriptor obtained from fuse_mount()
- * @return the created channel object, or NULL on failure
- */
-struct fuse_chan *fuse_kern_chan_new(int fd);
-
/* ----------------------------------------------------------- *
* Session interface *
* ----------------------------------------------------------- */
@@ -1019,6 +1011,15 @@ struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data);
void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);
/**
+ * Remove a channel from a session
+ *
+ * If the channel is not assigned to a session, then this is a no-op
+ *
+ * @param ch the channel to remove
+ */
+void fuse_session_remove_chan(struct fuse_chan *ch);
+
+/**
* Iterate over the channels assigned to a session
*
* The iterating function needs to start with a NULL channel, and
@@ -1208,31 +1209,6 @@ int fuse_chan_send(struct fuse_chan *ch, const struct iovec iov[],
void fuse_chan_destroy(struct fuse_chan *ch);
/* ----------------------------------------------------------- *
- * Signal handling *
- * ----------------------------------------------------------- */
-
-/**
- * Exit session on HUP, TERM and INT signals and ignore PIPE signal
- *
- * Stores session in a global variable. May only be called once per
- * process until fuse_remove_signal_handlers() is called.
- *
- * @param se the session to exit
- * @return 0 on success, -1 on failure
- */
-int fuse_set_signal_handlers(struct fuse_session *se);
-
-/**
- * Restore default signal handlers
- *
- * Resets global session. After this fuse_set_signal_handlers() may
- * be called again.
- *
- * @param se the same session as given in fuse_set_signal_handlers()
- */
-void fuse_remove_signal_handlers(struct fuse_session *se);
-
-/* ----------------------------------------------------------- *
* Compatibility stuff *
* ----------------------------------------------------------- */