From 39c7d8538dbe69662a15f65ea88ba40bce1016e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 10 Nov 2014 08:52:23 +0100 Subject: [PATCH] Set the fuse protocol fall back to 7.12 when available The support for ioctls has been added to fuse when using protocol 7.18, and an equivalent upgrade has been done in fuse lite with commit [ae9aee]. For old kernels, a fall back to protocol 7.8 was implemented, but this appears not to be supported in not-so-old kernels (e.g. 2.6.35). With this patch, the fall back protocol is set to 7.12 or to the highest level supported by the kernel. --- include/fuse-lite/fuse_kernel.h | 5 +++-- libfuse-lite/fuse_lowlevel.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/fuse-lite/fuse_kernel.h b/include/fuse-lite/fuse_kernel.h index cefbc499..c031b04f 100644 --- a/include/fuse-lite/fuse_kernel.h +++ b/include/fuse-lite/fuse_kernel.h @@ -56,11 +56,12 @@ #define FUSE_KERNEL_MINOR_VERSION 18 /* - * For binary compatibility with old kernels we accept falling back to 7.8 + * For binary compatibility with old kernels we accept falling back + * to 7.12 or earlier maximum version supported by the kernel */ #define FUSE_KERNEL_MAJOR_FALLBACK 7 -#define FUSE_KERNEL_MINOR_FALLBACK 8 +#define FUSE_KERNEL_MINOR_FALLBACK 12 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 diff --git a/libfuse-lite/fuse_lowlevel.c b/libfuse-lite/fuse_lowlevel.c index 5e13e522..ee01c7c1 100644 --- a/libfuse-lite/fuse_lowlevel.c +++ b/libfuse-lite/fuse_lowlevel.c @@ -1105,7 +1105,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) outarg.major = FUSE_KERNEL_VERSION; /* * Suggest using protocol 7.18 when available, and fallback - * to 7.8 when running on an old kernel. + * to 7.12 or even earlier when running on an old kernel. * Protocol 7.12 has the ability to process the umask * conditionnally (as needed if POSIXACLS is set) * Protocol 7.18 has the ability to process the ioctls @@ -1119,8 +1119,20 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) outarg.flags |= FUSE_DONT_MASK; #endif } else { + /* Never use a version more recent than supported by the kernel */ + if ((arg->major < FUSE_KERNEL_MAJOR_FALLBACK) + || ((arg->major == FUSE_KERNEL_MAJOR_FALLBACK) + && (arg->minor < FUSE_KERNEL_MINOR_FALLBACK))) { + outarg.major = arg->major; + outarg.minor = arg->minor; + } else { outarg.major = FUSE_KERNEL_MAJOR_FALLBACK; outarg.minor = FUSE_KERNEL_MINOR_FALLBACK; +#ifdef POSIXACLS + if (f->conn.want & FUSE_CAP_DONT_MASK) + outarg.flags |= FUSE_DONT_MASK; +#endif + } } if (f->conn.async_read) outarg.flags |= FUSE_ASYNC_READ;