This commit is contained in:
Miklos Szeredi
2005-08-15 13:19:07 +00:00
parent a148242fb8
commit 178451d6f0
9 changed files with 77 additions and 25 deletions
-6
View File
@@ -37,9 +37,6 @@ struct fuse;
/** 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
@@ -510,9 +507,6 @@ 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));
/** Returns the lowlevel FUSE session */
struct fuse_session *fuse_get_session(struct fuse *f);
/* ----------------------------------------------------------- *
* Compatibility stuff *
* ----------------------------------------------------------- */
+4
View File
@@ -190,6 +190,10 @@ struct fuse_chan *fuse_kern_chan_new(int fd);
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);
};
+1
View File
@@ -4,6 +4,7 @@ lib_LTLIBRARIES = libfuse.la
libfuse_la_SOURCES = \
fuse.c \
fuse_i.h \
fuse_kern_chan.c \
fuse_loop.c \
fuse_loop_mt.c \
+3 -8
View File
@@ -10,7 +10,7 @@
/* For pthread_rwlock_t */
#define _GNU_SOURCE
#include "fuse.h"
#include "fuse_i.h"
#include "fuse_lowlevel.h"
#include "fuse_compat.h"
@@ -110,11 +110,6 @@ struct fuse_dirhandle {
fuse_ino_t nodeid;
};
struct fuse_cmd {
char *buf;
size_t buflen;
};
static struct fuse_context *(*fuse_getcontext)(void) = NULL;
#ifndef USE_UCLIBC
@@ -1643,8 +1638,7 @@ static void free_cmd(struct fuse_cmd *cmd)
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)
@@ -1685,6 +1679,7 @@ struct fuse_cmd *fuse_read_cmd(struct fuse *f)
return NULL;
}
cmd->buflen = res;
cmd->ch = ch;
}
return cmd;
}
+24
View File
@@ -0,0 +1,24 @@
/*
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);
-1
View File
@@ -53,7 +53,6 @@ static int fuse_loop_mt_send(struct fuse_chan *ch, const struct iovec iov[],
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)
+36 -4
View File
@@ -6,7 +6,7 @@
See the file COPYING.LIB.
*/
#include "fuse.h"
#include "fuse_i.h"
#include "fuse_lowlevel.h"
#include <stdio.h>
@@ -71,6 +71,8 @@ static void mt_delete_context_key(void)
struct procdata {
struct fuse *f;
struct fuse_chan *prevch;
struct fuse_session *prevse;
fuse_processor_t proc;
void *data;
};
@@ -82,10 +84,25 @@ static void mt_session_proc(void *data, const char *buf, size_t len,
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;
@@ -95,11 +112,18 @@ static int mt_chan_receive(struct fuse_chan *ch, char *buf, size_t size)
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)
@@ -111,13 +135,18 @@ 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;
@@ -149,6 +178,9 @@ int fuse_loop_mt(struct fuse *f)
{
int res;
if (f == NULL)
return -1;
if (mt_create_context_key() != 0)
return -1;
+8 -1
View File
@@ -85,17 +85,24 @@ 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)
{
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,
+1 -5
View File
@@ -6,7 +6,7 @@
See the file COPYING.LIB.
*/
#include "fuse.h"
#include "fuse_i.h"
#include "fuse_compat.h"
#include <stdio.h>
@@ -16,10 +16,6 @@
#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)