diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2005-02-28 17:32:16 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2005-02-28 17:32:16 +0000 |
commit | 159bd7e2f44d836cca687c10d58c63943a26bbc3 (patch) | |
tree | fbfa1094736597dfaa33dcd2910b83786064c428 | |
parent | f43f06394ff53c2cb36a6843298fe36900cd902c (diff) | |
download | android_external_fuse-159bd7e2f44d836cca687c10d58c63943a26bbc3.tar.gz android_external_fuse-159bd7e2f44d836cca687c10d58c63943a26bbc3.tar.bz2 android_external_fuse-159bd7e2f44d836cca687c10d58c63943a26bbc3.zip |
fix
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | include/fuse.h | 28 | ||||
-rw-r--r-- | lib/fuse.c | 6 | ||||
-rw-r--r-- | lib/fuse_i.h | 1 |
4 files changed, 32 insertions, 7 deletions
@@ -1,9 +1,11 @@ 2005-02-28 Miklos Szeredi <miklos@szeredi.hu> - * libfuse: added opendir() operation. This can be used in case + * libfuse: added opendir() method. This can be used in case permission checking in getdir() is too late. Thanks to Usarin Heininga for pointing out this deficiency + * libfuse: added init() and destroy() methods to fuse_operations + * kernel: llseek() method for files and directories made explicit * kernel: fixed inode leak in NFS export in case of nodeid diff --git a/include/fuse.h b/include/fuse.h index 5b9df10..df6149f 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -85,9 +85,9 @@ struct fuse_file_info { * negated error value (-errno) directly. * * All methods are optional, but some are essential for a useful - * filesystem (e.g. getattr). Flush, release and fsync are special - * purpose methods, without which a full featured filesystem can still - * be implemented. + * filesystem (e.g. getattr). Flush, release, fsync, init and destroy + * are special purpose methods, without which a full featured + * filesystem can still be implemented. */ struct fuse_operations { /** Get file attributes. @@ -245,10 +245,26 @@ struct fuse_operations { /** Open direcory * * This method should check if the open operation is permitted for - * this directory. The fuse_file_info parameter is currently - * unused. This method is optional. + * this directory. The fuse_file_info parameter is currently + * unused. */ int (*opendir) (const char *, struct fuse_file_info *); + + /** + * Initialize filesystem + * + * The return value will passed in the private_data field of + * fuse_context to all file operations and as a parameter to the + * destroy() method. + */ + void *(*init) (void); + + /** + * Clean up filesystem + * + * Called on filesystem exit. + */ + void (*destroy) (void *); }; /** Extra context that may be needed by some filesystems @@ -269,7 +285,7 @@ struct fuse_context { /** Thread ID of the calling process */ pid_t pid; - /** Currently unused */ + /** Private filesystem data */ void *private_data; }; @@ -1497,6 +1497,9 @@ static void do_init(struct fuse *f, struct fuse_in_header *in, fflush(stdout); } f->got_init = 1; + if (f->op.init) + f->user_data = f->op.init(); + memset(&outarg, 0, sizeof(outarg)); outarg.major = FUSE_KERNEL_VERSION; outarg.minor = FUSE_KERNEL_MINOR_VERSION; @@ -1628,6 +1631,7 @@ void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd) ctx->uid = in->uid; ctx->gid = in->gid; ctx->pid = in->pid; + ctx->private_data = f->user_data; argsize = cmd->buflen - sizeof(struct fuse_in_header); @@ -2031,6 +2035,8 @@ void fuse_destroy(struct fuse *f) free(f->name_table); pthread_mutex_destroy(&f->lock); pthread_mutex_destroy(&f->worker_lock); + if (f->op.destroy) + f->op.destroy(f->user_data); free(f); } diff --git a/lib/fuse_i.h b/lib/fuse_i.h index 17615b4..7ab485d 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -29,6 +29,7 @@ struct fuse { int numavail; volatile int exited; int got_init; + void *user_data; }; struct fuse *fuse_new_common(int fd, const char *opts, |