libfuse
fuse_common.h
Go to the documentation of this file.
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 
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 #ifdef HAVE_LIBFUSE_PRIVATE_CONFIG_H
18 #include "fuse_config.h"
19 #endif
20 
21 #include "libfuse_config.h"
22 
23 #include "fuse_opt.h"
24 #include "fuse_log.h"
25 #include <stdint.h>
26 #include <sys/types.h>
27 
29 #define FUSE_MAJOR_VERSION 3
30 
32 #define FUSE_MINOR_VERSION 14
33 
34 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 100 + (min))
35 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
52  int flags;
53 
60  unsigned int writepage : 1;
61 
63  unsigned int direct_io : 1;
64 
69  unsigned int keep_cache : 1;
70 
73  unsigned int parallel_direct_writes : 1;
74 
78  unsigned int flush : 1;
79 
82  unsigned int nonseekable : 1;
83 
84  /* Indicates that flock locks for this file should be
85  released. If set, lock_owner shall contain a valid value.
86  May only be set in ->release(). */
87  unsigned int flock_release : 1;
88 
93  unsigned int cache_readdir : 1;
94 
97  unsigned int noflush : 1;
98 
100  unsigned int padding : 23;
101  unsigned int padding2 : 32;
102 
106  uint64_t fh;
107 
109  uint64_t lock_owner;
110 
113  uint32_t poll_events;
114 };
115 
116 
117 
124 #if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
125 struct fuse_loop_config_v1; /* forward declarition */
127 #else
128 struct fuse_loop_config_v1 {
129 #endif
134  int clone_fd;
135 
146  unsigned int max_idle_threads;
147 };
148 
149 
150 /**************************************************************************
151  * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
152  **************************************************************************/
153 
164 #define FUSE_CAP_ASYNC_READ (1 << 0)
165 
172 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
173 
181 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
182 
188 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
189 
196 #define FUSE_CAP_DONT_MASK (1 << 6)
197 
204 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
205 
212 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
213 
221 #define FUSE_CAP_SPLICE_READ (1 << 9)
222 
234 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
235 
241 #define FUSE_CAP_IOCTL_DIR (1 << 11)
242 
263 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
264 
271 #define FUSE_CAP_READDIRPLUS (1 << 13)
272 
299 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
300 
310 #define FUSE_CAP_ASYNC_DIO (1 << 15)
311 
319 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
320 
332 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
333 
342 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
343 
361 #define FUSE_CAP_POSIX_ACL (1 << 19)
362 
370 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
371 
383 #define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
384 
395 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
396 
418 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
419 
434 #define FUSE_CAP_EXPIRE_ONLY (1 << 26)
435 
446 #define FUSE_IOCTL_COMPAT (1 << 0)
447 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
448 #define FUSE_IOCTL_RETRY (1 << 2)
449 #define FUSE_IOCTL_DIR (1 << 4)
450 
451 #define FUSE_IOCTL_MAX_IOV 256
452 
464  unsigned proto_major;
465 
469  unsigned proto_minor;
470 
474  unsigned max_write;
475 
488  unsigned max_read;
489 
493  unsigned max_readahead;
494 
498  unsigned capable;
499 
506  unsigned want;
507 
536  unsigned max_background;
537 
547 
563  unsigned time_gran;
564 
568  unsigned reserved[22];
569 };
570 
571 struct fuse_session;
572 struct fuse_pollhandle;
573 struct fuse_conn_info_opts;
574 
617 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
618 
626 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
627  struct fuse_conn_info *conn);
628 
635 int fuse_daemonize(int foreground);
636 
642 int fuse_version(void);
643 
649 const char *fuse_pkgversion(void);
650 
656 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
657 
658 /* ----------------------------------------------------------- *
659  * Data buffer *
660  * ----------------------------------------------------------- */
661 
672  FUSE_BUF_IS_FD = (1 << 1),
673 
681  FUSE_BUF_FD_SEEK = (1 << 2),
682 
690  FUSE_BUF_FD_RETRY = (1 << 3)
691 };
692 
706  FUSE_BUF_NO_SPLICE = (1 << 1),
707 
715 
724 
732  FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
733 };
734 
741 struct fuse_buf {
745  size_t size;
746 
750  enum fuse_buf_flags flags;
751 
757  void *mem;
758 
764  int fd;
765 
771  off_t pos;
772 };
773 
782 struct fuse_bufvec {
786  size_t count;
787 
791  size_t idx;
792 
796  size_t off;
797 
801  struct fuse_buf buf[1];
802 };
803 
804 /* Initialize bufvec with a single buffer of given size */
805 #define FUSE_BUFVEC_INIT(size__) \
806  ((struct fuse_bufvec) { \
807  /* .count= */ 1, \
808  /* .idx = */ 0, \
809  /* .off = */ 0, \
810  /* .buf = */ { /* [0] = */ { \
811  /* .size = */ (size__), \
812  /* .flags = */ (enum fuse_buf_flags) 0, \
813  /* .mem = */ NULL, \
814  /* .fd = */ -1, \
815  /* .pos = */ 0, \
816  } } \
817  } )
818 
825 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
826 
835 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
837 
838 /* ----------------------------------------------------------- *
839  * Signal handling *
840  * ----------------------------------------------------------- */
841 
857 int fuse_set_signal_handlers(struct fuse_session *se);
858 
870 void fuse_remove_signal_handlers(struct fuse_session *se);
871 
878 
882 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
883 
888  unsigned int value);
889 
894  unsigned int value);
895 
899 void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
900  unsigned int value);
901 
908 void fuse_loop_cfg_convert(struct fuse_loop_config *config,
909  struct fuse_loop_config_v1 *v1_conf);
910 
911 /* ----------------------------------------------------------- *
912  * Compatibility stuff *
913  * ----------------------------------------------------------- */
914 
915 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
916 # error only API version 30 or greater is supported
917 #endif
918 
919 #ifdef __cplusplus
920 }
921 #endif
922 
923 
924 /*
925  * This interface uses 64 bit off_t.
926  *
927  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
928  */
929 
930 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
931 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
932 #else
933 struct _fuse_off_t_must_be_64bit_dummy_struct \
934  { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
935 #endif
936 
937 #endif /* FUSE_COMMON_H_ */
void fuse_loop_cfg_convert(struct fuse_loop_config *config, struct fuse_loop_config_v1 *v1_conf)
Definition: fuse_loop_mt.c:454
void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:462
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
Definition: helper.c:398
fuse_buf_flags
Definition: fuse_common.h:665
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:681
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:690
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:672
struct fuse_loop_config * fuse_loop_cfg_create(void)
Definition: fuse_loop_mt.c:427
void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:482
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition: buffer.c:284
void fuse_loop_cfg_destroy(struct fuse_loop_config *config)
Definition: fuse_loop_mt.c:441
const char * fuse_pkgversion(void)
Definition: fuse.c:5113
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition: fuse.c:5108
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
Definition: fuse_common.h:696
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:732
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:714
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:706
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:723
int fuse_daemonize(int foreground)
Definition: helper.c:253
void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:476
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:445
enum fuse_buf_flags flags
Definition: fuse_common.h:750
off_t pos
Definition: fuse_common.h:771
void * mem
Definition: fuse_common.h:757
size_t idx
Definition: fuse_common.h:791
size_t count
Definition: fuse_common.h:786
unsigned time_gran
Definition: fuse_common.h:563
unsigned congestion_threshold
Definition: fuse_common.h:546
unsigned max_background
Definition: fuse_common.h:536
unsigned proto_major
Definition: fuse_common.h:464
unsigned max_read
Definition: fuse_common.h:488
unsigned proto_minor
Definition: fuse_common.h:469
unsigned capable
Definition: fuse_common.h:498
unsigned max_readahead
Definition: fuse_common.h:493
unsigned max_write
Definition: fuse_common.h:474
unsigned want
Definition: fuse_common.h:506
unsigned int direct_io
Definition: fuse_common.h:63
unsigned int keep_cache
Definition: fuse_common.h:69
unsigned int nonseekable
Definition: fuse_common.h:82
uint64_t lock_owner
Definition: fuse_common.h:109
uint32_t poll_events
Definition: fuse_common.h:113
unsigned int noflush
Definition: fuse_common.h:97
unsigned int writepage
Definition: fuse_common.h:60
unsigned int flush
Definition: fuse_common.h:78
unsigned int padding
Definition: fuse_common.h:100
unsigned int parallel_direct_writes
Definition: fuse_common.h:73
unsigned int cache_readdir
Definition: fuse_common.h:93
unsigned int max_idle_threads
Definition: fuse_common.h:146