diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2001-12-20 15:38:05 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2001-12-20 15:38:05 +0000 |
commit | fe25def3344095825738deba119e1400b8e2315f (patch) | |
tree | a277304923d54e0495558c1e4e6720c2c114d78d /lib/fuse_mt.c | |
parent | 2e50d4376f3124a87d5723ae66c09fa71c7ecf88 (diff) | |
download | libfuse-fe25def3344095825738deba119e1400b8e2315f.tar.gz |
permission checking implemented
Diffstat (limited to 'lib/fuse_mt.c')
-rw-r--r-- | lib/fuse_mt.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/fuse_mt.c b/lib/fuse_mt.c index 4534d0f..b8756ac 100644 --- a/lib/fuse_mt.c +++ b/lib/fuse_mt.c @@ -69,9 +69,28 @@ static void start_thread(struct fuse_worker *w) pthread_detach(thrid); } +static struct fuse_context *mt_getcontext(struct fuse *f) +{ + struct fuse_context *ctx; + + ctx = (struct fuse_context *) pthread_getspecific(f->context_key); + if(ctx == NULL) { + ctx = (struct fuse_context *) malloc(sizeof(struct fuse_context)); + pthread_setspecific(f->context_key, ctx); + } + + return ctx; +} + +static void mt_freecontext(void *data) +{ + free(data); +} + void __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data) { struct fuse_worker *w; + int res; w = malloc(sizeof(struct fuse_worker)); w->f = f; @@ -79,6 +98,12 @@ void __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data) w->proc = proc; f->numworker = 1; + res = pthread_key_create(&f->context_key, mt_freecontext); + if(res != 0) { + fprintf(stderr, "Failed to create thread specific key\n"); + exit(1); + } + f->getcontext = mt_getcontext; do_work(w); } |