fuse_common.h
Go to the documentation of this file.
/* FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU LGPLv2.
See the file COPYING.LIB.
*/
#if !defined(FUSE_H_) && !defined(FUSE_LOWLEVEL_H_)
#error "Never include <fuse_common.h> directly; use <fuse.h> or <fuse_lowlevel.h> instead."
#endif
#ifndef FUSE_COMMON_H_
#define FUSE_COMMON_H_
#include "fuse_opt.h"
#include <stdint.h>
#include <sys/types.h>
#define FUSE_MAJOR_VERSION 3
#define FUSE_MINOR_VERSION 2
#define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (min))
#define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
#ifdef __cplusplus
extern "C" {
#endif
struct fuse_file_info {
int flags;
unsigned int writepage : 1;
unsigned int direct_io : 1;
unsigned int keep_cache : 1;
unsigned int flush : 1;
unsigned int nonseekable : 1;
/* Indicates that flock locks for this file should be
released. If set, lock_owner shall contain a valid value.
May only be set in ->release(). */
unsigned int flock_release : 1;
unsigned int padding : 27;
uint64_t fh;
uint64_t lock_owner;
uint32_t poll_events;
};
struct fuse_loop_config {
int clone_fd;
unsigned int max_idle_threads;
};
/**************************************************************************
* Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
**************************************************************************/
#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_CAP_PARALLEL_DIROPS (1 << 18)
#define FUSE_CAP_POSIX_ACL (1 << 19)
#define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
#define FUSE_IOCTL_COMPAT (1 << 0)
#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
#define FUSE_IOCTL_RETRY (1 << 2)
#define FUSE_IOCTL_DIR (1 << 4)
#define FUSE_IOCTL_MAX_IOV 256
struct fuse_conn_info {
unsigned proto_major;
unsigned proto_minor;
unsigned max_write;
unsigned max_read;
unsigned max_readahead;
unsigned capable;
unsigned want;
unsigned max_background;
unsigned congestion_threshold;
unsigned time_gran;
unsigned reserved[22];
};
struct fuse_session;
struct fuse_pollhandle;
struct fuse_conn_info_opts;
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);
/* ----------------------------------------------------------- *
* Data buffer *
* ----------------------------------------------------------- */
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),
};
struct fuse_buf {
size_t size;
enum fuse_buf_flags flags;
void *mem;
int fd;
off_t pos;
};
struct fuse_bufvec {
size_t count;
size_t idx;
size_t off;
struct fuse_buf buf[1];
};
/* Initialize bufvec with a single buffer of given size */
#define FUSE_BUFVEC_INIT(size__) \
((struct fuse_bufvec) { \
/* .count= */ 1, \
/* .idx = */ 0, \
/* .off = */ 0, \
/* .buf = */ { /* [0] = */ { \
/* .size = */ (size__), \
/* .flags = */ (enum fuse_buf_flags) 0, \
/* .mem = */ NULL, \
/* .fd = */ -1, \
/* .pos = */ 0, \
} } \
} )
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);
/* ----------------------------------------------------------- *
* Signal handling *
* ----------------------------------------------------------- */
int fuse_set_signal_handlers(struct fuse_session *se);
void fuse_remove_signal_handlers(struct fuse_session *se);
/* ----------------------------------------------------------- *
* Compatibility stuff *
* ----------------------------------------------------------- */
#if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
# error only API version 30 or greater is supported
#endif
#ifdef __cplusplus
}
#endif
/*
* This interface uses 64 bit off_t.
*
* On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
*/
#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
#else
struct _fuse_off_t_must_be_64bit_dummy_struct \
{ unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
#endif
#endif /* FUSE_COMMON_H_ */
fuse_bufvec::off
size_t off
Definition: fuse_common.h:679
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:548
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:381
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:72
fuse_conn_info
Definition: fuse_common.h:343
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:43
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:46
FUSE_BUF_IS_FD
Definition: fuse_common.h:555
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:79
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:225
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:357
FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:597
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:352
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:103
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:419
FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:606
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:51
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:75
FUSE_BUF_FD_RETRY
Definition: fuse_common.h:573
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
fuse_buf::pos
off_t pos
Definition: fuse_common.h:654
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_file_info
Definition: fuse_common.h:37
fuse_version
int fuse_version(void)
Definition: fuse.c:5066
fuse_parse_conn_info_opts
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
fuse_file_info::flags
int flags
Definition: fuse_common.h:39
fuse_apply_conn_info_opts
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
Definition: helper.c:361
fuse_bufvec
Definition: fuse_common.h:665
fuse_loop_config
Definition: fuse_common.h:86
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:674
fuse_bufvec::count
size_t count
Definition: fuse_common.h:669
fuse_opt.h
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:60
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:429
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1766
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:56
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:371
FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:589
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:376
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:347
fuse_buf::mem
void * mem
Definition: fuse_common.h:640
FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:615
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:389
fuse_args
Definition: fuse_opt.h:109
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5071
FUSE_BUF_FD_SEEK
Definition: fuse_common.h:564
fuse_buf_size
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
fuse_buf_copy
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition: buffer.c:281
fuse_buf::size
size_t size
Definition: fuse_common.h:628
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:579
fuse_buf::fd
int fd
Definition: fuse_common.h:647
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:91
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:68
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:446
fuse_buf
Definition: fuse_common.h:624