libfuse: include/fuse_common.h Source File

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_config.h"
18 #include "fuse_opt.h"
19 #include "fuse_log.h"
20 #include <stdint.h>
21 #include <sys/types.h>
22
24 #define FUSE_MAJOR_VERSION 3
25
27 #define FUSE_MINOR_VERSION 13
28
29 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 100 + (min))
30 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
45 struct fuse_file_info {
47 int flags;
48
55 unsigned int writepage : 1;
56
58 unsigned int direct_io : 1;
59
65 unsigned int keep_cache : 1;
66
70 unsigned int flush : 1;
71
74 unsigned int nonseekable : 1;
75
76 /* Indicates that flock locks for this file should be
77 released. If set, lock_owner shall contain a valid value.
78 May only be set in ->release(). */
79 unsigned int flock_release : 1;
80
85 unsigned int cache_readdir : 1;
86
89 unsigned int noflush : 1;
90
92 unsigned int padding : 24;
93 unsigned int padding2 : 32;
94
98 uint64_t fh;
99
101 uint64_t lock_owner;
102
105 uint32_t poll_events;
106 };
107
108
109
116 #if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
117 struct fuse_loop_config_v1; /* forward declarition */
118 struct fuse_loop_config {
119 #else
120 struct fuse_loop_config_v1 {
121 #endif
126 int clone_fd;
127
138 unsigned int max_idle_threads;
139 };
140
141
142 /**************************************************************************
143 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
144 **************************************************************************/
145
156 #define FUSE_CAP_ASYNC_READ (1 << 0)
157
164 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
165
173 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
174
180 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
181
188 #define FUSE_CAP_DONT_MASK (1 << 6)
189
196 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
197
204 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
205
213 #define FUSE_CAP_SPLICE_READ (1 << 9)
214
226 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
227
233 #define FUSE_CAP_IOCTL_DIR (1 << 11)
234
255 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
256
263 #define FUSE_CAP_READDIRPLUS (1 << 13)
264
291 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
292
302 #define FUSE_CAP_ASYNC_DIO (1 << 15)
303
311 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
312
324 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
325
334 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
335
353 #define FUSE_CAP_POSIX_ACL (1 << 19)
354
362 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
363
375 #define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
376
387 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
388
410 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
411
426 #define FUSE_CAP_EXPIRE_ONLY (1 << 26)
427
438 #define FUSE_IOCTL_COMPAT (1 << 0)
439 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
440 #define FUSE_IOCTL_RETRY (1 << 2)
441 #define FUSE_IOCTL_DIR (1 << 4)
442
443 #define FUSE_IOCTL_MAX_IOV 256
444
452 struct fuse_conn_info {
456 unsigned proto_major;
457
461 unsigned proto_minor;
462
466 unsigned max_write;
467
480 unsigned max_read;
481
485 unsigned max_readahead;
486
490 unsigned capable;
491
498 unsigned want;
499
528 unsigned max_background;
529
538 unsigned congestion_threshold;
539
555 unsigned time_gran;
556
560 unsigned reserved[22];
561 };
562
563 struct fuse_session;
564 struct fuse_pollhandle;
565 struct fuse_conn_info_opts;
566
609 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
610
618 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
619 struct fuse_conn_info *conn);
620
627 int fuse_daemonize(int foreground);
628
634 int fuse_version(void);
635
641 const char *fuse_pkgversion(void);
642
648 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
649
650 /* ----------------------------------------------------------- *
651 * Data buffer *
652 * ----------------------------------------------------------- */
653
657 enum fuse_buf_flags {
664 FUSE_BUF_IS_FD = (1 << 1),
665
673 FUSE_BUF_FD_SEEK = (1 << 2),
674
682 FUSE_BUF_FD_RETRY = (1 << 3)
683 };
684
688 enum fuse_buf_copy_flags {
698 FUSE_BUF_NO_SPLICE = (1 << 1),
699
706 FUSE_BUF_FORCE_SPLICE = (1 << 2),
707
715 FUSE_BUF_SPLICE_MOVE = (1 << 3),
716
724 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
725 };
726
733 struct fuse_buf {
737 size_t size;
738
742 enum fuse_buf_flags flags;
743
749 void *mem;
750
756 int fd;
757
763 off_t pos;
764 };
765
774 struct fuse_bufvec {
778 size_t count;
779
783 size_t idx;
784
788 size_t off;
789
793 struct fuse_buf buf[1];
794 };
795
796 /* Initialize bufvec with a single buffer of given size */
797 #define FUSE_BUFVEC_INIT(size__) \
798 ((struct fuse_bufvec) { \
799 /* .count= */ 1, \
800 /* .idx = */ 0, \
801 /* .off = */ 0, \
802 /* .buf = */ { /* [0] = */ { \
803 /* .size = */ (size__), \
804 /* .flags = */ (enum fuse_buf_flags) 0, \
805 /* .mem = */ NULL, \
806 /* .fd = */ -1, \
807 /* .pos = */ 0, \
808 } } \
809 } )
810
817 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
818
827 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
828 enum fuse_buf_copy_flags flags);
829
830 /* ----------------------------------------------------------- *
831 * Signal handling *
832 * ----------------------------------------------------------- */
833
849 int fuse_set_signal_handlers(struct fuse_session *se);
850
862 void fuse_remove_signal_handlers(struct fuse_session *se);
863
869 struct fuse_loop_config *fuse_loop_cfg_create(void);
870
874 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
875
879 void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
880 unsigned int value);
881
885 void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
886 unsigned int value);
887
891 void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
892 unsigned int value);
893
900 void fuse_loop_cfg_convert(struct fuse_loop_config *config,
901 struct fuse_loop_config_v1 *v1_conf);
902
903 /* ----------------------------------------------------------- *
904 * Compatibility stuff *
905 * ----------------------------------------------------------- */
906
907 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
908 # error only API version 30 or greater is supported
909 #endif
910
911 #ifdef __cplusplus
912 }
913 #endif
914
915
916 /*
917 * This interface uses 64 bit off_t.
918 *
919 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
920 */
921
922 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
923 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
924 #else
925 struct _fuse_off_t_must_be_64bit_dummy_struct \
926 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
927 #endif
928
929 #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_bufvec
Definition: fuse_common.h:773
fuse_conn_info
Definition: fuse_common.h:451
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