/** Structure containing a raw command */
struct fuse_cmd;
-/** The lowlevel FUSE session */
-struct fuse_session;
-
/** Function to add an entry in a readdir() operation
*
* @param buf the buffer passed to the readdir() operation
/** Set function which can be used to get the current context */
void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
-/** Returns the lowlevel FUSE session */
-struct fuse_session *fuse_get_session(struct fuse *f);
-
/* ----------------------------------------------------------- *
* Compatibility stuff *
* ----------------------------------------------------------- */
struct fuse_session_ops {
void (*process) (void *data, const char *buf, size_t len,
struct fuse_chan *ch);
+
+ void (*exit) (void *data, int val);
+
+ int (*exited) (void *data);
void (*destroy) (void *data);
};
libfuse_la_SOURCES = \
fuse.c \
+ fuse_i.h \
fuse_kern_chan.c \
fuse_loop.c \
fuse_loop_mt.c \
/* For pthread_rwlock_t */
#define _GNU_SOURCE
-#include "fuse.h"
+#include "fuse_i.h"
#include "fuse_lowlevel.h"
#include "fuse_compat.h"
fuse_ino_t nodeid;
};
-struct fuse_cmd {
- char *buf;
- size_t buflen;
-};
-
static struct fuse_context *(*fuse_getcontext)(void) = NULL;
#ifndef USE_UCLIBC
void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd)
{
- struct fuse_chan *ch = fuse_session_next_chan(f->se, NULL);
- fuse_session_process(f->se, cmd->buf, cmd->buflen, ch);
+ fuse_session_process(f->se, cmd->buf, cmd->buflen, cmd->ch);
}
int fuse_exited(struct fuse *f)
return NULL;
}
cmd->buflen = res;
+ cmd->ch = ch;
}
return cmd;
}
--- /dev/null
+/*
+ FUSE: Filesystem in Userspace
+ Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
+
+ This program can be distributed under the terms of the GNU LGPL.
+ See the file COPYING.LIB
+*/
+
+#include "fuse.h"
+
+struct fuse_session;
+struct fuse_chan;
+
+struct fuse_cmd {
+ char *buf;
+ size_t buflen;
+ struct fuse_chan *ch;
+};
+
+struct fuse_session *fuse_get_session(struct fuse *f);
+
+struct fuse *fuse_new_common(int fd, const char *opts,
+ const struct fuse_operations *op,
+ size_t op_size, int compat);
return fuse_chan_send(w->prevch, iov, count);
}
-
static int start_thread(struct fuse_worker *w, pthread_t *thread_id);
static void *do_work(void *data)
See the file COPYING.LIB.
*/
-#include "fuse.h"
+#include "fuse_i.h"
#include "fuse_lowlevel.h"
#include <stdio.h>
struct procdata {
struct fuse *f;
+ struct fuse_chan *prevch;
+ struct fuse_session *prevse;
fuse_processor_t proc;
void *data;
};
struct fuse_cmd *cmd = *(struct fuse_cmd **) buf;
(void) len;
- (void) ch;
+ cmd->ch = ch;
pd->proc(pd->f, cmd, pd->data);
}
+static void mt_session_exit(void *data, int val)
+{
+ struct procdata *pd = (struct procdata *) data;
+ if (val)
+ fuse_session_exit(pd->prevse);
+ else
+ fuse_session_reset(pd->prevse);
+}
+
+static int mt_session_exited(void *data)
+{
+ struct procdata *pd = (struct procdata *) data;
+ return fuse_session_exited(pd->prevse);
+}
+
static int mt_chan_receive(struct fuse_chan *ch, char *buf, size_t size)
{
struct fuse_cmd *cmd;
cmd = fuse_read_cmd(pd->f);
if (cmd == NULL)
- return -1;
+ return 0;
*(struct fuse_cmd **) buf = cmd;
- return 0;
+ return sizeof(cmd);
+}
+
+static int mt_chan_send(struct fuse_chan *ch, const struct iovec iov[],
+ size_t count)
+{
+ struct procdata *pd = (struct procdata *) fuse_chan_data(ch);
+ return fuse_chan_send(pd->prevch, iov, count);
}
int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data)
struct fuse_chan *prevch = fuse_session_next_chan(prevse, NULL);
struct fuse_chan *ch;
struct fuse_session_ops sop = {
+ .exit = mt_session_exit,
+ .exited = mt_session_exited,
.process = mt_session_proc,
};
struct fuse_chan_ops cop = {
.receive = mt_chan_receive,
+ .send = mt_chan_send,
};
pd.f = f;
+ pd.prevch = prevch;
+ pd.prevse = prevse;
pd.proc = proc;
pd.data = data;
{
int res;
+ if (f == NULL)
+ return -1;
+
if (mt_create_context_key() != 0)
return -1;
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)
{
- return se->exited;
+ if (se->op.exited)
+ return se->op.exited(se->data);
+ else
+ return se->exited;
}
struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd,
See the file COPYING.LIB.
*/
-#include "fuse.h"
+#include "fuse_i.h"
#include "fuse_compat.h"
#include <stdio.h>
#include <limits.h>
#include <signal.h>
-struct fuse *fuse_new_common(int fd, const char *opts,
- const struct fuse_operations *op,
- size_t op_size, int compat);
-
static struct fuse *fuse_instance;
static void usage(const char *progname)