"Fossies" - the Fresh Open Source Software Archive

Member "fuse-3.2.3/include/fuse_common.h" (11 May 2018, 23133 Bytes) of package /linux/misc/fuse-3.2.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "fuse_common.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3.2.1_vs_3.2.2.

    1 /*  FUSE: Filesystem in Userspace
    2   Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
    3 
    4   This program can be distributed under the terms of the GNU LGPLv2.
    5   See the file COPYING.LIB.
    6 */
    7 
    8 /** @file */
    9 
   10 #if !defined(FUSE_H_) && !defined(FUSE_LOWLEVEL_H_)
   11 #error "Never include <fuse_common.h> directly; use <fuse.h> or <fuse_lowlevel.h> instead."
   12 #endif
   13 
   14 #ifndef FUSE_COMMON_H_
   15 #define FUSE_COMMON_H_
   16 
   17 #include "fuse_opt.h"
   18 #include <stdint.h>
   19 #include <sys/types.h>
   20 
   21 /** Major version of FUSE library interface */
   22 #define FUSE_MAJOR_VERSION 3
   23 
   24 /** Minor version of FUSE library interface */
   25 #define FUSE_MINOR_VERSION 2
   26 
   27 #define FUSE_MAKE_VERSION(maj, min)  ((maj) * 10 + (min))
   28 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
   29 
   30 #ifdef __cplusplus
   31 extern "C" {
   32 #endif
   33 
   34 /**
   35  * Information about open files
   36  */
   37 struct fuse_file_info {
   38     /** Open flags.  Available in open() and release() */
   39     int flags;
   40 
   41     /** In case of a write operation indicates if this was caused by a
   42         writepage */
   43     unsigned int writepage : 1;
   44 
   45     /** Can be filled in by open, to use direct I/O on this file. */
   46     unsigned int direct_io : 1;
   47 
   48     /** Can be filled in by open, to indicate that currently
   49         cached file data (that the filesystem provided the last
   50         time the file was open) need not be invalidated. */
   51     unsigned int keep_cache : 1;
   52 
   53     /** Indicates a flush operation.  Set in flush operation, also
   54         maybe set in highlevel lock operation and lowlevel release
   55         operation. */
   56     unsigned int flush : 1;
   57 
   58     /** Can be filled in by open, to indicate that the file is not
   59         seekable. */
   60     unsigned int nonseekable : 1;
   61 
   62     /* Indicates that flock locks for this file should be
   63        released.  If set, lock_owner shall contain a valid value.
   64        May only be set in ->release(). */
   65     unsigned int flock_release : 1;
   66 
   67     /** Padding.  Do not use*/
   68     unsigned int padding : 27;
   69 
   70     /** File handle.  May be filled in by filesystem in open().
   71         Available in all other file operations */
   72     uint64_t fh;
   73 
   74     /** Lock owner id.  Available in locking operations and flush */
   75     uint64_t lock_owner;
   76 
   77     /** Requested poll events.  Available in ->poll.  Only set on kernels
   78         which support it.  If unsupported, this field is set to zero. */
   79     uint32_t poll_events;
   80 };
   81 
   82 /**
   83  * Configuration parameters passed to fuse_session_loop_mt() and
   84  * fuse_loop_mt().
   85  */
   86 struct fuse_loop_config {
   87     /**
   88      * whether to use separate device fds for each thread
   89      * (may increase performance)
   90      */
   91     int clone_fd;
   92 
   93     /**
   94      * The maximum number of available worker threads before they
   95      * start to get deleted when they become idle. If not
   96      * specified, the default is 10.
   97      *
   98      * Adjusting this has performance implications; a very small number
   99      * of threads in the pool will cause a lot of thread creation and
  100      * deletion overhead and performance may suffer. When set to 0, a new
  101      * thread will be created to service every operation.
  102      */
  103     unsigned int max_idle_threads;
  104 };
  105 
  106 /**************************************************************************
  107  * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
  108  **************************************************************************/
  109 
  110 /**
  111  * Indicates that the filesystem supports asynchronous read requests.
  112  *
  113  * If this capability is not requested/available, the kernel will
  114  * ensure that there is at most one pending read request per
  115  * file-handle at any time, and will attempt to order read requests by
  116  * increasing offset.
  117  *
  118  * This feature is enabled by default when supported by the kernel.
  119  */
  120 #define FUSE_CAP_ASYNC_READ     (1 << 0)
  121 
  122 /**
  123  * Indicates that the filesystem supports "remote" locking.
  124  *
  125  * This feature is enabled by default when supported by the kernel,
  126  * and if getlk() and setlk() handlers are implemented.
  127  */
  128 #define FUSE_CAP_POSIX_LOCKS        (1 << 1)
  129 
  130 /**
  131  * Indicates that the filesystem supports the O_TRUNC open flag.  If
  132  * disabled, and an application specifies O_TRUNC, fuse first calls
  133  * truncate() and then open() with O_TRUNC filtered out.
  134  *
  135  * This feature is enabled by default when supported by the kernel.
  136  */
  137 #define FUSE_CAP_ATOMIC_O_TRUNC     (1 << 3)
  138 
  139 /**
  140  * Indicates that the filesystem supports lookups of "." and "..".
  141  *
  142  * This feature is disabled by default.
  143  */
  144 #define FUSE_CAP_EXPORT_SUPPORT     (1 << 4)
  145 
  146 /**
  147  * Indicates that the kernel should not apply the umask to the
  148  * file mode on create operations.
  149  *
  150  * This feature is disabled by default.
  151  */
  152 #define FUSE_CAP_DONT_MASK      (1 << 6)
  153 
  154 /**
  155  * Indicates that libfuse should try to use splice() when writing to
  156  * the fuse device. This may improve performance.
  157  *
  158  * This feature is disabled by default.
  159  */
  160 #define FUSE_CAP_SPLICE_WRITE       (1 << 7)
  161 
  162 /**
  163  * Indicates that libfuse should try to move pages instead of copying when
  164  * writing to / reading from the fuse device. This may improve performance.
  165  *
  166  * This feature is disabled by default.
  167  */
  168 #define FUSE_CAP_SPLICE_MOVE        (1 << 8)
  169 
  170 /**
  171  * Indicates that libfuse should try to use splice() when reading from
  172  * the fuse device. This may improve performance.
  173  *
  174  * This feature is enabled by default when supported by the kernel and
  175  * if the filesystem implements a write_buf() handler.
  176  */
  177 #define FUSE_CAP_SPLICE_READ        (1 << 9)
  178 
  179 /**
  180  * If set, the calls to flock(2) will be emulated using POSIX locks and must
  181  * then be handled by the filesystem's setlock() handler.
  182  *
  183  * If not set, flock(2) calls will be handled by the FUSE kernel module
  184  * internally (so any access that does not go through the kernel cannot be taken
  185  * into account).
  186  *
  187  * This feature is enabled by default when supported by the kernel and
  188  * if the filesystem implements a flock() handler.
  189  */
  190 #define FUSE_CAP_FLOCK_LOCKS        (1 << 10)
  191 
  192 /**
  193  * Indicates that the filesystem supports ioctl's on directories.
  194  *
  195  * This feature is enabled by default when supported by the kernel.
  196  */
  197 #define FUSE_CAP_IOCTL_DIR      (1 << 11)
  198 
  199 /**
  200  * Traditionally, while a file is open the FUSE kernel module only
  201  * asks the filesystem for an update of the file's attributes when a
  202  * client attempts to read beyond EOF. This is unsuitable for
  203  * e.g. network filesystems, where the file contents may change
  204  * without the kernel knowing about it.
  205  *
  206  * If this flag is set, FUSE will check the validity of the attributes
  207  * on every read. If the attributes are no longer valid (i.e., if the
  208  * *attr_timeout* passed to fuse_reply_attr() or set in `struct
  209  * fuse_entry_param` has passed), it will first issue a `getattr`
  210  * request. If the new mtime differs from the previous value, any
  211  * cached file *contents* will be invalidated as well.
  212  *
  213  * This flag should always be set when available. If all file changes
  214  * go through the kernel, *attr_timeout* should be set to a very large
  215  * number to avoid unnecessary getattr() calls.
  216  *
  217  * This feature is enabled by default when supported by the kernel.
  218  */
  219 #define FUSE_CAP_AUTO_INVAL_DATA    (1 << 12)
  220 
  221 /**
  222  * Indicates that the filesystem supports readdirplus
  223  *
  224  * This feature is enabled by default when supported by the kernel and if the
  225  * filesystem implements a readdirplus() handler.
  226  */
  227 #define FUSE_CAP_READDIRPLUS        (1 << 13)
  228 
  229 /**
  230  * Indicates that the filesystem supports adaptive readdirplus
  231  *
  232  * This feature is enabled by default when supported by the kernel and if the
  233  * filesystem implements a readdirplus() handler.
  234  */
  235 #define FUSE_CAP_READDIRPLUS_AUTO   (1 << 14)
  236 
  237 /**
  238  * Indicates that the filesystem supports asynchronous direct I/O submission.
  239  *
  240  * If this capability is not requested/available, the kernel will ensure that
  241  * there is at most one pending read and one pending write request per direct
  242  * I/O file-handle at any time.
  243  *
  244  * This feature is enabled by default when supported by the kernel.
  245  */
  246 #define FUSE_CAP_ASYNC_DIO      (1 << 15)
  247 
  248 /**
  249  * Indicates that writeback caching should be enabled. This means that
  250  * individual write request may be buffered and merged in the kernel
  251  * before they are send to the filesystem.
  252  *
  253  * This feature is disabled by default.
  254  */
  255 #define FUSE_CAP_WRITEBACK_CACHE    (1 << 16)
  256 
  257 /**
  258  * Indicates support for zero-message opens. If this flag is set in
  259  * the `capable` field of the `fuse_conn_info` structure, then the
  260  * filesystem may return `ENOSYS` from the open() handler to indicate
  261  * success. Further attempts to open files will be handled in the
  262  * kernel. (If this flag is not set, returning ENOSYS will be treated
  263  * as an error and signaled to the caller).
  264  *
  265  * Setting (or unsetting) this flag in the `want` field has *no
  266  * effect*.
  267  */
  268 #define FUSE_CAP_NO_OPEN_SUPPORT    (1 << 17)
  269 
  270 /**
  271  * Indicates support for parallel directory operations. If this flag
  272  * is unset, the FUSE kernel module will ensure that lookup() and
  273  * readdir() requests are never issued concurrently for the same
  274  * directory.
  275  *
  276  * This feature is enabled by default when supported by the kernel.
  277  */
  278 #define FUSE_CAP_PARALLEL_DIROPS        (1 << 18)
  279 
  280 /**
  281  * Indicates support for POSIX ACLs.
  282  *
  283  * If this feature is enabled, the kernel will cache and have
  284  * responsibility for enforcing ACLs. ACL will be stored as xattrs and
  285  * passed to userspace, which is responsible for updating the ACLs in
  286  * the filesystem, keeping the file mode in sync with the ACL, and
  287  * ensuring inheritance of default ACLs when new filesystem nodes are
  288  * created. Note that this requires that the file system is able to
  289  * parse and interpret the xattr representation of ACLs.
  290  *
  291  * Enabling this feature implicitly turns on the
  292  * ``default_permissions`` mount option (even if it was not passed to
  293  * mount(2)).
  294  *
  295  * This feature is disabled by default.
  296  */
  297 #define FUSE_CAP_POSIX_ACL              (1 << 19)
  298 
  299 /**
  300  * Indicates that the filesystem is responsible for unsetting
  301  * setuid and setgid bits when a file is written, truncated, or
  302  * its owner is changed.
  303  *
  304  * This feature is enabled by default when supported by the kernel.
  305  */
  306 #define FUSE_CAP_HANDLE_KILLPRIV         (1 << 20)
  307 
  308 /**
  309  * Ioctl flags
  310  *
  311  * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
  312  * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
  313  * FUSE_IOCTL_RETRY: retry with new iovecs
  314  * FUSE_IOCTL_DIR: is a directory
  315  *
  316  * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
  317  */
  318 #define FUSE_IOCTL_COMPAT   (1 << 0)
  319 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
  320 #define FUSE_IOCTL_RETRY    (1 << 2)
  321 #define FUSE_IOCTL_DIR      (1 << 4)
  322 
  323 #define FUSE_IOCTL_MAX_IOV  256
  324 
  325 /**
  326  * Connection information, passed to the ->init() method
  327  *
  328  * Some of the elements are read-write, these can be changed to
  329  * indicate the value requested by the filesystem.  The requested
  330  * value must usually be smaller than the indicated value.
  331  */
  332 struct fuse_conn_info {
  333     /**
  334      * Major version of the protocol (read-only)
  335      */
  336     unsigned proto_major;
  337 
  338     /**
  339      * Minor version of the protocol (read-only)
  340      */
  341     unsigned proto_minor;
  342 
  343     /**
  344      * Maximum size of the write buffer
  345      */
  346     unsigned max_write;
  347 
  348     /**
  349      * Maximum size of read requests. A value of zero indicates no
  350      * limit. However, even if the filesystem does not specify a
  351      * limit, the maximum size of read requests will still be
  352      * limited by the kernel.
  353      *
  354      * NOTE: For the time being, the maximum size of read requests
  355      * must be set both here *and* passed to fuse_session_new()
  356      * using the ``-o max_read=<n>`` mount option. At some point
  357      * in the future, specifying the mount option will no longer
  358      * be necessary.
  359      */
  360     unsigned max_read;
  361 
  362     /**
  363      * Maximum readahead
  364      */
  365     unsigned max_readahead;
  366 
  367     /**
  368      * Capability flags that the kernel supports (read-only)
  369      */
  370     unsigned capable;
  371 
  372     /**
  373      * Capability flags that the filesystem wants to enable.
  374      *
  375      * libfuse attempts to initialize this field with
  376      * reasonable default values before calling the init() handler.
  377      */
  378     unsigned want;
  379 
  380     /**
  381      * Maximum number of pending "background" requests. A
  382      * background request is any type of request for which the
  383      * total number is not limited by other means. As of kernel
  384      * 4.8, only two types of requests fall into this category:
  385      *
  386      *   1. Read-ahead requests
  387      *   2. Asynchronous direct I/O requests
  388      *
  389      * Read-ahead requests are generated (if max_readahead is
  390      * non-zero) by the kernel to preemptively fill its caches
  391      * when it anticipates that userspace will soon read more
  392      * data.
  393      *
  394      * Asynchronous direct I/O requests are generated if
  395      * FUSE_CAP_ASYNC_DIO is enabled and userspace submits a large
  396      * direct I/O request. In this case the kernel will internally
  397      * split it up into multiple smaller requests and submit them
  398      * to the filesystem concurrently.
  399      *
  400      * Note that the following requests are *not* background
  401      * requests: writeback requests (limited by the kernel's
  402      * flusher algorithm), regular (i.e., synchronous and
  403      * buffered) userspace read/write requests (limited to one per
  404      * thread), asynchronous read requests (Linux's io_submit(2)
  405      * call actually blocks, so these are also limited to one per
  406      * thread).
  407      */
  408     unsigned max_background;
  409 
  410     /**
  411      * Kernel congestion threshold parameter. If the number of pending
  412      * background requests exceeds this number, the FUSE kernel module will
  413      * mark the filesystem as "congested". This instructs the kernel to
  414      * expect that queued requests will take some time to complete, and to
  415      * adjust its algorithms accordingly (e.g. by putting a waiting thread
  416      * to sleep instead of using a busy-loop).
  417      */
  418     unsigned congestion_threshold;
  419 
  420     /**
  421      * When FUSE_CAP_WRITEBACK_CACHE is enabled, the kernel is responsible
  422      * for updating mtime and ctime when write requests are received. The
  423      * updated values are passed to the filesystem with setattr() requests.
  424      * However, if the filesystem does not support the full resolution of
  425      * the kernel timestamps (nanoseconds), the mtime and ctime values used
  426      * by kernel and filesystem will differ (and result in an apparent
  427      * change of times after a cache flush).
  428      *
  429      * To prevent this problem, this variable can be used to inform the
  430      * kernel about the timestamp granularity supported by the file-system.
  431      * The value should be power of 10.  The default is 1, i.e. full
  432      * nano-second resolution. Filesystems supporting only second resolution
  433      * should set this to 1000000000.
  434      */
  435     unsigned time_gran;
  436 
  437     /**
  438      * For future use.
  439      */
  440     unsigned reserved[22];
  441 };
  442 
  443 struct fuse_session;
  444 struct fuse_pollhandle;
  445 struct fuse_conn_info_opts;
  446 
  447 /**
  448  * This function parses several command-line options that can be used
  449  * to override elements of struct fuse_conn_info. The pointer returned
  450  * by this function should be passed to the
  451  * fuse_apply_conn_info_opts() method by the file system's init()
  452  * handler.
  453  *
  454  * Before using this function, think twice if you really want these
  455  * parameters to be adjustable from the command line. In most cases,
  456  * they should be determined by the file system internally.
  457  *
  458  * The following options are recognized:
  459  *
  460  *   -o max_write=N         sets conn->max_write
  461  *   -o max_readahead=N     sets conn->max_readahead
  462  *   -o max_background=N    sets conn->max_background
  463  *   -o congestion_threshold=N  sets conn->congestion_threshold
  464  *   -o async_read          sets FUSE_CAP_ASYNC_READ in conn->want
  465  *   -o sync_read           unsets FUSE_CAP_ASYNC_READ in conn->want
  466  *   -o atomic_o_trunc      sets FUSE_CAP_ATOMIC_O_TRUNC in conn->want
  467  *   -o no_remote_lock      Equivalent to -o no_remote_flock,no_remote_posix_lock
  468  *   -o no_remote_flock     Unsets FUSE_CAP_FLOCK_LOCKS in conn->want
  469  *   -o no_remote_posix_lock  Unsets FUSE_CAP_POSIX_LOCKS in conn->want
  470  *   -o [no_]splice_write     (un-)sets FUSE_CAP_SPLICE_WRITE in conn->want
  471  *   -o [no_]splice_move      (un-)sets FUSE_CAP_SPLICE_MOVE in conn->want
  472  *   -o [no_]splice_read      (un-)sets FUSE_CAP_SPLICE_READ in conn->want
  473  *   -o [no_]auto_inval_data  (un-)sets FUSE_CAP_AUTO_INVAL_DATA in conn->want
  474  *   -o readdirplus=no        unsets FUSE_CAP_READDIRPLUS in conn->want
  475  *   -o readdirplus=yes       sets FUSE_CAP_READDIRPLUS and unsets
  476  *                            FUSE_CAP_READDIRPLUS_AUTO in conn->want
  477  *   -o readdirplus=auto      sets FUSE_CAP_READDIRPLUS and
  478  *                            FUSE_CAP_READDIRPLUS_AUTO in conn->want
  479  *   -o [no_]async_dio        (un-)sets FUSE_CAP_ASYNC_DIO in conn->want
  480  *   -o [no_]writeback_cache  (un-)sets FUSE_CAP_WRITEBACK_CACHE in conn->want
  481  *   -o time_gran=N           sets conn->time_gran
  482  *
  483  * Known options will be removed from *args*, unknown options will be
  484  * passed through unchanged.
  485  *
  486  * @param args argument vector (input+output)
  487  * @return parsed options
  488  **/
  489 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
  490 
  491 /**
  492  * This function applies the (parsed) parameters in *opts* to the
  493  * *conn* pointer. It may modify the following fields: wants,
  494  * max_write, max_readahead, congestion_threshold, max_background,
  495  * time_gran. A field is only set (or unset) if the corresponding
  496  * option has been explicitly set.
  497  */
  498 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
  499               struct fuse_conn_info *conn);
  500 
  501 /**
  502  * Go into the background
  503  *
  504  * @param foreground if true, stay in the foreground
  505  * @return 0 on success, -1 on failure
  506  */
  507 int fuse_daemonize(int foreground);
  508 
  509 /**
  510  * Get the version of the library
  511  *
  512  * @return the version
  513  */
  514 int fuse_version(void);
  515 
  516 /**
  517  * Get the full package version string of the library
  518  *
  519  * @return the package version
  520  */
  521 const char *fuse_pkgversion(void);
  522 
  523 /**
  524  * Destroy poll handle
  525  *
  526  * @param ph the poll handle
  527  */
  528 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
  529 
  530 /* ----------------------------------------------------------- *
  531  * Data buffer                             *
  532  * ----------------------------------------------------------- */
  533 
  534 /**
  535  * Buffer flags
  536  */
  537 enum fuse_buf_flags {
  538     /**
  539      * Buffer contains a file descriptor
  540      *
  541      * If this flag is set, the .fd field is valid, otherwise the
  542      * .mem fields is valid.
  543      */
  544     FUSE_BUF_IS_FD      = (1 << 1),
  545 
  546     /**
  547      * Seek on the file descriptor
  548      *
  549      * If this flag is set then the .pos field is valid and is
  550      * used to seek to the given offset before performing
  551      * operation on file descriptor.
  552      */
  553     FUSE_BUF_FD_SEEK    = (1 << 2),
  554 
  555     /**
  556      * Retry operation on file descriptor
  557      *
  558      * If this flag is set then retry operation on file descriptor
  559      * until .size bytes have been copied or an error or EOF is
  560      * detected.
  561      */
  562     FUSE_BUF_FD_RETRY   = (1 << 3),
  563 };
  564 
  565 /**
  566  * Buffer copy flags
  567  */
  568 enum fuse_buf_copy_flags {
  569     /**
  570      * Don't use splice(2)
  571      *
  572      * Always fall back to using read and write instead of
  573      * splice(2) to copy data from one file descriptor to another.
  574      *
  575      * If this flag is not set, then only fall back if splice is
  576      * unavailable.
  577      */
  578     FUSE_BUF_NO_SPLICE  = (1 << 1),
  579 
  580     /**
  581      * Force splice
  582      *
  583      * Always use splice(2) to copy data from one file descriptor
  584      * to another.  If splice is not available, return -EINVAL.
  585      */
  586     FUSE_BUF_FORCE_SPLICE   = (1 << 2),
  587 
  588     /**
  589      * Try to move data with splice.
  590      *
  591      * If splice is used, try to move pages from the source to the
  592      * destination instead of copying.  See documentation of
  593      * SPLICE_F_MOVE in splice(2) man page.
  594      */
  595     FUSE_BUF_SPLICE_MOVE    = (1 << 3),
  596 
  597     /**
  598      * Don't block on the pipe when copying data with splice
  599      *
  600      * Makes the operations on the pipe non-blocking (if the pipe
  601      * is full or empty).  See SPLICE_F_NONBLOCK in the splice(2)
  602      * man page.
  603      */
  604     FUSE_BUF_SPLICE_NONBLOCK= (1 << 4),
  605 };
  606 
  607 /**
  608  * Single data buffer
  609  *
  610  * Generic data buffer for I/O, extended attributes, etc...  Data may
  611  * be supplied as a memory pointer or as a file descriptor
  612  */
  613 struct fuse_buf {
  614     /**
  615      * Size of data in bytes
  616      */
  617     size_t size;
  618 
  619     /**
  620      * Buffer flags
  621      */
  622     enum fuse_buf_flags flags;
  623 
  624     /**
  625      * Memory pointer
  626      *
  627      * Used unless FUSE_BUF_IS_FD flag is set.
  628      */
  629     void *mem;
  630 
  631     /**
  632      * File descriptor
  633      *
  634      * Used if FUSE_BUF_IS_FD flag is set.
  635      */
  636     int fd;
  637 
  638     /**
  639      * File position
  640      *
  641      * Used if FUSE_BUF_FD_SEEK flag is set.
  642      */
  643     off_t pos;
  644 };
  645 
  646 /**
  647  * Data buffer vector
  648  *
  649  * An array of data buffers, each containing a memory pointer or a
  650  * file descriptor.
  651  *
  652  * Allocate dynamically to add more than one buffer.
  653  */
  654 struct fuse_bufvec {
  655     /**
  656      * Number of buffers in the array
  657      */
  658     size_t count;
  659 
  660     /**
  661      * Index of current buffer within the array
  662      */
  663     size_t idx;
  664 
  665     /**
  666      * Current offset within the current buffer
  667      */
  668     size_t off;
  669 
  670     /**
  671      * Array of buffers
  672      */
  673     struct fuse_buf buf[1];
  674 };
  675 
  676 /* Initialize bufvec with a single buffer of given size */
  677 #define FUSE_BUFVEC_INIT(size__)                \
  678     ((struct fuse_bufvec) {                 \
  679         /* .count= */ 1,                \
  680         /* .idx =  */ 0,                \
  681         /* .off =  */ 0,                \
  682         /* .buf =  */ { /* [0] = */ {           \
  683             /* .size =  */ (size__),        \
  684             /* .flags = */ (enum fuse_buf_flags) 0, \
  685             /* .mem =   */ NULL,            \
  686             /* .fd =    */ -1,          \
  687             /* .pos =   */ 0,           \
  688         } }                     \
  689     } )
  690 
  691 /**
  692  * Get total size of data in a fuse buffer vector
  693  *
  694  * @param bufv buffer vector
  695  * @return size of data
  696  */
  697 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
  698 
  699 /**
  700  * Copy data from one buffer vector to another
  701  *
  702  * @param dst destination buffer vector
  703  * @param src source buffer vector
  704  * @param flags flags controlling the copy
  705  * @return actual number of bytes copied or -errno on error
  706  */
  707 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
  708               enum fuse_buf_copy_flags flags);
  709 
  710 /* ----------------------------------------------------------- *
  711  * Signal handling                         *
  712  * ----------------------------------------------------------- */
  713 
  714 /**
  715  * Exit session on HUP, TERM and INT signals and ignore PIPE signal
  716  *
  717  * Stores session in a global variable.  May only be called once per
  718  * process until fuse_remove_signal_handlers() is called.
  719  *
  720  * Once either of the POSIX signals arrives, the signal handler calls
  721  * fuse_session_exit().
  722  *
  723  * @param se the session to exit
  724  * @return 0 on success, -1 on failure
  725  *
  726  * See also:
  727  * fuse_remove_signal_handlers()
  728  */
  729 int fuse_set_signal_handlers(struct fuse_session *se);
  730 
  731 /**
  732  * Restore default signal handlers
  733  *
  734  * Resets global session.  After this fuse_set_signal_handlers() may
  735  * be called again.
  736  *
  737  * @param se the same session as given in fuse_set_signal_handlers()
  738  *
  739  * See also:
  740  * fuse_set_signal_handlers()
  741  */
  742 void fuse_remove_signal_handlers(struct fuse_session *se);
  743 
  744 /* ----------------------------------------------------------- *
  745  * Compatibility stuff                         *
  746  * ----------------------------------------------------------- */
  747 
  748 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
  749 #  error only API version 30 or greater is supported
  750 #endif
  751 
  752 #ifdef __cplusplus
  753 }
  754 #endif
  755 
  756 
  757 /*
  758  * This interface uses 64 bit off_t.
  759  *
  760  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
  761  */
  762 
  763 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
  764 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
  765 #else
  766 struct _fuse_off_t_must_be_64bit_dummy_struct \
  767     { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
  768 #endif
  769 
  770 #endif /* FUSE_COMMON_H_ */