Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librefuse/refuse lib/librefuse: Implement all sorts of c...
details: https://anonhg.NetBSD.org/src/rev/7f40f5adee5f
branches: trunk
changeset: 359772:7f40f5adee5f
user: pho <pho%NetBSD.org@localhost>
date: Sat Jan 22 08:09:39 2022 +0000
description:
lib/librefuse: Implement all sorts of compat tweaks to appease various file systems
ReFUSE now supports all the FUSE API variants from FUSE 1.1 to FUSE
3.10. Sorry for the freaking giant patch. I could not break it down
any further.
diffstat:
distrib/sets/lists/comp/mi | 17 +-
lib/librefuse/HACKING.md | 59 +
lib/librefuse/TODO | 15 +-
lib/librefuse/fuse.h | 560 +++++++++-
lib/librefuse/fuse_internal.h | 25 +-
lib/librefuse/fuse_lowlevel.h | 11 +-
lib/librefuse/refuse.c | 450 +++-----
lib/librefuse/refuse/Makefile.inc | 26 +-
lib/librefuse/refuse/chan.c | 248 +++++
lib/librefuse/refuse/chan.h | 80 +
lib/librefuse/refuse/fs.c | 1802 +++++++++++++++++++++++++++++++++++++
lib/librefuse/refuse/fs.h | 120 ++
lib/librefuse/refuse/v11.c | 181 +++
lib/librefuse/refuse/v11.h | 92 +
lib/librefuse/refuse/v21.c | 108 ++
lib/librefuse/refuse/v21.h | 86 +
lib/librefuse/refuse/v22.c | 67 +
lib/librefuse/refuse/v22.h | 89 +
lib/librefuse/refuse/v23.h | 88 +
lib/librefuse/refuse/v25.c | 115 ++
lib/librefuse/refuse/v25.h | 99 ++
lib/librefuse/refuse/v26.c | 113 ++
lib/librefuse/refuse/v26.h | 111 ++
lib/librefuse/refuse/v28.h | 95 +
lib/librefuse/refuse/v29.h | 101 ++
lib/librefuse/refuse/v30.c | 72 +
lib/librefuse/refuse/v30.h | 129 ++
lib/librefuse/refuse/v32.c | 42 +
lib/librefuse/refuse/v32.h | 52 +
lib/librefuse/refuse/v34.h | 95 +
lib/librefuse/refuse/v35.h | 95 +
lib/librefuse/refuse/v38.h | 96 +
lib/librefuse/refuse_compat.c | 108 ++-
lib/librefuse/refuse_lowlevel.c | 7 +-
34 files changed, 5083 insertions(+), 371 deletions(-)
diffs (truncated from 6109 to 300 lines):
diff -r 5e73ef704388 -r 7f40f5adee5f distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Sat Jan 22 08:07:02 2022 +0000
+++ b/distrib/sets/lists/comp/mi Sat Jan 22 08:09:39 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2408 2022/01/22 07:57:30 pho Exp $
+# $NetBSD: mi,v 1.2409 2022/01/22 08:09:39 pho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -3093,9 +3093,24 @@
./usr/include/readline/history.h comp-c-include
./usr/include/readline/readline.h comp-c-include
./usr/include/refuse/buf.h comp-refuse-include
+./usr/include/refuse/chan.h comp-refuse-include
+./usr/include/refuse/fs.h comp-refuse-include
./usr/include/refuse/legacy.h comp-refuse-include
./usr/include/refuse/poll.h comp-refuse-include
./usr/include/refuse/session.h comp-refuse-include
+./usr/include/refuse/v11.h comp-refuse-include
+./usr/include/refuse/v21.h comp-refuse-include
+./usr/include/refuse/v22.h comp-refuse-include
+./usr/include/refuse/v23.h comp-refuse-include
+./usr/include/refuse/v25.h comp-refuse-include
+./usr/include/refuse/v26.h comp-refuse-include
+./usr/include/refuse/v28.h comp-refuse-include
+./usr/include/refuse/v29.h comp-refuse-include
+./usr/include/refuse/v30.h comp-refuse-include
+./usr/include/refuse/v32.h comp-refuse-include
+./usr/include/refuse/v34.h comp-refuse-include
+./usr/include/refuse/v35.h comp-refuse-include
+./usr/include/refuse/v38.h comp-refuse-include
./usr/include/regex.h comp-c-include
./usr/include/regexp.h comp-c-include
./usr/include/res_update.h comp-c-include
diff -r 5e73ef704388 -r 7f40f5adee5f lib/librefuse/HACKING.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/librefuse/HACKING.md Sat Jan 22 08:09:39 2022 +0000
@@ -0,0 +1,59 @@
+<!--
+ $NetBSD: HACKING.md,v 1.1 2022/01/22 08:09:39 pho Exp $
+-->
+
+# How to add support for a new API version
+
+1. Update `_REFUSE_MAJOR_VERSION_` and/or `_REFUSE_MINOR_VERSION_` in
+ `fuse.h`.
+2. If the new API introduces some new typedefs, enums, constants,
+ functions, or struct fields, define them *unconditionally*. Trying
+ to conditionalize them will only increase complexity of the
+ implementation without necessity.
+3. If the new API removes some existing declarations, move them to
+ `./refuse/legacy.[ch]`. There is no need to conditionally hide
+ them.
+4. If the new API doesn't change any of existing declarations, you are
+ lucky. You are **tremendously** lucky. But if it does, things get
+ interesting... (Spoiler: this happens all the time. All, the,
+ time. As if there still weren't enough API-breaking changes in the
+ history of FUSE API.)
+
+## If it breaks API compatibility by changing function prototypes or whatever
+
+1. Create a new header `./refuse/v${VERSION}.h`. Don't forget to add it
+ in `./refuse/Makefile.inc` and `../../distrib/sets/lists/comp/mi`.
+2. Include it from `./fuse.h` and add a new conditionalized section at
+ the bottom of it. The whole point of the section is to choose
+ correct symbols (or types, or whatever) and expose them without a
+ version postfix.
+
+### If it changes `struct fuse_operations`
+
+1. Add `#define _FUSE_OP_VERSION__` for the new API version in the
+ conditionalized section.
+2. Define `struct fuse_operations_v${VERSION}` in `v${VERSION}.h`.
+3. Update `./refuse/fs.c`. This is the abstraction layer which absorbs
+ all the subtle differences in `struct fuse_operations` between
+ versions. Every function has to be updated for the new version.
+
+### If it changes anything else that are already versioned
+
+1. Declare them in `./refuse/v${VERSION}.h` with a version postfix.
+2. Update the conditionalized section for the version in `./fuse.h` so
+ that it exposes the correct definition to user code.
+3. Create `./refuse/v${VERSION}.c` and implement version-specific
+ functions in it. Don't forget to add it to `./refuse/Makefile.inc`.
+
+### If it changes something that have never been changed before
+
+1. Move them from the unconditionalized part of the implementation to
+ `./refuse/v${VERSION}.[ch]`.
+2. Add a version postfix to them.
+3. Update every single conditionalized section in `./fuse.h` so that
+ they will be conditionally exposed without a version postfix
+ depending the value of `FUSE_USE_VERSION`. If you cannot just
+ `#define` them but need to introduce some functions, inline
+ functions are preferred over function macros because the latter
+ lack types and are therefore error-prone. Preprocessor conditionals
+ are already error-prone so don't make them worse.
diff -r 5e73ef704388 -r 7f40f5adee5f lib/librefuse/TODO
--- a/lib/librefuse/TODO Sat Jan 22 08:07:02 2022 +0000
+++ b/lib/librefuse/TODO Sat Jan 22 08:09:39 2022 +0000
@@ -1,4 +1,4 @@
- $NetBSD: TODO,v 1.7 2022/01/22 07:58:32 pho Exp $
+ $NetBSD: TODO,v 1.8 2022/01/22 08:09:39 pho Exp $
To Do
=====
@@ -7,15 +7,22 @@
support fuse_mt (i.e. worker threads, but that'll probably be smarter
to do inside of libpuffs)
support fuse_ll (i.e. "raw" vfs/vnode export)
-implement all sorts of compat tweaks to appease various file systems
do proper implementations of dirfillers
-statfs - some fuse file systems want struct statfs and we only have
- statvfs available natively
+Implement filesystem module API appeared on FUSE 2.7 (struct fuse_module).
+Support flags and options in struct fuse_file_info. They all are ignored atm.
+Support capabilities and other options in struct fuse_conn_info. They all are ignored atm.
Support polling appeared on FUSE 2.8 (struct fuse_pollhandle).
Support data buffers appeared on FUSE 2.9 (struct fuse_buf).
+Support fsync operation.
+Support access() operation.
+Support flock operation.
+Support fallocate operation.
+Support ioctl appeared on FUSE 2.8 (probably impossible due to incompatibilities with Linux).
Done
====
+implement all sorts of compat tweaks to appease various file systems
+Linux-specific statfs
statvfs
sync
WARNS=6
diff -r 5e73ef704388 -r 7f40f5adee5f lib/librefuse/fuse.h
--- a/lib/librefuse/fuse.h Sat Jan 22 08:07:02 2022 +0000
+++ b/lib/librefuse/fuse.h Sat Jan 22 08:09:39 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.33 2022/01/22 08:06:21 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.34 2022/01/22 08:09:39 pho Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@@ -33,6 +33,7 @@
#include <fcntl.h>
#include <fuse_opt.h>
#include <refuse/buf.h>
+#include <refuse/chan.h>
#include <refuse/legacy.h>
#include <refuse/poll.h>
#include <refuse/session.h>
@@ -54,8 +55,8 @@
/* 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 _REFUSE_MAJOR_VERSION_ 3
+#define _REFUSE_MINOR_VERSION_ 10
#define _REFUSE_VERSION_ FUSE_MAKE_VERSION(_REFUSE_MAJOR_VERSION_, _REFUSE_MINOR_VERSION_)
@@ -222,71 +223,10 @@
*/
#define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 }
-
-typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *, off_t);
-typedef int (*fuse_dirfil_t)(fuse_dirh_t, const char *, int, ino_t);
-
-/*
- * These operations shadow those in puffs_usermount, and are used
- * as a table of callbacks to make when file system requests come
- * in.
- *
- * NOTE: keep same order as fuse
- */
-struct fuse_operations {
- int (*getattr)(const char *, struct stat *);
- int (*readlink)(const char *, char *, size_t);
- int (*getdir)(const char *, fuse_dirh_t, fuse_dirfil_t);
- int (*mknod)(const char *, mode_t, dev_t);
- int (*mkdir)(const char *, mode_t);
- int (*unlink)(const char *);
- int (*rmdir)(const char *);
- int (*symlink)(const char *, const char *);
- int (*rename)(const char *, const char *);
- int (*link)(const char *, const char *);
- int (*chmod)(const char *, mode_t);
- int (*chown)(const char *, uid_t, gid_t);
- int (*truncate)(const char *, off_t);
- int (*utime)(const char *, struct utimbuf *);
- int (*open)(const char *, struct fuse_file_info *);
- int (*read)(const char *, char *, size_t, off_t, struct fuse_file_info *);
- int (*write)(const char *, const char *, size_t, off_t, struct fuse_file_info *);
- int (*statfs)(const char *, struct statvfs *);
- int (*flush)(const char *, struct fuse_file_info *);
- int (*release)(const char *, struct fuse_file_info *);
- int (*fsync)(const char *, int, struct fuse_file_info *);
- int (*setxattr)(const char *, const char *, const char *, size_t, int);
- int (*getxattr)(const char *, const char *, char *, size_t);
- int (*listxattr)(const char *, char *, size_t);
- int (*removexattr)(const char *, const char *);
- int (*opendir)(const char *, struct fuse_file_info *);
- int (*readdir)(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *);
- int (*releasedir)(const char *, struct fuse_file_info *);
- int (*fsyncdir)(const char *, int, struct fuse_file_info *);
- void *(*init)(struct fuse_conn_info *);
- void (*destroy)(void *);
- int (*access)(const char *, int);
- int (*create)(const char *, mode_t, struct fuse_file_info *);
- int (*ftruncate)(const char *, off_t, struct fuse_file_info *);
- int (*fgetattr)(const char *, struct stat *, struct fuse_file_info *);
- int (*lock)(const char *, struct fuse_file_info *, int, struct flock *);
- int (*utimens)(const char *, const struct timespec *);
- int (*bmap)(const char *, size_t , uint64_t *);
-};
-
-
-struct fuse *fuse_new(struct fuse_args *,
- const struct fuse_operations *, size_t, void *);
-
-int fuse_mount(struct fuse *, const char *);
-void fuse_unmount(struct fuse *);
-
-int fuse_main_real(int, char **, const struct fuse_operations *, size_t, void *);
/* Functions that have existed since the beginning and have never
* changed between API versions. */
int fuse_loop(struct fuse *);
void fuse_exit(struct fuse *);
-void fuse_destroy(struct fuse *);
struct fuse_context *fuse_get_context(void);
/* Print available library options. Appeared on FUSE 3.1. */
@@ -307,19 +247,6 @@
/* Get the version number of the library. Appeared on FUSE 2.7. */
int fuse_version(void);
-#if FUSE_USE_VERSION == 22
-#define fuse_unmount fuse_unmount_compat22
-#endif
-
-void fuse_unmount_compat22(const char *);
-
-#if FUSE_USE_VERSION >= 26
-#define fuse_main(argc, argv, op, user_data) \
- fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)
-#else
-#define fuse_main(argc, argv, op) \
- fuse_main_real(argc, argv, op, sizeof(*(op)), NULL)
-#endif
/* Get the version string of the library. Appeared on FUSE 3.0. */
const char *fuse_pkgversion(void);
@@ -340,6 +267,485 @@
* cleanup. Appeared on FUSE 2.9. */
int fuse_clean_cache(struct fuse *fuse);
+/* Generic implementation of fuse_main(). The exact type of "op" is
+ * determined by op_version. This is only an implementation detail:
+ * user code should never call this directly. */
+int __fuse_main(int argc, char* argv[],
+ const void* op, int op_version, void* user_data);
+
+/* NOTE: Compatibility headers are included
+ * unconditionally. Declarations in these headers all have a version
+ * postfix, and need to be aliased depending on FUSE_USE_VERSION. */
+#include <refuse/v11.h>
+#include <refuse/v21.h>
+#include <refuse/v22.h>
+#include <refuse/v23.h>
+#include <refuse/v25.h>
+#include <refuse/v26.h>
+#include <refuse/v28.h>
+#include <refuse/v29.h>
+#include <refuse/v30.h>
+#include <refuse/v32.h>
+#include <refuse/v34.h>
+#include <refuse/v35.h>
+#include <refuse/v38.h>
+
+/* NOTE: refuse/fs.h relies on some typedef's in refuse/v*.h */
+#include <refuse/fs.h>
+
+#define _MK_FUSE_OPERATIONS_(VER) __CONCAT(fuse_operations_v,VER)
+
+/* Version specific types and functions. */
+#if defined(FUSE_USE_VERSION)
+/* ===== FUSE 1.x ===== */
+# if FUSE_USE_VERSION < 21
+ /* Types */
+# define _FUSE_OP_VERSION__ 11 /* Implementation detail */
+# define fuse_dirfil_t fuse_dirfil_t_v11
+# define fuse_operations _MK_FUSE_OPERATIONS_(_FUSE_OP_VERSION__)
+ /* Functions */
+static __inline int
+fuse_main(int argc, char *argv[], const struct fuse_operations *op) {
+ return __fuse_main(argc, argv, op, _FUSE_OP_VERSION__, NULL);
+}
+# define fuse_mount fuse_mount_v11
+# define fuse_unmount fuse_unmount_v11
+static __inline struct fuse *
Home |
Main Index |
Thread Index |
Old Index