summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2013-06-21 13:35:30 +0200
committerMiklos Szeredi <mszeredi@suse.cz>2013-06-21 13:35:30 +0200
commitb13051ae4179a0fa7b7febda8cf9cece12a73119 (patch)
tree5b88b4b755b567be3546a01f0657b17af86a045e
parent2bcfd55fc145430e49193715417ced10d58d7b54 (diff)
downloadfuse-b13051ae4179a0fa7b7febda8cf9cece12a73119.tar.gz
libfuse: clean up fuse_session
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();
-rw-r--r--include/fuse_lowlevel.h72
-rw-r--r--lib/fuse_i.h21
-rw-r--r--lib/fuse_lowlevel.c18
-rw-r--r--lib/fuse_session.c28
-rw-r--r--lib/fuse_versionscript3
5 files changed, 26 insertions, 116 deletions
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index f62afcc..539c6e7 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -1575,56 +1575,6 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
* ----------------------------------------------------------- */
/**
- * 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
*
* If a session is destroyed, the assigned channel is also destroyed
@@ -1652,21 +1602,9 @@ 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
@@ -1720,14 +1658,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
*
* @param se the session
diff --git a/lib/fuse_i.h b/lib/fuse_i.h
index 33fbb43..c205fa8 100644
--- a/lib/fuse_i.h
+++ b/lib/fuse_i.h
@@ -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);
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 45cd5f3..30877ec 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -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;
diff --git a/lib/fuse_session.c b/lib/fuse_session.c
index 2a4fc8d..f535720 100644
--- a/lib/fuse_session.c
+++ b/lib/fuse_session.c
@@ -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)
diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
index 391c4f8..8bd2c92 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -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;