diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fuse.c | 70 | ||||
-rw-r--r-- | lib/fuse_i.h | 3 |
2 files changed, 27 insertions, 46 deletions
@@ -99,6 +99,7 @@ static const char *opname(enum fuse_opcode opcode) case FUSE_GETXATTR: return "GETXATTR"; case FUSE_LISTXATTR: return "LISTXATTR"; case FUSE_REMOVEXATTR: return "REMOVEXATTR"; + case FUSE_INIT: return "INIT"; default: return "???"; } } @@ -1504,6 +1505,20 @@ static void do_removexattr(struct fuse *f, struct fuse_in_header *in, send_reply(f, in, res, NULL, 0); } +static void do_init(struct fuse *f, struct fuse_in_header *in, + struct fuse_init_in_out *arg) +{ + struct fuse_init_in_out outarg; + if (f->flags & FUSE_DEBUG) { + printf(" INIT: %u.%u\n", arg->major, arg->minor); + fflush(stdout); + } + f->got_init = 1; + memset(&outarg, 0, sizeof(outarg)); + outarg.major = FUSE_KERNEL_VERSION; + outarg.minor = FUSE_KERNEL_MINOR_VERSION; + send_reply(f, in, 0, &outarg, sizeof(outarg)); +} static void free_cmd(struct fuse_cmd *cmd) { @@ -1527,6 +1542,12 @@ void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd) fflush(stdout); } + if (!f->got_init && in->opcode != FUSE_INIT) { + /* Old kernel version probably */ + send_reply(f, in, -EPROTO, NULL, 0); + goto out; + } + ctx->fuse = f; ctx->uid = in->uid; ctx->gid = in->gid; @@ -1628,10 +1649,15 @@ void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd) do_removexattr(f, in, (char *) inarg); break; + case FUSE_INIT: + do_init(f, in, (struct fuse_init_in_out *) inarg); + break; + default: send_reply(f, in, -ENOSYS, NULL, 0); } + out: free_cmd(cmd); } @@ -1742,47 +1768,6 @@ void fuse_set_getcontext_func(struct fuse_context *(*func)(void)) fuse_getcontext = func; } -static int check_version(struct fuse *f) -{ - int res; - const char *version_file = FUSE_VERSION_FILE_NEW; - FILE *vf = fopen(version_file, "r"); - if (vf == NULL) { - version_file = FUSE_VERSION_FILE_OLD; - vf = fopen(version_file, "r"); - if (vf == NULL) { - struct stat tmp; - if (stat(FUSE_DEV_OLD, &tmp) != -1) { - fprintf(stderr, "fuse: kernel interface too old, need >= %i.%i\n", - FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION); - return -1; - } else { - fprintf(stderr, "fuse: warning: version of kernel interface unknown\n"); - return 0; - } - } - } - res = fscanf(vf, "%i.%i", &f->majorver, &f->minorver); - fclose(vf); - if (res != 2) { - fprintf(stderr, "fuse: error reading %s\n", version_file); - return -1; - } - if (f->majorver != FUSE_KERNEL_VERSION) { - fprintf(stderr, "fuse: bad kernel interface major version: needs %i\n", - FUSE_KERNEL_VERSION); - return -1; - } - if (f->minorver < FUSE_KERNEL_MINOR_VERSION_NEED) { - fprintf(stderr, "fuse: kernel interface too old: need >= %i.%i\n", - FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION); - return -1; - } - - return 0; -} - - int fuse_is_lib_option(const char *opt) { if (strcmp(opt, "debug") == 0 || @@ -1838,9 +1823,6 @@ struct fuse *fuse_new_common(int fd, const char *opts, goto out; } - if (check_version(f) == -1) - goto out_free; - if (parse_lib_opts(f, opts) == -1) goto out_free; diff --git a/lib/fuse_i.h b/lib/fuse_i.h index ebe712a..284e531 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -28,8 +28,7 @@ struct fuse { int numworker; int numavail; volatile int exited; - int majorver; - int minorver; + int got_init; }; struct fuse *fuse_new_common(int fd, const char *opts, |