fuse
Data Structures | Macros | Enumerations | Functions
fuse_common.h File Reference
#include "fuse_opt.h"
#include <stdint.h>
#include <sys/types.h>

Data Structures

struct  fuse_file_info
 
struct  fuse_conn_info
 
struct  fuse_buf
 
struct  fuse_bufvec
 

Macros

#define FUSE_MAJOR_VERSION   3
 
#define FUSE_MINOR_VERSION   0
 
#define FUSE_CAP_ASYNC_READ   (1 << 0)
 
#define FUSE_CAP_POSIX_LOCKS   (1 << 1)
 
#define FUSE_CAP_ATOMIC_O_TRUNC   (1 << 3)
 
#define FUSE_CAP_EXPORT_SUPPORT   (1 << 4)
 
#define FUSE_CAP_DONT_MASK   (1 << 6)
 
#define FUSE_CAP_SPLICE_WRITE   (1 << 7)
 
#define FUSE_CAP_SPLICE_MOVE   (1 << 8)
 
#define FUSE_CAP_SPLICE_READ   (1 << 9)
 
#define FUSE_CAP_FLOCK_LOCKS   (1 << 10)
 
#define FUSE_CAP_IOCTL_DIR   (1 << 11)
 
#define FUSE_CAP_AUTO_INVAL_DATA   (1 << 12)
 
#define FUSE_CAP_READDIRPLUS   (1 << 13)
 
#define FUSE_CAP_READDIRPLUS_AUTO   (1 << 14)
 
#define FUSE_CAP_ASYNC_DIO   (1 << 15)
 
#define FUSE_CAP_WRITEBACK_CACHE   (1 << 16)
 
#define FUSE_CAP_NO_OPEN_SUPPORT   (1 << 17)
 
#define FUSE_IOCTL_COMPAT   (1 << 0)
 

Enumerations

enum  fuse_buf_flags { FUSE_BUF_IS_FD = (1 << 1), FUSE_BUF_FD_SEEK = (1 << 2), FUSE_BUF_FD_RETRY = (1 << 3) }
 
enum  fuse_buf_copy_flags { FUSE_BUF_NO_SPLICE = (1 << 1), FUSE_BUF_FORCE_SPLICE = (1 << 2), FUSE_BUF_SPLICE_MOVE = (1 << 3), FUSE_BUF_SPLICE_NONBLOCK = (1 << 4) }
 

Functions

struct fuse_conn_info_opts * fuse_parse_conn_info_opts (struct fuse_args *args)
 
