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 #include "fuse_opt.h"
18 #include "fuse_log.h"
19 #include <stdint.h>
20 #include <sys/types.h>
21 
23 #define FUSE_MAJOR_VERSION 3
24 
26 #define FUSE_MINOR_VERSION 13
27 
28 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 100 + (min))
29 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
46  int flags;
47 
54  unsigned int writepage : 1;
55 
57  unsigned int direct_io : 1;
58 
64  unsigned int keep_cache : 1;
65 
69  unsigned int flush : 1;
70 
73  unsigned int nonseekable : 1;
74 
75  /* Indicates that flock locks for this file should be
76  released. If set, lock_owner shall contain a valid value.
77  May only be set in ->release(). */
78  unsigned int flock_release : 1;
79 
84  unsigned int cache_readdir : 1;
85 
88  unsigned int noflush : 1;
89 
91  unsigned int padding : 24;
92  unsigned int padding2 : 32;
93 
97  uint64_t fh;
98 
100  uint64_t lock_owner;
101 
104  uint32_t poll_events;
105 };
106 
107 
108 
115 #if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
116 struct fuse_loop_config_v1; /* forward declarition */
118 #else
119 struct fuse_loop_config_v1 {
120 #endif
125  int clone_fd;
126 
137  unsigned int max_idle_threads;
138 };
139 
140 
141 /**************************************************************************
142  * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
143  **************************************************************************/
144 
155 #define FUSE_CAP_ASYNC_READ (1 << 0)
156 
163 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
164 
172 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
173 
179 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
180 
187 #define FUSE_CAP_DONT_MASK (1 << 6)
188 
195 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
196 
203 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
204 
212 #define FUSE_CAP_SPLICE_READ (1 << 9)
213 
225 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
226 
232 #define FUSE_CAP_IOCTL_DIR (1 << 11)
233 
254 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
255 
262 #define FUSE_CAP_READDIRPLUS (1 << 13)
263 
290 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
291 
301 #define FUSE_CAP_ASYNC_DIO (1 << 15)
302 
310 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
311 
323 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
324 
333 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
334 
352 #define FUSE_CAP_POSIX_ACL (1 << 19)
353 
361 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
362 
374 #define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
375 
386 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
387 
409 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
410 
425 #define FUSE_CAP_EXPIRE_ONLY (1 << 26)
426 
437 #define FUSE_IOCTL_COMPAT (1 << 0)
438 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
439 #define FUSE_IOCTL_RETRY (1 << 2)
440 #define FUSE_IOCTL_DIR (1 << 4)
441 
442 #define FUSE_IOCTL_MAX_IOV 256
443 
455  unsigned proto_major;
456 
460  unsigned proto_minor;
461 
465  unsigned max_write;
466 
479  unsigned max_read;
480 
484  unsigned max_readahead;
485 
489  unsigned capable;
490 
497  unsigned want;
498 
527  unsigned max_background;
528 
538 
554  unsigned time_gran;
555 
559  unsigned reserved[22];
560 };
561 
562 struct fuse_session;
563 struct fuse_pollhandle;
564 struct fuse_conn_info_opts;
565 
608 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
609 
617 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
618  struct fuse_conn_info *conn);
619 
626 int fuse_daemonize(int foreground);
627 
633 int fuse_version(void);
634 
640 const char *fuse_pkgversion(void);
641 
647 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
648 
649 /* ----------------------------------------------------------- *
650  * Data buffer *
651  * ----------------------------------------------------------- */
652 
663  FUSE_BUF_IS_FD = (1 << 1),
664 
672  FUSE_BUF_FD_SEEK = (1 << 2),
673 
681  FUSE_BUF_FD_RETRY = (1 << 3)
682 };
683 
697  FUSE_BUF_NO_SPLICE = (1 << 1),
698 
706 
715 
723  FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
724 };
725 
732 struct fuse_buf {
736  size_t size;
737 
741  enum fuse_buf_flags flags;
742 
748  void *mem;
749 
755  int fd;
756 
762  off_t pos;
763 };
764 
773 struct fuse_bufvec {
777  size_t count;
778 
782  size_t idx;
783 
787  size_t off;
788 
792  struct fuse_buf buf[1];
793 };
794 
795 /* Initialize bufvec with a single buffer of given size */
796 #define FUSE_BUFVEC_INIT(size__) \
797  ((struct fuse_bufvec) { \
798  /* .count= */ 1, \
799  /* .idx = */ 0, \
800  /* .off = */ 0, \
801  /* .buf = */ { /* [0] = */ { \
802  /* .size = */ (size__), \
803  /* .flags = */ (enum fuse_buf_flags) 0, \
804  /* .mem = */ NULL, \
805  /* .fd = */ -1, \
806  /* .pos = */ 0, \
807  } } \
808  } )
809 
816 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
817 
826 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
828 
829 /* ----------------------------------------------------------- *
830  * Signal handling *
831  * ----------------------------------------------------------- */
832 
848 int fuse_set_signal_handlers(struct fuse_session *se);
849 
861 void fuse_remove_signal_handlers(struct fuse_session *se);
862 
869 
873 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
874 
879  unsigned int value);
880 
885  unsigned int value);
886 
890 void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
891  unsigned int value);
892 
899 void fuse_loop_cfg_convert(struct fuse_loop_config *config,
900  struct fuse_loop_config_v1 *v1_conf);
901 
902 /* ----------------------------------------------------------- *
903  * Compatibility stuff *
904  * ----------------------------------------------------------- */
905 
906 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
907 # error only API version 30 or greater is supported
908 #endif
909 
910 #ifdef __cplusplus
911 }
912 #endif
913 
914 
915 /*
916  * This interface uses 64 bit off_t.
917  *
918  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
919  */
920 
921 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
922 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
923 #else
924 struct _fuse_off_t_must_be_64bit_dummy_struct \
925  { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
926 #endif
927 
928 #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:656
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:672
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:681
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:663
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:480
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:5106
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition: fuse.c:5101
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
Definition: fuse_common.h:687
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:723
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:705
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:697
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:714
int fuse_daemonize(int foreground)
Definition: helper.c:254
void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:474
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:741
off_t pos
Definition: fuse_common.h:762
void * mem
Definition: fuse_common.h:748
size_t idx
Definition: fuse_common.h:782
size_t count
Definition: fuse_common.h:777
unsigned time_gran
Definition: fuse_common.h:554
unsigned congestion_threshold
Definition: fuse_common.h:537
unsigned max_background
Definition: fuse_common.h:527
unsigned proto_major
Definition: fuse_common.h:455
unsigned max_read
Definition: fuse_common.h:479
unsigned proto_minor
Definition: fuse_common.h:460
unsigned capable
Definition: fuse_common.h:489
unsigned max_readahead
Definition: fuse_common.h:484
unsigned max_write
Definition: fuse_common.h:465
unsigned want
Definition: fuse_common.h:497
unsigned int direct_io
Definition: fuse_common.h:57
unsigned int keep_cache
Definition: fuse_common.h:64
unsigned int nonseekable
Definition: fuse_common.h:73
uint64_t lock_owner
Definition: fuse_common.h:100
uint64_t fh
Definition: fuse_common.h:97
uint32_t poll_events
Definition: fuse_common.h:104
unsigned int noflush
Definition: fuse_common.h:88
unsigned int writepage
Definition: fuse_common.h:54
unsigned int flush
Definition: fuse_common.h:69
unsigned int padding
Definition: fuse_common.h:91
unsigned int cache_readdir
Definition: fuse_common.h:84
unsigned int max_idle_threads
Definition: fuse_common.h:137