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
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
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
451 struct fuse_conn_info {
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
537 unsigned congestion_threshold;
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
656 enum fuse_buf_flags {
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
687 enum fuse_buf_copy_flags {
697 FUSE_BUF_NO_SPLICE = (1 << 1),
698
705 FUSE_BUF_FORCE_SPLICE = (1 << 2),
706
714 FUSE_BUF_SPLICE_MOVE = (1 << 3),
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,
827 enum fuse_buf_copy_flags flags);
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
868 struct fuse_loop_config *fuse_loop_cfg_create(void);
869
873 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
874
878 void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
879 unsigned int value);
880
884 void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
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_ */
fuse_loop_cfg_convert
void fuse_loop_cfg_convert(struct fuse_loop_config *config, struct fuse_loop_config_v1 *v1_conf)
Definition: fuse_loop_mt.c:454
fuse_loop_cfg_set_idle_threads
void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:462
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
fuse_buf_size
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
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:398
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:656
FUSE_BUF_FD_SEEK
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:672
FUSE_BUF_FD_RETRY
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:681
FUSE_BUF_IS_FD
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:663
fuse_loop_cfg_create
struct fuse_loop_config * fuse_loop_cfg_create(void)
Definition: fuse_loop_mt.c:427
fuse_loop_cfg_set_clone_fd
void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:480
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:284
fuse_loop_cfg_destroy
void fuse_loop_cfg_destroy(struct fuse_loop_config *config)
Definition: fuse_loop_mt.c:441
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5106
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1832
fuse_version
int fuse_version(void)
Definition: fuse.c:5101
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:687
FUSE_BUF_SPLICE_NONBLOCK
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:723
FUSE_BUF_FORCE_SPLICE
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:705
FUSE_BUF_NO_SPLICE
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:697
FUSE_BUF_SPLICE_MOVE
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:714
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:254
fuse_loop_cfg_set_max_threads
void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:474
fuse_parse_conn_info_opts
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:445
fuse_log.h
fuse_opt.h
fuse_args
Definition: fuse_opt.h:109
fuse_buf
Definition: fuse_common.h:732
fuse_buf::flags
enum fuse_buf_flags flags
Definition: fuse_common.h:741
fuse_buf::mem
void * mem
Definition: fuse_common.h:748
fuse_buf::fd
int fd
Definition: fuse_common.h:755
fuse_buf::pos
off_t pos
Definition: fuse_common.h:762
fuse_bufvec
Definition: fuse_common.h:773
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:782
fuse_bufvec::count
size_t count
Definition: fuse_common.h:777
fuse_conn_info
Definition: fuse_common.h:451
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:554
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:537
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:527
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:455
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:479
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:460
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:489
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:484
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:465
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:497
fuse_file_info
Definition: fuse_common.h:44
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:57
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:64
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:73
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:100
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:97
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:104
fuse_file_info::noflush
unsigned int noflush
Definition: fuse_common.h:88
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:54
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:69
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:91
fuse_file_info::flags
int flags
Definition: fuse_common.h:46
fuse_file_info::cache_readdir
unsigned int cache_readdir
Definition: fuse_common.h:84
fuse_loop_config
Definition: fuse_common.h:117
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:125
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:137