void fuse_apply_conn_info_opts (struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
 
int fuse_daemonize (int foreground)
 
int fuse_version (void)
 
const char * fuse_pkgversion (void)
 
void fuse_pollhandle_destroy (struct fuse_pollhandle *ph)
 
size_t fuse_buf_size (const struct fuse_bufvec *bufv)
 
ssize_t fuse_buf_copy (struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
 
int fuse_set_signal_handlers (struct fuse_session *se)
 
void fuse_remove_signal_handlers (struct fuse_session *se)
 

Macro Definition Documentation

#define FUSE_CAP_ASYNC_DIO   (1 << 15)

Indicates that the filesystem supports asynchronous direct I/O submission.

If this capability is not requested/available, the kernel will ensure that there is at most one pending read and one pending write request per direct I/O file-handle at any time.

#define FUSE_CAP_ASYNC_READ   (1 << 0)

Indicates that the filesystem supports asynchronous read requests.

If this capability is not requested/available, the kernel will ensure that there is at most one pending read request per file-handle at any time, and will attempt to order read requests by increasing offset.

#define FUSE_CAP_ATOMIC_O_TRUNC   (1 << 3)

Indicates that the filesystem supports the O_TRUNC open flag

#define FUSE_CAP_AUTO_INVAL_DATA   (1 << 12)

Indicates that the filesystem supports automatic invalidation of cached pages.

#define FUSE_CAP_DONT_MASK   (1 << 6)

Indicates that the kernel should not apply the umask to the file mode on create operations.

#define FUSE_CAP_EXPORT_SUPPORT   (1 << 4)

Indicates that the filesystem supports lookups of "." and "..".

#define FUSE_CAP_FLOCK_LOCKS   (1 << 10)

FIXME: This capability is not documented. Please get in touch if you know what it does!

#define FUSE_CAP_IOCTL_DIR   (1 << 11)

Indicates that the filesystem supports ioctl's on directories.

#define FUSE_CAP_NO_OPEN_SUPPORT   (1 << 17)

Indicates that the filesystem supports support zero-message opens.

#define FUSE_CAP_POSIX_LOCKS   (1 << 1)

Indicates that the filesystem supports "remote" locking.

#define FUSE_CAP_READDIRPLUS   (1 << 13)

Indicates that the filesystem supports readdirplus

#define FUSE_CAP_READDIRPLUS_AUTO   (1 << 14)

Indicates that the filesystem supports adaptive readdirplus

#define FUSE_CAP_SPLICE_MOVE   (1 << 8)

Indicates that libfuse should try to move pages instead of copying when writing to / reading from the fuse device.

#define FUSE_CAP_SPLICE_READ   (1 << 9)

Indicates that libfuse should try to use splice() when reading from the fuse device.

#define FUSE_CAP_SPLICE_WRITE   (1 << 7)

Indicates that libfuse should try to use splice() when writing to the fuse device

#define FUSE_CAP_WRITEBACK_CACHE   (1 << 16)

Indicates that writeback caching should be enabled. This means that individual write request may be buffered and merged in the kernel before they are send to the filesystem.

#define FUSE_IOCTL_COMPAT   (1 << 0)

Ioctl flags

FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed FUSE_IOCTL_RETRY: retry with new iovecs FUSE_IOCTL_DIR: is a directory

FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs

#define FUSE_MAJOR_VERSION   3

Major version of FUSE library interface

#define FUSE_MINOR_VERSION   0

Minor version of FUSE library interface

Enumeration Type Documentation

Buffer copy flags

Enumerator
FUSE_BUF_NO_SPLICE 

Don't use splice(2)

Always fall back to using read and write instead of splice(2) to copy data from one file descriptor to another.

If this flag is not set, then only fall back if splice is unavailable.

FUSE_BUF_FORCE_SPLICE 

Force splice

Always use splice(2) to copy data from one file descriptor to another. If splice is not available, return -EINVAL.

FUSE_BUF_SPLICE_MOVE 

Try to move data with splice.

If splice is used, try to move pages from the source to the destination instead of copying. See documentation of SPLICE_F_MOVE in splice(2) man page.

FUSE_BUF_SPLICE_NONBLOCK 

Don't block on the pipe when copying data with splice

Makes the operations on the pipe non-blocking (if the pipe is full or empty). See SPLICE_F_NONBLOCK in the splice(2) man page.

Buffer flags

Enumerator
FUSE_BUF_IS_FD 

Buffer contains a file descriptor

If this flag is set, the .fd field is valid, otherwise the .mem fields is valid.

FUSE_BUF_FD_SEEK 

Seek on the file descriptor

If this flag is set then the .pos field is valid and is used to seek to the given offset before performing operation on file descriptor.

FUSE_BUF_FD_RETRY 

Retry operation on file descriptor

If this flag is set then retry operation on file descriptor until .size bytes have been copied or an error or EOF is detected.

Function Documentation

void fuse_apply_conn_info_opts ( struct fuse_conn_info_opts *  opts,
struct fuse_conn_info conn 
)

This function applies the (parsed) parameters in opts to the conn pointer. It may modify the following fields: wants, max_write, max_readahead, congestion_threshold, max_background, time_gran. A field is only set (or unset) if the corresponding option has been explicitly set.

ssize_t fuse_buf_copy ( struct fuse_bufvec dst,
struct fuse_bufvec src,
enum fuse_buf_copy_flags  flags 
)

Copy data from one buffer vector to another

Parameters
dstdestination buffer vector
srcsource buffer vector
flagsflags controlling the copy
Returns
actual number of bytes copied or -errno on error
size_t fuse_buf_size ( const struct fuse_bufvec bufv)

Get total size of data in a fuse buffer vector

Parameters
bufvbuffer vector
Returns
size of data
int fuse_daemonize ( int  foreground)

Go into the background

Parameters
foregroundif true, stay in the foreground
Returns
0 on success, -1 on failure
struct fuse_conn_info_opts* fuse_parse_conn_info_opts ( struct fuse_args args)

This function parses several command-line options that can be used to override elements of struct fuse_conn_info. The pointer returned by this function should be passed to the fuse_apply_conn_info_opts() method by the file system's init() handler.

Before using this function, think twice if you really want these parameters to be adjustable from the command line. In most cases, they should be determined by the file system internally.

The following options are recognized:

-o max_write=N sets conn->max_write -o max_readahead=N sets conn->max_readahead -o max_background=N sets conn->max_background -o congestion_threshold=N sets conn->congestion_threshold -o async_read sets FUSE_CAP_ASYNC_READ in conn->want -o sync_read unsets FUSE_CAP_ASYNC_READ in conn->want -o atomic_o_trunc sets FUSE_CAP_ATOMIC_O_TRUNC in conn->want -o no_remote_lock Equivalent to -o no_remote_flock,no_remote_posix_lock -o no_remote_flock Unsets FUSE_CAP_FLOCK_LOCKS in conn->want -o no_remote_posix_lock Unsets FUSE_CAP_POSIX_LOCKS in conn->want -o [no_]splice_write (un-)sets FUSE_CAP_SPLICE_WRITE in conn->want -o [no_]splice_move (un-)sets FUSE_CAP_SPLICE_MOVE in conn->want -o [no_]splice_read (un-)sets FUSE_CAP_SPLICE_READ in conn->want -o [no_]auto_inval_data (un-)sets FUSE_CAP_AUTO_INVAL_DATA in conn->want -o readdirplus=no unsets FUSE_CAP_READDIRPLUS in conn->want -o readdirplus=yes sets FUSE_CAP_READDIRPLUS and unsets FUSE_CAP_READDIRPLUS_AUTO in conn->want -o readdirplus=auto sets FUSE_CAP_READDIRPLUS and FUSE_CAP_READDIRPLUS_AUTO in conn->want -o [no_]async_dio (un-)sets FUSE_CAP_ASYNC_DIO in conn->want -o [no_]writeback_cache (un-)sets FUSE_CAP_WRITEBACK_CACHE in conn->want -o time_gran=N sets conn->time_gran

Known options will be removed from args, unknown options will be passed through unchanged.

Parameters
argsargument vector (input+output)
Returns
parsed options
const char* fuse_pkgversion ( void  )

Get the full package version string of the library

Returns
the package version
void fuse_pollhandle_destroy ( struct fuse_pollhandle *  ph)

Destroy poll handle

Parameters
phthe poll handle
void fuse_remove_signal_handlers ( struct fuse_session *  se)

Restore default signal handlers

Resets global session. After this fuse_set_signal_handlers() may be called again.

Parameters
sethe same session as given in fuse_set_signal_handlers()

See also: fuse_set_signal_handlers()

int fuse_set_signal_handlers ( struct fuse_session *  se)

Exit session on HUP, TERM and INT signals and ignore PIPE signal

Stores session in a global variable. May only be called once per process until fuse_remove_signal_handlers() is called.

Once either of the POSIX signals arrives, the exit_handler() in fuse_signals.c is called:

static void exit_handler(int sig)
{
(void) sig;
if (fuse_instance)
fuse_session_exit(fuse_instance);
}
Parameters
sethe session to exit
Returns
0 on success, -1 on failure

See also: fuse_remove_signal_handlers()

int fuse_version ( void  )

Get the version of the library

Returns
the version