aboutsummaryrefslogtreecommitdiff
path: root/include/fuse.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/fuse.h')
-rw-r--r--include/fuse.h204
1 files changed, 41 insertions, 163 deletions
diff --git a/include/fuse.h b/include/fuse.h
index c657e67..b8a9307 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -13,21 +13,13 @@
*
* This file defines the library interface of FUSE
*
- * IMPORTANT: you should define FUSE_USE_VERSION before including this
- * header. To use the newest API define it to 26 (recommended for any
- * new application), to use the old API define it to 21 (default) 22
- * or 25, to use the even older 1.X API define it to 11.
+ * IMPORTANT: you should define FUSE_USE_VERSION before including this header.
*/
-#ifndef FUSE_USE_VERSION
-#define FUSE_USE_VERSION 21
-#endif
-
#include "fuse_common.h"
#include <fcntl.h>
#include <time.h>
-#include <utime.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
@@ -44,9 +36,6 @@ extern "C" {
/** Handle for a FUSE filesystem */
struct fuse;
-/** Structure containing a raw command */
-struct fuse_cmd;
-
/** Function to add an entry in a readdir() operation
*
* @param buf the buffer passed to the readdir() operation
@@ -58,11 +47,6 @@ struct fuse_cmd;
typedef int (*fuse_fill_dir_t) (void *buf, const char *name,
const struct stat *stbuf, off_t off);
-/* Used by deprecated getdir() method */
-typedef struct fuse_dirhandle *fuse_dirh_t;
-typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type,
- ino_t ino);
-
/**
* The file system operations:
*
@@ -86,6 +70,24 @@ typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type,
* is also a snapshot of the relevant wiki pages in the doc/ folder.
*/
struct fuse_operations {
+ /**
+ * Flag indicating that the path need not be calculated for
+ * the following operations:
+ *
+ * read, write, flush, release, fsync, readdir, releasedir,
+ * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
+ *
+ * If this flag is set then the path will not be calculaged even if the
+ * file wasn't unlinked. However the path can still be non-NULL if it
+ * needs to be calculated for some other reason.
+ */
+ unsigned int flag_nopath:1;
+
+ /**
+ * Reserved flags, don't set
+ */
+ unsigned int flag_reserved:31;
+
/** Get file attributes.
*
* Similar to stat(). The 'st_dev' and 'st_blksize' fields are
@@ -104,9 +106,6 @@ struct fuse_operations {
*/
int (*readlink) (const char *, char *, size_t);
- /* Deprecated, use readdir() instead */
- int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t);
-
/** Create a file node
*
* This is called for creation of all non-directory, non-symlink
@@ -115,7 +114,7 @@ struct fuse_operations {
*/
int (*mknod) (const char *, mode_t, dev_t);
- /** Create a directory
+ /** Create a directory
*
* Note that the mode argument may not have the type specification
* bits set, i.e. S_ISDIR(mode) can be false. To obtain the
@@ -147,12 +146,6 @@ struct fuse_operations {
/** Change the size of a file */
int (*truncate) (const char *, off_t);
- /** Change the access and/or modification times of a file
- *
- * Deprecated, use utimens() instead.
- */
- int (*utime) (const char *, struct utimbuf *);
-
/** File open operation
*
* No creation (O_CREAT, O_EXCL) and by default also no
@@ -282,16 +275,12 @@ struct fuse_operations {
/** Read directory
*
- * This supersedes the old getdir() interface. New applications
- * should use this.
- *
* The filesystem may choose between two modes of operation:
*
* 1) The readdir implementation ignores the offset parameter, and
* passes zero to the filler function's offset. The filler
* function will not return '1' (unless an error happens), so the
- * whole directory is read in a single readdir operation. This
- * works just like the old getdir() method.
+ * whole directory is read in a single readdir operation.
*
* 2) The readdir implementation keeps track of the offsets of the
* directory entries. It uses the offset parameter and always
@@ -454,43 +443,6 @@ struct fuse_operations {
int (*bmap) (const char *, size_t blocksize, uint64_t *idx);
/**
- * Flag indicating that the filesystem can accept a NULL path
- * as the first argument for the following operations:
- *
- * read, write, flush, release, fsync, readdir, releasedir,
- * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
- *
- * If this flag is set these operations continue to work on
- * unlinked files even if "-ohard_remove" option was specified.
- */
- unsigned int flag_nullpath_ok:1;
-
- /**
- * Flag indicating that the path need not be calculated for
- * the following operations:
- *
- * read, write, flush, release, fsync, readdir, releasedir,
- * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
- *
- * Closely related to flag_nullpath_ok, but if this flag is
- * set then the path will not be calculaged even if the file
- * wasn't unlinked. However the path can still be non-NULL if
- * it needs to be calculated for some other reason.
- */
- unsigned int flag_nopath:1;
-
- /**
- * Flag indicating that the filesystem accepts special
- * UTIME_NOW and UTIME_OMIT values in its utimens operation.
- */
- unsigned int flag_utime_omit_ok:1;
-
- /**
- * Reserved flags, don't set
- */
- unsigned int flag_reserved:29;
-
- /**
* Ioctl
*
* flags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in
@@ -637,6 +589,8 @@ struct fuse_context {
* @param op the file system operation
* @param user_data user data supplied in the context during the init() method
* @return 0 on success, nonzero on failure
+ *
+ * Example usage, see hello.c
*/
/*
int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
@@ -683,6 +637,8 @@ void fuse_destroy(struct fuse *f);
*
* @param f the FUSE handle
* @return 0 if no error occurred, -1 otherwise
+ *
+ * See also: fuse_loop()
*/
int fuse_loop(struct fuse *f);
@@ -703,8 +659,24 @@ void fuse_exit(struct fuse *f);
* Calling this function requires the pthreads library to be linked to
* the application.
*
+ * Note: using fuse_loop() instead of fuse_loop_mt() means you are running in
+ * single-threaded mode, and that you will not have to worry about reentrancy,
+ * though you will have to worry about recursive lookups. In single-threaded
+ * mode, FUSE will wait for one callback to return before calling another.
+ *
+ * Enabling multiple threads, by using fuse_loop_mt(), will cause FUSE to make
+ * multiple simultaneous calls into the various callback functions given by your
+ * fuse_operations record.
+ *
+ * If you are using multiple threads, you can enjoy all the parallel execution
+ * and interactive response benefits of threads, and you get to enjoy all the
+ * benefits of race conditions and locking bugs, too. Ensure that any code used
+ * in the callback funtion of fuse_operations is also thread-safe.
+ *
* @param f the FUSE handle
* @return 0 if no error occurred, -1 otherwise
+ *
+ * See also: fuse_loop()
*/
int fuse_loop_mt(struct fuse *f);
@@ -746,16 +718,6 @@ int fuse_getgroups(int size, gid_t list[]);
int fuse_interrupted(void);
/**
- * Obsolete, doesn't do anything
- *
- * @return -EINVAL
- */
-int fuse_invalidate(struct fuse *f, const char *path);
-
-/* Deprecated, don't use */
-int fuse_is_lib_option(const char *opt);
-
-/**
* The real main function
*
* Do not call this directly, use fuse_main()
@@ -964,93 +926,9 @@ void fuse_register_module(struct fuse_module *mod);
fuse_register_module(&mod); \
}
-
-/* ----------------------------------------------------------- *
- * Advanced API for event handling, don't worry about this... *
- * ----------------------------------------------------------- */
-
-/* NOTE: the following functions are deprecated, and will be removed
- from the 3.0 API. Use the lowlevel session functions instead */
-
-/** Function type used to process commands */
-typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);
-
-/** This is the part of fuse_main() before the event loop */
-struct fuse *fuse_setup(int argc, char *argv[],
- const struct fuse_operations *op, size_t op_size,
- char **mountpoint, int *multithreaded,
- void *user_data);
-
-/** This is the part of fuse_main() after the event loop */
-void fuse_teardown(struct fuse *fuse, char *mountpoint);
-
-/** Read a single command. If none are read, return NULL */
-struct fuse_cmd *fuse_read_cmd(struct fuse *f);
-
-/** Process a single command */
-void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd);
-
-/** Multi threaded event loop, which calls the custom command
- processor function */
-int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data);
-
-/** Return the exited flag, which indicates if fuse_exit() has been
- called */
-int fuse_exited(struct fuse *f);
-
-/** This function is obsolete and implemented as a no-op */
-void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
-
/** Get session from fuse object */
struct fuse_session *fuse_get_session(struct fuse *f);
-/* ----------------------------------------------------------- *
- * Compatibility stuff *
- * ----------------------------------------------------------- */
-
-#if FUSE_USE_VERSION < 26
-# include "fuse_compat.h"
-# undef fuse_main
-# if FUSE_USE_VERSION == 25
-# define fuse_main(argc, argv, op) \
- fuse_main_real_compat25(argc, argv, op, sizeof(*(op)))
-# define fuse_new fuse_new_compat25
-# define fuse_setup fuse_setup_compat25
-# define fuse_teardown fuse_teardown_compat22
-# define fuse_operations fuse_operations_compat25
-# elif FUSE_USE_VERSION == 22
-# define fuse_main(argc, argv, op) \
- fuse_main_real_compat22(argc, argv, op, sizeof(*(op)))
-# define fuse_new fuse_new_compat22
-# define fuse_setup fuse_setup_compat22
-# define fuse_teardown fuse_teardown_compat22
-# define fuse_operations fuse_operations_compat22
-# define fuse_file_info fuse_file_info_compat
-# elif FUSE_USE_VERSION == 24
-# error Compatibility with high-level API version 24 not supported
-# else
-# 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_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_compat22
-# define __fuse_exited fuse_exited
-# define __fuse_set_getcontext_func fuse_set_getcontext_func
-# else
-# 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_DEBUG FUSE_DEBUG_COMPAT1
-# endif
-# endif
-#endif
-
#ifdef __cplusplus
}
#endif