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 12
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 
44 struct fuse_file_info {
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 */
117 struct fuse_loop_config {
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 
421 #define FUSE_IOCTL_COMPAT (1 << 0)
422 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
423 #define FUSE_IOCTL_RETRY (1 << 2)
424 #define FUSE_IOCTL_DIR (1 << 4)
425 
426 #define FUSE_IOCTL_MAX_IOV 256
427 
435 struct fuse_conn_info {
439  unsigned proto_major;
440 
444  unsigned proto_minor;
445 
449  unsigned max_write;
450 
463  unsigned max_read;
464 
468  unsigned max_readahead;
469 
473  unsigned capable;
474 
481  unsigned want;
482 
511  unsigned max_background;
512 
521  unsigned congestion_threshold;
522 
538  unsigned time_gran;
539 
543  unsigned reserved[22];
544 };
545 
546 struct fuse_session;
547 struct fuse_pollhandle;
548 struct fuse_conn_info_opts;
549 
592 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
593 
601 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
602  struct fuse_conn_info *conn);
603 
610 int fuse_daemonize(int foreground);
611 
617 int fuse_version(void);
618 
624 const char *fuse_pkgversion(void);
625 
631 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
632 
633 /* ----------------------------------------------------------- *
634  * Data buffer *
635  * ----------------------------------------------------------- */
636 
647  FUSE_BUF_IS_FD = (1 << 1),
648 
656  FUSE_BUF_FD_SEEK = (1 << 2),
657 
665  FUSE_BUF_FD_RETRY = (1 << 3)
666 };
667 
681  FUSE_BUF_NO_SPLICE = (1 << 1),
682 
690 
699 
707  FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
708 };
709 
716 struct fuse_buf {
720  size_t size;
721 
725  enum fuse_buf_flags flags;
726 
732  void *mem;
733 
739  int fd;
740 
746  off_t pos;
747 };
748 
757 struct fuse_bufvec {
761  size_t count;
762 
766  size_t idx;
767 
771  size_t off;
772 
776  struct fuse_buf buf[1];
777 };
778 
779 /* Initialize bufvec with a single buffer of given size */
780 #define FUSE_BUFVEC_INIT(size__) \
781  ((struct fuse_bufvec) { \
782  /* .count= */ 1, \
783  /* .idx = */ 0, \
784  /* .off = */ 0, \
785  /* .buf = */ { /* [0] = */ { \
786  /* .size = */ (size__), \
787  /* .flags = */ (enum fuse_buf_flags) 0, \
788  /* .mem = */ NULL, \
789  /* .fd = */ -1, \
790  /* .pos = */ 0, \
791  } } \
792  } )
793 
800 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
801 
810 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
812 
813 /* ----------------------------------------------------------- *
814  * Signal handling *
815  * ----------------------------------------------------------- */
816 
832 int fuse_set_signal_handlers(struct fuse_session *se);
833 
845 void fuse_remove_signal_handlers(struct fuse_session *se);
846 
853 
857 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
858 
863  unsigned int value);
864 
869  unsigned int value);
870 
874 void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
875  unsigned int value);
876 
883 void fuse_loop_cfg_convert(struct fuse_loop_config *config,
884  struct fuse_loop_config_v1 *v1_conf);
885 
886 /* ----------------------------------------------------------- *
887  * Compatibility stuff *
888  * ----------------------------------------------------------- */
889 
890 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
891 # error only API version 30 or greater is supported
892 #endif
893 
894 #ifdef __cplusplus
895 }
896 #endif
897 
898 
899 /*
900  * This interface uses 64 bit off_t.
901  *
902  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
903  */
904 
905 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
906 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
907 #else
908 struct _fuse_off_t_must_be_64bit_dummy_struct \
909  { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
910 #endif
911 
912 #endif /* FUSE_COMMON_H_ */
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:361
fuse_buf_flags
Definition: fuse_common.h:626
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:642
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:651
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:633
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition: buffer.c:284
const char * fuse_pkgversion(void)
Definition: fuse.c:5122
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition: fuse.c:5117
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
Definition: fuse_common.h:657
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:693
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:675
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:667
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:684
int fuse_daemonize(int foreground)
Definition: helper.c:225
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
void fuse_loop_cfg_convert(struct fuse_loop_config *config, struct fuse_loop_config_v1 *v1_conf)
Definition: fuse_loop_mt.c:451
void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:459
struct fuse_loop_config * fuse_loop_cfg_create(void)
Definition: fuse_loop_mt.c:424
void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:471
void fuse_loop_cfg_destroy(struct fuse_loop_config *config)
Definition: fuse_loop_mt.c:438
void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:465
enum fuse_buf_flags flags
Definition: fuse_common.h:711
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:96
uint64_t fh
Definition: fuse_common.h:93
uint32_t poll_events
Definition: fuse_common.h:100
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:87
unsigned int cache_readdir
Definition: fuse_common.h:84
unsigned int max_idle_threads
Definition: fuse_common.h:124