libfuse: clean up fuse_session
authorMiklos Szeredi <mszeredi@suse.cz>
Fri, 21 Jun 2013 11:35:30 +0000 (13:35 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Fri, 21 Jun 2013 11:35:30 +0000 (13:35 +0200)
Clean up fuse_session related interfaces.  Remove the following from the
lowlevel library API:

struct fuse_session_ops;
fuse_session_new();
fuse_session_process();
fuse_session_data();

include/fuse_lowlevel.h
lib/fuse_i.h
lib/fuse_lowlevel.c
lib/fuse_session.c
lib/fuse_versionscript

index f62afccf29c496fb58808191bc69c418262820a2..539c6e793da671b783e6014b828d49585b3c6d95 100644 (file)
@@ -1574,56 +1574,6 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
  * Session interface                                          *
  * ----------------------------------------------------------- */
 
-/**
- * Session operations
- *
- * This is used in session creation
- */
-struct fuse_session_ops {
-       /**
-        * Hook to process a request (mandatory)
-        *
-        * @param data user data passed to fuse_session_new()
-        * @param buf buffer containing the raw request
-        * @param len request length
-        * @param ch channel on which the request was received
-        */
-       void (*process) (void *data, const char *buf, size_t len,
-                        struct fuse_chan *ch);
-
-       /**
-        * Hook for session exit and reset (optional)
-        *
-        * @param data user data passed to fuse_session_new()
-        * @param val exited status (1 - exited, 0 - not exited)
-        */
-       void (*exit) (void *data, int val);
-
-       /**
-        * Hook for querying the current exited status (optional)
-        *
-        * @param data user data passed to fuse_session_new()
-        * @return 1 if exited, 0 if not exited
-        */
-       int (*exited) (void *data);
-
-       /**
-        * Hook for cleaning up the channel on destroy (optional)
-        *
-        * @param data user data passed to fuse_session_new()
-        */
-       void (*destroy) (void *data);
-};
-
-/**
- * Create a new session
- *
- * @param op session operations
- * @param data user data
- * @return new session object, or NULL on failure
- */
-struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data);
-
 /**
  * Assign a channel to a session
  *
@@ -1651,22 +1601,10 @@ void fuse_session_remove_chan(struct fuse_chan *ch);
  */
 struct fuse_chan *fuse_session_chan(struct fuse_session *se);
 
-/**
- * Process a raw request
- *
- * @param se the session
- * @param buf buffer containing the raw request
- * @param len request length
- * @param ch channel on which the request was received
- */
-void fuse_session_process(struct fuse_session *se, const char *buf, size_t len,
-                         struct fuse_chan *ch);
-
 /**
  * Process a raw request supplied in a generic buffer
  *
- * This is a more generic version of fuse_session_process().  The
- * fuse_buf may contain a memory buffer or a pipe file descriptor.
+ * The fuse_buf may contain a memory buffer or a pipe file descriptor.
  *
  * @param se the session
  * @param buf the fuse_buf containing the request
@@ -1719,14 +1657,6 @@ void fuse_session_reset(struct fuse_session *se);
  */
 int fuse_session_exited(struct fuse_session *se);
 
-/**
- * Get the user data provided to the session
- *
- * @param se the session
- * @return the user data
- */
-void *fuse_session_data(struct fuse_session *se);
-
 /**
  * Enter a single threaded event loop
  *
index 33fbb434c80dd4da8fa6039a7302ca0356ec4c5e..c205fa8cde051c771b2bfc72b659c1213089c9e7 100644 (file)
@@ -13,14 +13,14 @@ struct fuse_chan;
 struct fuse_ll;
 
 struct fuse_session {
-       struct fuse_session_ops op;
-
        int (*receive_buf)(struct fuse_session *se, struct fuse_buf *buf,
                           struct fuse_chan **chp);
 
        void (*process_buf)(void *data, const struct fuse_buf *buf,
                            struct fuse_chan *ch);
 
+       void (*destroy) (void *data);
+
        void *data;
 
        volatile int exited;
@@ -95,6 +95,23 @@ struct fuse_chan *fuse_kern_chan_new(int fd);
 
 int fuse_chan_clearfd(struct fuse_chan *ch);
 
+/**
+ * Create a new session
+ *
+ * @param data user data
+ * @return new session object, or NULL on failure
+ */
+struct fuse_session *fuse_session_new(void *data);
+
+/**
+ * Get the user data provided to the session
+ *
+ * @param se the session
+ * @return the user data
+ */
+void *fuse_session_data(struct fuse_session *se);
+
+
 void fuse_kern_unmount(const char *mountpoint, int fd);
 int fuse_kern_mount(const char *mountpoint, struct fuse_args *args);
 
