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 15
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 
50 struct fuse_file_info {
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 */
126 struct fuse_loop_config {
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 
441 #define FUSE_CAP_SETXATTR_EXT (1 << 27)
442 
453 #define FUSE_IOCTL_COMPAT (1 << 0)
454 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
455 #define FUSE_IOCTL_RETRY (1 << 2)
456 #define FUSE_IOCTL_DIR (1 << 4)
457 
458 #define FUSE_IOCTL_MAX_IOV 256
459 
467 struct fuse_conn_info {
471  unsigned proto_major;
472 
476  unsigned proto_minor;
477 
481  unsigned max_write;
482 
495  unsigned max_read;
496 
500  unsigned max_readahead;
501 
505  unsigned capable;
506 
513  unsigned want;
514 
543  unsigned max_background;
544 
553  unsigned congestion_threshold;
554 
570  unsigned time_gran;
571 
575  unsigned reserved[22];
576 };
577 
578 struct fuse_session;
579 struct fuse_pollhandle;
580 struct fuse_conn_info_opts;
581 
624 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
625 
633 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
634  struct fuse_conn_info *conn);
635 
642 int fuse_daemonize(int foreground);
643 
649 int fuse_version(void);
650 
656 const char *fuse_pkgversion(void);
657 
663 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
664 
665 /* ----------------------------------------------------------- *
666  * Data buffer *
667  * ----------------------------------------------------------- */
668 
679  FUSE_BUF_IS_FD = (1 << 1),
680 
688  FUSE_BUF_FD_SEEK = (1 << 2),
689 
697  FUSE_BUF_FD_RETRY = (1 << 3)
698 };
699 
713  FUSE_BUF_NO_SPLICE = (1 << 1),
714 
722 
731 
739  FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
740 };
741 
748 struct fuse_buf {
752  size_t size;
753 
757  enum fuse_buf_flags flags;
758 
764  void *mem;
765 
771  int fd;
772 
778  off_t pos;
779 };
780 
789 struct fuse_bufvec {
793  size_t count;
794 
798  size_t idx;
799 
803  size_t off;
804 
808  struct fuse_buf buf[1];
809 };
810 
811 /* Initialize bufvec with a single buffer of given size */
812 #define FUSE_BUFVEC_INIT(size__) \
813  ((struct fuse_bufvec) { \
814  /* .count= */ 1, \
815  /* .idx = */ 0, \
816  /* .off = */ 0, \
817  /* .buf = */ { /* [0] = */ { \
818  /* .size = */ (size__), \
819  /* .flags = */ (enum fuse_buf_flags) 0, \
820  /* .mem = */ NULL, \
821  /* .fd = */ -1, \
822  /* .pos = */ 0, \
823  } } \
824  } )
825 
832 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
833 
842 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
844 
845 /* ----------------------------------------------------------- *
846  * Signal handling *
847  * ----------------------------------------------------------- */
848 
864 int fuse_set_signal_handlers(struct fuse_session *se);
865 
877 void fuse_remove_signal_handlers(struct fuse_session *se);
878 
885 
889 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
890 
895  unsigned int value);
896 
901  unsigned int value);
902 
906 void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
907  unsigned int value);
908 
915 void fuse_loop_cfg_convert(struct fuse_loop_config *config,
916  struct fuse_loop_config_v1 *v1_conf);
917 
918 /* ----------------------------------------------------------- *
919  * Compatibility stuff *
920  * ----------------------------------------------------------- */
921 
922 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
923 # error only API version 30 or greater is supported
924 #endif
925 
926 #ifdef __cplusplus
927 }
928 #endif
929 
930 
931 /*
932  * This interface uses 64 bit off_t.
933  *
934  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
935  */
936 
937 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
938 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
939 #else
940 struct _fuse_off_t_must_be_64bit_dummy_struct \
941  { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
942 #endif
943 
944 #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
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