aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am2
-rw-r--r--include/fuse.h63
-rw-r--r--include/fuse_compat.h85
3 files changed, 144 insertions, 6 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index f6f1600..14ac9d9 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
fuseincludedir=$(includedir)/fuse
-fuseinclude_HEADERS = fuse.h
+fuseinclude_HEADERS = fuse.h fuse_compat.h
noinst_HEADERS = fuse_kernel.h
# remove fuse.h from old place to avoid collision with new one
diff --git a/include/fuse.h b/include/fuse.h
index 072ac22..3223155 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -11,11 +11,20 @@
/* 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, to use the
+ even older 1.X API define it to 11. */
+
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 21
+#endif
+
/** Major version of FUSE library interface */
-#define FUSE_MAJOR_VERSION 3
+#define FUSE_MAJOR_VERSION 2
/** Minor version of FUSE library interface */
-#define FUSE_MINOR_VERSION 0
+#define FUSE_MINOR_VERSION 2
/* This interface uses 64 bit off_t */
#if _FILE_OFFSET_BITS != 64
@@ -174,12 +183,15 @@ struct fuse_context {
* - registers the operations
* - calls either the single-threaded or the multi-threaded event loop
*
+ * Note: this is currently implemented as a macro.
+ *
* @param argc the argument counter passed to the main() function
* @param argv the argument vector passed to the main() function
* @param op the file system operation
* @return 0 on success, nonzero on failure
*/
-int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
+/* int fuse_main(int argc, char *argv[], const struct fuse_operations *op); */
+#define fuse_main(argc, argv, op) __fuse_main(argc, argv, op, sizeof(*(op)))
/* ----------------------------------------------------------- *
* More detailed API *
@@ -210,10 +222,11 @@ void fuse_unmount(const char *mountpoint);
* @param fd the control file descriptor
* @param opts mount options to be used by the library
* @param op the operations
+ * @param op_size the size of the fuse_operations structure
* @return the created FUSE handle
*/
struct fuse *fuse_new(int fd, const char *opts,
- const struct fuse_operations *op);
+ const struct fuse_operations *op, size_t op_size);
/**
* Destroy the FUSE handle.
@@ -287,6 +300,14 @@ int fuse_invalidate(struct fuse *f, const char *path);
*/
int fuse_is_lib_option(const char *opt);
+/**
+ * The real main function
+ *
+ * Do not call this directly, use fuse_main()
+ */
+int __fuse_main(int argc, char *argv[], const struct fuse_operations *op,
+ size_t op_size);
+
/* ----------------------------------------------------------- *
* Advanced API for event handling, don't worry about this... *
* ----------------------------------------------------------- */
@@ -294,7 +315,7 @@ int fuse_is_lib_option(const char *opt);
struct fuse_cmd;
typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);
struct fuse *__fuse_setup(int argc, char *argv[],
- const struct fuse_operations *op,
+ const struct fuse_operations *op, size_t op_size,
char **mountpoint, int *multithreaded, int *fd);
void __fuse_teardown(struct fuse *fuse, int fd, char *mountpoint);
struct fuse_cmd *__fuse_read_cmd(struct fuse *f);
@@ -303,6 +324,38 @@ int __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data);
int __fuse_exited(struct fuse* f);
void __fuse_set_getcontext_func(struct fuse_context *(*func)(void));
+/* ----------------------------------------------------------- *
+ * Compatibility stuff *
+ * ----------------------------------------------------------- */
+
+#if FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11
+# include <fuse_compat.h>
+# define fuse_dirfil_t _fuse_dirfil_t_compat
+# 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
+# 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
+#elif FUSE_USE_VERSION != 22
+# error API version other than 22, 21 and 11 not supported
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/include/fuse_compat.h b/include/fuse_compat.h
new file mode 100644
index 0000000..7ec9a29
--- /dev/null
+++ b/include/fuse_compat.h
@@ -0,0 +1,85 @@
+/*
+ FUSE: Filesystem in Userspace
+ Copyright (C) 2001-2004 Miklos Szeredi <miklos@szeredi.hu>
+
+ This program can be distributed under the terms of the GNU LGPL.
+ See the file COPYING.LIB.
+*/
+
+/* these definitions provide source compatibility to prior versions.
+ Do not include this file directly! */
+
+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 *);
+ int (*readlink) (const char *, char *, size_t);
+ int (*getdir) (const char *, fuse_dirh_t, _fuse_dirfil_t_compat);
+ 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 *, int);
+ int (*read) (const char *, char *, size_t, off_t);
+ int (*write) (const char *, const char *, size_t, off_t);
+ int (*statfs) (const char *, struct statfs *);
+ int (*flush) (const char *);
+ int (*release) (const char *, int);
+ int (*fsync) (const char *, int);
+ 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 _fuse_main_compat2(int argc, char *argv[], const struct _fuse_operations_compat2 *op);
+
+struct fuse *_fuse_new_compat2(int fd, const char *opts, const struct _fuse_operations_compat2 *op);
+
+struct fuse *_fuse_setup_compat2(int argc, char *argv[], const struct _fuse_operations_compat2 *op, char **mountpoint, int *multithreaded, int *fd);
+
+struct _fuse_statfs_compat1 {
+ long block_size;
+ long blocks;
+ long blocks_free;
+ long files;
+ long files_free;
+ long namelen;
+};
+
+struct _fuse_operations_compat1 {
+ int (*getattr) (const char *, struct stat *);
+ int (*readlink) (const char *, char *, size_t);
+ int (*getdir) (const char *, fuse_dirh_t, _fuse_dirfil_t_compat);
+ 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 *, int);
+ int (*read) (const char *, char *, size_t, off_t);
+ int (*write) (const char *, const char *, size_t, off_t);
+ int (*statfs) (struct _fuse_statfs_compat1 *);
+ int (*release) (const char *, int);
+ int (*fsync) (const char *, int);
+};
+
+#define _FUSE_DEBUG_COMPAT1 (1 << 1)
+
+int _fuse_mount_compat1(const char *mountpoint, const char *args[]);
+
+struct fuse *_fuse_new_compat1(int fd, int flags, const struct _fuse_operations_compat1 *op);
+
+void _fuse_main_compat1(int argc, char *argv[], const struct _fuse_operations_compat1 *op);