index 45cd5f31a9f6f3433844e20771a477608ff9239b..30877ec5f96acb1bb204a27ba5dacc38874c3630 100644 (file)
@@ -2513,17 +2513,6 @@ clear_pipe:
        goto out_free;
 }
 
-static void fuse_ll_process(void *data, const char *buf, size_t len,
-                           struct fuse_chan *ch)
-{
-       struct fuse_buf fbuf = {
-               .mem = (void *) buf,
-               .size = len,
-       };
-
-       fuse_ll_process_buf(data, &fbuf, ch);
-}
-
 enum {
        KEY_HELP,
        KEY_VERSION,
@@ -2762,10 +2751,6 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
        int err;
        struct fuse_ll *f;
        struct fuse_session *se;
-       struct fuse_session_ops sop = {
-               .process = fuse_ll_process,
-               .destroy = fuse_ll_destroy,
-       };
 
        if (sizeof(struct fuse_lowlevel_ops) < op_size) {
                fprintf(stderr, "fuse: warning: library too old, some operations may not work\n");
@@ -2805,12 +2790,13 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
        f->owner = getuid();
        f->userdata = userdata;
 
-       se = fuse_session_new(&sop, f);
+       se = fuse_session_new(f);
        if (!se)
                goto out_key_destroy;
 
        se->receive_buf = fuse_ll_receive_buf;
        se->process_buf = fuse_ll_process_buf;
+       se->destroy = fuse_ll_destroy;
 
        return se;
 
index 2a4fc8d03b391fff583768845c169cd3e1c87b1a..f535720f4b9488e464bfac6d67d66ca5cec68df5 100644 (file)
@@ -25,7 +25,7 @@ struct fuse_chan {
        size_t bufsize;
 };
 
-struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data)
+struct fuse_session *fuse_session_new(void *data)
 {
        struct fuse_session *se = (struct fuse_session *) malloc(sizeof(*se));
        if (se == NULL) {
@@ -34,7 +34,6 @@ struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data)
        }
 
        memset(se, 0, sizeof(*se));
-       se->op = *op;
        se->data = data;
 
        return se;
@@ -63,21 +62,10 @@ struct fuse_chan *fuse_session_chan(struct fuse_session *se)
        return se->ch;
 }
 
-void fuse_session_process(struct fuse_session *se, const char *buf, size_t len,
-                         struct fuse_chan *ch)
-{
-       se->op.process(se->data, buf, len, ch);
-}
-
 void fuse_session_process_buf(struct fuse_session *se,
                              const struct fuse_buf *buf, struct fuse_chan *ch)
 {
-       if (se->process_buf) {
-               se->process_buf(se->data, buf, ch);
-       } else {
-               assert(!(buf->flags & FUSE_BUF_IS_FD));
-               fuse_session_process(se->data, buf->mem, buf->size, ch);
-       }
+       se->process_buf(se->data, buf, ch);
 }
 
 int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf,
@@ -105,8 +93,7 @@ int fuse_chan_clearfd(struct fuse_chan *ch)
 
 void fuse_session_destroy(struct fuse_session *se)
 {
-       if (se->op.destroy)
-               se->op.destroy(se->data);
+       se->destroy(se->data);
        if (se->ch != NULL)
                fuse_chan_destroy(se->ch);
        free(se);
@@ -114,24 +101,17 @@ void fuse_session_destroy(struct fuse_session *se)
 
 void fuse_session_exit(struct fuse_session *se)
 {
-       if (se->op.exit)
-               se->op.exit(se->data, 1);
        se->exited = 1;
 }
 
 void fuse_session_reset(struct fuse_session *se)
 {
-       if (se->op.exit)
-               se->op.exit(se->data, 0);
        se->exited = 0;
 }
 
 int fuse_session_exited(struct fuse_session *se)
 {
-       if (se->op.exited)
-               return se->op.exited(se->data);
-       else
-               return se->exited;
+       return se->exited;
 }
 
 void *fuse_session_data(struct fuse_session *se)
index 391c4f83a2eaade061f5819d6d9f5bb2b186eebe..8bd2c925dae2c883d7197c192a26639b704323e5 100644 (file)
@@ -24,9 +24,7 @@ FUSE_3.0 {
                fuse_session_exited;
                fuse_session_loop;
                fuse_session_loop_mt;
-               fuse_session_new;
                fuse_session_chan;
-               fuse_session_process;
                fuse_session_reset;
                fuse_opt_parse;
                fuse_opt_add_opt;
@@ -117,7 +115,6 @@ FUSE_3.0 {
                fuse_reply_poll;
                fuse_req_ctx;
                fuse_req_getgroups;
-               fuse_session_data;
                fuse_buf_copy;
                fuse_buf_size;
                fuse_fs_read_buf;