Module Name: src Committed By: pho Date: Sat Jan 22 08:01:12 UTC 2022
Modified Files: src/lib/librefuse: fuse.h fuse_internal.h refuse.c Log Message: Change the way how FUSE_*_VERSION are handled * FUSE_MAKE_VERSION(maj, min) now generates a 3-digits number if the version is higher than 3.9. This is needed to support FUSE 3.10 API. * FUSE_{MAJOR,MINOR}_VERSION no longer have a fixed value but are derived from FUSE_USE_VERSION specified by the user code. This is needed to support more FUSE filesystems in the wild. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/librefuse/fuse.h cvs rdiff -u -r1.2 -r1.3 src/lib/librefuse/fuse_internal.h cvs rdiff -u -r1.108 -r1.109 src/lib/librefuse/refuse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/librefuse/fuse.h diff -u src/lib/librefuse/fuse.h:1.28 src/lib/librefuse/fuse.h:1.29 --- src/lib/librefuse/fuse.h:1.28 Sat Jan 22 07:57:30 2022 +++ src/lib/librefuse/fuse.h Sat Jan 22 08:01:12 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fuse.h,v 1.28 2022/01/22 07:57:30 pho Exp $ */ +/* $NetBSD: fuse.h,v 1.29 2022/01/22 08:01:12 pho Exp $ */ /* * Copyright © 2007 Alistair Crooks. All rights reserved. @@ -40,24 +40,52 @@ #include <sys/types.h> #include <utime.h> -/* The latest version of FUSE API currently provided by refuse. */ -#define FUSE_MAJOR_VERSION 2 -#define FUSE_MINOR_VERSION 6 +/* This used to be (maj) * 10 + (min) until FUSE 3.10, and then + * changed to (maj) * 100 + (min). We can't just use the "newer" + * definition because filesystems in the wild still use the older one + * in their FUSE_USE_VERSION request. */ +#define FUSE_MAKE_VERSION(maj, min) \ + (((maj) > 3 || ((maj) == 3 && (min) >= 10)) \ + ? (maj) * 100 + (min) \ + : (maj) * 10 + (min)) + +/* The latest version of FUSE API currently provided by ReFUSE. This + * is an implementation detail. User code should not rely on this + * constant. */ +#define _REFUSE_MAJOR_VERSION_ 2 +#define _REFUSE_MINOR_VERSION_ 6 -#define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (min)) -#define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION) +#define _REFUSE_VERSION_ FUSE_MAKE_VERSION(_REFUSE_MAJOR_VERSION_, _REFUSE_MINOR_VERSION_) /* FUSE_USE_VERSION is expected to be defined by user code to * determine the API to be used. Although defining this macro is * mandatory in the original FUSE implementation, refuse hasn't * required this so we only emit a warning if it's undefined. */ #if defined(FUSE_USE_VERSION) -# if FUSE_USE_VERSION > FUSE_VERSION +# if FUSE_USE_VERSION > _REFUSE_VERSION_ # warning "The requested API version is higher than the latest one supported by refuse." +# elif FUSE_USE_VERSION < 11 +# warning "The requested API version is lower than the oldest one supported by refuse." # endif #else -# warning "User code including <fuse.h> should define FUSE_USE_VERSION before including this header. Defaulting to the latest version." -# define FUSE_USE_VERSION FUSE_VERSION +# if !defined(_REFUSE_IMPLEMENTATION_) +# warning "User code including <fuse.h> should define FUSE_USE_VERSION before including this header. Defaulting to the latest version." +# define FUSE_USE_VERSION _REFUSE_VERSION_ +# endif +#endif + +/* FUSE_VERSION is supposed to be the latest version of FUSE API + * supported by the library. However, due to the way how original FUSE + * is implemented, some filesystems set FUSE_USE_VERSION to some old + * one and then expect the actual API version exposed by the library + * to be something newer if FUSE_VERSION is higher than that. ReFUSE + * doesn't work that way, so this has to be always identical to + * FUSE_USE_VERSION. + */ +#if defined(FUSE_USE_VERSION) +# define FUSE_VERSION FUSE_USE_VERSION +# define FUSE_MAJOR_VERSION (FUSE_VERSION / 10) +# define FUSE_MINOR_VERSION (FUSE_VERSION % 10) #endif #ifdef __cplusplus Index: src/lib/librefuse/fuse_internal.h diff -u src/lib/librefuse/fuse_internal.h:1.2 src/lib/librefuse/fuse_internal.h:1.3 --- src/lib/librefuse/fuse_internal.h:1.2 Sat Jan 22 07:53:06 2022 +++ src/lib/librefuse/fuse_internal.h Sat Jan 22 08:01:12 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fuse_internal.h,v 1.2 2022/01/22 07:53:06 pho Exp $ */ +/* $NetBSD: fuse_internal.h,v 1.3 2022/01/22 08:01:12 pho Exp $ */ /* * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -32,9 +32,9 @@ #define FUSE_INTERNAL_H /* We emit a compiler warning for anyone including <fuse.h> without - * defining FUSE_USE_VERSION. Define it here, or otherwise we'll be + * defining FUSE_USE_VERSION. Exempt ourselves here, or we'll be * warned too. */ -#define FUSE_USE_VERSION FUSE_VERSION +#define _REFUSE_IMPLEMENTATION_ #include <fuse.h> #include <fuse_lowlevel.h> Index: src/lib/librefuse/refuse.c diff -u src/lib/librefuse/refuse.c:1.108 src/lib/librefuse/refuse.c:1.109 --- src/lib/librefuse/refuse.c:1.108 Sat Jan 22 08:00:17 2022 +++ src/lib/librefuse/refuse.c Sat Jan 22 08:01:12 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: refuse.c,v 1.108 2022/01/22 08:00:17 pho Exp $ */ +/* $NetBSD: refuse.c,v 1.109 2022/01/22 08:01:12 pho Exp $ */ /* * Copyright © 2007 Alistair Crooks. All rights reserved. @@ -31,14 +31,9 @@ #include <sys/cdefs.h> #if !defined(lint) -__RCSID("$NetBSD: refuse.c,v 1.108 2022/01/22 08:00:17 pho Exp $"); +__RCSID("$NetBSD: refuse.c,v 1.109 2022/01/22 08:01:12 pho Exp $"); #endif /* !lint */ -/* We emit a compiler warning for anyone including <fuse.h> without - * defining FUSE_USE_VERSION. Define it here, or otherwise we'll be - * warned too. */ -#define FUSE_USE_VERSION FUSE_VERSION - #include <sys/types.h> #include <assert.h> @@ -1417,7 +1412,7 @@ fuse_invalidate_path(struct fuse *fuse _ int fuse_version(void) { - return FUSE_VERSION; + return _REFUSE_VERSION_; } /* This is a legacy function that has been removed from the FUSE API,