+2009-07-16 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Clarify how the protocol version should be negotiated between
+ kernel and userspace. Notably libfuse didn't correctly handle the
+ case when the supported major versions didn't match
+
2009-07-02 Miklos Szeredi <miklos@szeredi.hu>
* The context is extended with a 'umask' field. The umask is sent
#define __u32 uint32_t
#define __s32 int32_t
+/*
+ * Version negotiation:
+ *
+ * Both the kernel and userspace send the version they support in the
+ * INIT request and reply respectively.
+ *
+ * If the major versions match then both shall use the smallest
+ * of the two minor versions for communication.
+ *
+ * If the kernel supports a larger major version, then userspace shall
+ * reply with the major version it supports, ignore the rest of the
+ * INIT message and expect a new INIT message from the kernel with a
+ * matching major version.
+ *
+ * If the library supports a larger major version, then it shall fall
+ * back to the major protocol version sent by the kernel for
+ * communication and reply with that major version (and an arbitrary
+ * supported minor version).
+ */
+
/** Version number of this interface */
#define FUSE_KERNEL_VERSION 7
(void) nodeid;
if (f->debug) {
fprintf(stderr, "INIT: %u.%u\n", arg->major, arg->minor);
- if (arg->major > 7 || (arg->major == 7 && arg->minor >= 6)) {
+ if (arg->major == 7 && arg->minor >= 6) {
fprintf(stderr, "flags=0x%08x\n", arg->flags);
fprintf(stderr, "max_readahead=0x%08x\n",
arg->max_readahead);
f->conn.capable = 0;
f->conn.want = 0;
+ memset(&outarg, 0, sizeof(outarg));
+ outarg.major = FUSE_KERNEL_VERSION;
+ outarg.minor = FUSE_KERNEL_MINOR_VERSION;
+
if (arg->major < 7) {
fprintf(stderr, "fuse: unsupported protocol version: %u.%u\n",
arg->major, arg->minor);
return;
}
- if (arg->major > 7 || (arg->major == 7 && arg->minor >= 6)) {
+ if (arg->major > 7) {
+ /* Wait for a second INIT request with a 7.X version */
+ send_reply_ok(req, &outarg, sizeof(outarg));
+ return;
+ }
+
+ if (arg->minor >= 6) {
if (f->conn.async_read)
f->conn.async_read = arg->flags & FUSE_ASYNC_READ;
if (arg->max_readahead < f->conn.max_readahead)
if (f->op.init)
f->op.init(f->userdata, &f->conn);
- memset(&outarg, 0, sizeof(outarg));
- outarg.major = FUSE_KERNEL_VERSION;
- outarg.minor = FUSE_KERNEL_MINOR_VERSION;
if (f->conn.async_read || (f->conn.want & FUSE_CAP_ASYNC_READ))
outarg.flags |= FUSE_ASYNC_READ;
if (f->conn.want & FUSE_CAP_POSIX_LOCKS)