diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/fuse.h | 75 | ||||
-rw-r--r-- | include/fuse_common.h | 4 | ||||
-rw-r--r-- | include/fuse_compat.h | 49 | ||||
-rw-r--r-- | include/fuse_lowlevel.h | 25 |
4 files changed, 116 insertions, 37 deletions
diff --git a/include/fuse.h b/include/fuse.h index 831dbff..2e977b2 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -12,9 +12,13 @@ /* This file defines the library interface of FUSE */ /* IMPORTANT: you should define FUSE_USE_VERSION before including this - header. To use the new API define it to 22 (recommended for any - new application), to use the old API define it to 21 (this is the - default), to use the even older 1.X API define it to 11. */ + header. To use the newest API define it to 25 (recommended for any + new application), to use the old API define it to 21 (default) or + 22, to use the even older 1.X API define it to 11. */ + +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 21 +#endif #include "fuse_common.h" @@ -162,8 +166,8 @@ struct fuse_operations { int (*write) (const char *, const char *, size_t, off_t, struct fuse_file_info *); - /** Old statfs interface, deprecated */ - int (*statfs_old) (const char *, void *stbuf); + /** Just a placeholder, don't set */ + void (*statfs_old) (void); /** Possibly flush cached data * @@ -357,7 +361,7 @@ struct fuse_operations { * Replaced 'struct statfs' parameter with 'struct statvfs' in * version 2.5 */ - int (*statfs) (const char *, struct statvfs *stbuf); + int (*statfs) (const char *, struct statvfs *); }; /** Extra context that may be needed by some filesystems @@ -539,37 +543,42 @@ void fuse_set_getcontext_func(struct fuse_context *(*func)(void)); * Compatibility stuff * * ----------------------------------------------------------- */ -#if FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11 +#if FUSE_USE_VERSION == 22 || FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11 # include "fuse_compat.h" -# define fuse_dirfil_t fuse_dirfil_t_compat -# define __fuse_read_cmd fuse_read_cmd -# define __fuse_process_cmd fuse_process_cmd -# define __fuse_loop_mt fuse_loop_mt_proc -# undef fuse_main # undef FUSE_MINOR_VERSION -# undef FUSE_MAJOR_VERSION -# if FUSE_USE_VERSION == 21 -# define FUSE_MAJOR_VERSION 2 -# define FUSE_MINOR_VERSION 1 -# define fuse_operations fuse_operations_compat2 -# define fuse_main fuse_main_compat2 -# define fuse_new fuse_new_compat2 -# define __fuse_setup fuse_setup_compat2 -# define __fuse_teardown fuse_teardown -# define __fuse_exited fuse_exited -# define __fuse_set_getcontext_func fuse_set_getcontext_func +# undef fuse_main +# if FUSE_USE_VERSION == 22 +# define FUSE_MINOR_VERSION 4 +# define fuse_main fuse_main_compat22 +# define fuse_operations fuse_operations_compat22 # else -# define FUSE_MAJOR_VERSION 1 -# define FUSE_MINOR_VERSION 1 -# define fuse_statfs fuse_statfs_compat1 -# define fuse_operations fuse_operations_compat1 -# define fuse_main fuse_main_compat1 -# define fuse_new fuse_new_compat1 -# define fuse_mount fuse_mount_compat1 -# define FUSE_DEBUG FUSE_DEBUG_COMPAT1 +# define fuse_dirfil_t fuse_dirfil_t_compat +# define __fuse_read_cmd fuse_read_cmd +# define __fuse_process_cmd fuse_process_cmd +# define __fuse_loop_mt fuse_loop_mt_proc +# if FUSE_USE_VERSION == 21 +# define FUSE_MAJOR_VERSION 2 +# define fuse_operations fuse_operations_compat2 +# define fuse_main fuse_main_compat2 +# define fuse_new fuse_new_compat2 +# define __fuse_setup fuse_setup_compat2 +# define __fuse_teardown fuse_teardown +# define __fuse_exited fuse_exited +# define __fuse_set_getcontext_func fuse_set_getcontext_func +# else +# undef FUSE_MAJOR_VERSION +# define FUSE_MAJOR_VERSION 1 +# define FUSE_MINOR_VERSION 1 +# define fuse_statfs fuse_statfs_compat1 +# define fuse_operations fuse_operations_compat1 +# define fuse_main fuse_main_compat1 +# define fuse_new fuse_new_compat1 +# define fuse_mount fuse_mount_compat1 +# define FUSE_DEBUG FUSE_DEBUG_COMPAT1 +# endif # endif -#elif FUSE_USE_VERSION < 22 -# error Compatibility with API version other than 21 and 11 not supported +#elif FUSE_USE_VERSION < 25 +# error Compatibility with API version other than 21, 22 and 11 not supported #endif #ifdef __cplusplus diff --git a/include/fuse_common.h b/include/fuse_common.h index a59aea6..96f4702 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -13,10 +13,6 @@ #ifndef _FUSE_COMMON_H_ #define _FUSE_COMMON_H_ -#ifndef FUSE_USE_VERSION -#define FUSE_USE_VERSION 21 -#endif - /** Major version of FUSE library interface */ #define FUSE_MAJOR_VERSION 2 diff --git a/include/fuse_compat.h b/include/fuse_compat.h index 08d391a..176560f 100644 --- a/include/fuse_compat.h +++ b/include/fuse_compat.h @@ -11,6 +11,55 @@ #include <sys/statfs.h> +struct fuse_operations_compat22 { + 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 statfs *); + 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) (void); + 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 *); + void (*statfs_new) (void); +}; + +static inline int fuse_main_compat22(int argc, char *argv[], + const struct fuse_operations_compat22 *op) +{ + return fuse_main_real(argc, argv, (const struct fuse_operations *) op, + sizeof(*op)); +} + + typedef int (*fuse_dirfil_t_compat) (fuse_dirh_t h, const char *name, int type); struct fuse_operations_compat2 { int (*getattr) (const char *, struct stat *); diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index f90d021..d2b43a2 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -13,6 +13,14 @@ * Low level API * * =========================================================== */ +/* IMPORTANT: you should define FUSE_USE_VERSION before including this + header. To use the newest API define it to 25 (recommended for any + new application), to use the old API define it to 24 (default) */ + +#ifndef FUSE_USE_VERSION +#define FUSE_USE_VERSION 24 +#endif + #include "fuse_common.h" #include <utime.h> @@ -1198,6 +1206,23 @@ int fuse_chan_send(struct fuse_chan *ch, const struct iovec iov[], */ void fuse_chan_destroy(struct fuse_chan *ch); +/* ----------------------------------------------------------- * + * Compatibility stuff * + * ----------------------------------------------------------- */ + +#if FUSE_USE_VERSION == 24 +#include <sys/statfs.h> + +int fuse_reply_statfs_compat(fuse_req_t req, const struct statfs *stbuf); + +#undef FUSE_MINOR_VERSION +#define FUSE_MINOR_VERSION 4 +#define fuse_reply_statfs fuse_reply_statfs_compat + +#elif FUSE_USE_VERSION < 25 +# error Compatibility with low level API version other than 24 not supported +#endif + #ifdef __cplusplus } #endif |