From cfd488b148cd05603141ccf1b14b56590b1f8e0b Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 23 Mar 2013 16:09:39 +0100 Subject: Bump to compatibility version 26 and compile with it * fuse.pc.in (Version): Set to 2.6.5. * src/fuse_i.h [!defined FUSE_USE_VERSION] (FUSE_USE_VERSION): Set to 26. (struct fuse): In field 'op', change type of field 'ops25' and add field 'ops'. Add fields 'conn' and 'user_data'. (FUSE_OP_HAVE, FUSE_OP_CALL): Use ops instead of ops25. * src/main.c: Add FUSE_SYMVER for fuse_main_real_compat25, fuse_new_compat25, fuse_mount_compat25. (fuse_main_real): New arg USER_DATA. (fuse_main_real_compat25): New function. (fuse_new): Change arg FD to CH, and add arg USER_DATA. Fill more fields in NEW. (fuse_new_compat25): New function. (fuse_mount): Change return value to 'struct fuse_chan *'. (fuse_mount_compat25): New function. --- fuse.pc.in | 2 +- src/fuse_i.h | 11 +++++---- src/main.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/fuse.pc.in b/fuse.pc.in index 499b6ba24..e93994363 100644 --- a/fuse.pc.in +++ b/fuse.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@ Name: fuse Description: Filesystem in Userspace -Version: 2.5.3 +Version: 2.6.5 Libs: -L${libdir} -lfuse -lpthread Cflags: -I${includedir}/fuse -D_FILE_OFFSET_BITS=64 diff --git a/src/fuse_i.h b/src/fuse_i.h index 640a042b7..1bc683011 100644 --- a/src/fuse_i.h +++ b/src/fuse_i.h @@ -17,7 +17,7 @@ #ifdef FUSE_USE_VERSION # include "fuse.h" #else -# define FUSE_USE_VERSION 25 +# define FUSE_USE_VERSION 26 # include "fuse.h" # include "fuse_compat.h" #endif @@ -32,16 +32,19 @@ struct fuse { int version; union { - struct fuse_operations ops25; + struct fuse_operations_compat25 ops25; + struct fuse_operations ops; } op; + struct fuse_conn_info conn; + void *user_data; void *private_data; }; /* pointer to the fuse structure of this translator process */ extern struct fuse *libfuse_fuse; -#define FUSE_OP_HAVE(a) (libfuse_fuse->op.ops25.a != NULL) -#define FUSE_OP_CALL(a,b...) (libfuse_fuse->op.ops25.a(b)) +#define FUSE_OP_HAVE(a) (libfuse_fuse->op.ops.a != NULL) +#define FUSE_OP_CALL(a,b...) (libfuse_fuse->op.ops.a(b)) #define NN_INFO(dir) ((void *) &(dir)->nn->info.info25) diff --git a/src/main.c b/src/main.c index bb5585519..6b8e39d09 100644 --- a/src/main.c +++ b/src/main.c @@ -246,15 +246,26 @@ fuse_parse_argv(int argc, char *argv[]) int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, - size_t op_size) + size_t op_size, void *user_data) { fuse_parse_argv(argc, argv); - int fd = fuse_mount(argv[0], NULL); + struct fuse_chan *ch = fuse_mount(argv[0], NULL); return (libfuse_params.disable_mt ? fuse_loop : fuse_loop_mt) - (fuse_new(fd, NULL, op, op_size)); + (fuse_new(ch, NULL, op, op_size, user_data)); } + +int +fuse_main_real_compat25(int argc, char *argv[], + const struct fuse_operations_compat25 *op, + size_t op_size) +{ + return fuse_main_real(argc, argv, (const struct fuse_operations *) op, + op_size, NULL); +} + + #undef fuse_main int fuse_main(void); int fuse_main(void) @@ -268,12 +279,12 @@ int fuse_main(void) * on the Hurd. Hmm. */ struct fuse * -fuse_new(int fd, struct fuse_args *args, - const struct fuse_operations *op, size_t op_size) +fuse_new(struct fuse_chan *ch, struct fuse_args *args, + const struct fuse_operations *op, size_t op_size, void *user_data) { struct fuse *new; - if(fd != FUSE_MAGIC) + if(ch != (void *) FUSE_MAGIC) return NULL; if(args && args->allocated) @@ -293,6 +304,9 @@ fuse_new(int fd, struct fuse_args *args, case sizeof(new->op.ops25): new->version = 25; break; + case sizeof(new->op.ops): + new->version = 26; + break; default: fprintf(stderr, "Unhandled size of fuse_operations: %d\n", op_size); fprintf(stderr, "libfuse will abort now\n"); @@ -300,18 +314,56 @@ fuse_new(int fd, struct fuse_args *args, } memcpy(&new->op, op, op_size); - if(new->op.ops25.init != NULL) - new->private_data = new->op.ops25.init(); + new->user_data = user_data; + + /* FIXME: figure out better values for fuse_conn_info fields. */ + new->conn.proto_major = FUSE_MAJOR_VERSION; + new->conn.proto_minor = FUSE_MINOR_VERSION; + new->conn.async_read = 1; + new->conn.max_write = UINT_MAX; + new->conn.max_readahead = UINT_MAX; + + if(new->op.ops.init != NULL) + { + if (new->version >= 26) + new->private_data = new->op.ops.init(&new->conn); + else + new->private_data = new->op.ops25.init(); + } return new; } +struct fuse * +fuse_new_compat25(int fd, struct fuse_args *args, + const struct fuse_operations_compat25 *op, size_t op_size) +{ + return fuse_new((struct fuse_chan *) fd, args, + (const struct fuse_operations *) op, op_size, NULL); +} + + /* Create a new mountpoint for our fuse filesystem, i.e. do the netfs * initialization stuff ... */ -int +struct fuse_chan * fuse_mount(const char *mountpoint, struct fuse_args *args) +{ + if(args && args->allocated) + { + int i; + for(i = 0; i < args->argc; i ++) + if(fuse_parse_opt(args->argv[i])) + return NULL; + } + + return (struct fuse_chan *) fuse_bootstrap(mountpoint); +} + + +int +fuse_mount_compat25(const char *mountpoint, struct fuse_args *args) { if(args && args->allocated) { @@ -529,3 +581,8 @@ fuse_get_context(void) { return libfuse_ctx; } + + +FUSE_SYMVER(".symver fuse_main_real_compat25,fuse_main_real@FUSE_2.5"); +FUSE_SYMVER(".symver fuse_new_compat25,fuse_new@FUSE_2.5"); +FUSE_SYMVER(".symver fuse_mount_compat25,fuse_mount@FUSE_2.5"); -- cgit v1.2.3