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 #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 14
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
70 unsigned int keep_cache : 1;
71
75 unsigned int flush : 1;
76
79 unsigned int nonseekable : 1;
80
81 /* Indicates that flock locks for this file should be
82 released. If set, lock_owner shall contain a valid value.
83 May only be set in ->release(). */
84 unsigned int flock_release : 1;
85
90 unsigned int cache_readdir : 1;
91
94 unsigned int noflush : 1;
95
97 unsigned int padding : 24;
98 unsigned int padding2 : 32;
99
103 uint64_t fh;
104
106 uint64_t lock_owner;
107
110 uint32_t poll_events;
111 };
112
113
114
121 #if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
122 struct fuse_loop_config_v1; /* forward declarition */
123 struct fuse_loop_config {
124 #else
125 struct fuse_loop_config_v1 {
126 #endif
131 int clone_fd;
132
143 unsigned int max_idle_threads;
144 };
145
146
147 /**************************************************************************
148 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
149 **************************************************************************/
150
161 #define FUSE_CAP_ASYNC_READ (1 << 0)
162
169 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
170
178 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
179
185 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
186
193 #define FUSE_CAP_DONT_MASK (1 << 6)
194
201 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
202
209 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
210
218 #define FUSE_CAP_SPLICE_READ (1 << 9)
219
231 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
232
238 #define FUSE_CAP_IOCTL_DIR (1 << 11)
239
260 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
261
268 #define FUSE_CAP_READDIRPLUS (1 << 13)
269
296 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
297
307 #define FUSE_CAP_ASYNC_DIO (1 << 15)
308
316 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
317
329 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
330
339 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
340
358 #define FUSE_CAP_POSIX_ACL (1 << 19)
359
367 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
368
380 #define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
381
392 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
393
415 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
416
431 #define FUSE_CAP_EXPIRE_ONLY (1 << 26)
432
443 #define FUSE_IOCTL_COMPAT (1 << 0)
444 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
445 #define FUSE_IOCTL_RETRY (1 << 2)
446 #define FUSE_IOCTL_DIR (1 << 4)
447
448 #define FUSE_IOCTL_MAX_IOV 256
449
457 struct fuse_conn_info {
461 unsigned proto_major;
462
466 unsigned proto_minor;
467
471 unsigned max_write;
472
485 unsigned max_read;
486
490 unsigned max_readahead;
491
495 unsigned capable;
496
503 unsigned want;
504
533 unsigned max_background;
534
543 unsigned congestion_threshold;
544
560 unsigned time_gran;
561
565 unsigned reserved[22];
566 };
567
568 struct fuse_session;
569 struct fuse_pollhandle;
570 struct fuse_conn_info_opts;
571
614 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
615
623 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
624 struct fuse_conn_info *conn);
625
632 int fuse_daemonize(int foreground);
633
639 int fuse_version(void);
640
646 const char *fuse_pkgversion(void);
647
653 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
654
655 /* ----------------------------------------------------------- *
656 * Data buffer *
657 * ----------------------------------------------------------- */
658
662 enum fuse_buf_flags {
669 FUSE_BUF_IS_FD = (1 << 1),
670
678 FUSE_BUF_FD_SEEK = (1 << 2),
679
687 FUSE_BUF_FD_RETRY = (1 << 3)
688 };
689
693 enum fuse_buf_copy_flags {
703 FUSE_BUF_NO_SPLICE = (1 << 1),
704
711 FUSE_BUF_FORCE_SPLICE = (1 << 2),
712
720 FUSE_BUF_SPLICE_MOVE = (1 << 3),
721
729 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
730 };
731
738 struct fuse_buf {
742 size_t size;
743
747 enum fuse_buf_flags flags;
748
754 void *mem;
755
761 int fd;
762
768 off_t pos;
769 };
770
779 struct fuse_bufvec {
783 size_t count;
784
788 size_t idx;
789
793 size_t off;
794
798 struct fuse_buf buf[1];
799 };
800
801 /* Initialize bufvec with a single buffer of given size */
802 #define FUSE_BUFVEC_INIT(size__) \
803 ((struct fuse_bufvec) { \
804 /* .count= */ 1, \
805 /* .idx = */ 0, \
806 /* .off = */ 0, \
807 /* .buf = */ { /* [0] = */ { \
808 /* .size = */ (size__), \
809 /* .flags = */ (enum fuse_buf_flags) 0, \
810 /* .mem = */ NULL, \
811 /* .fd = */ -1, \
812 /* .pos = */ 0, \
813 } } \
814 } )
815
822 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
823
832 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
833 enum fuse_buf_copy_flags flags);
834
835 /* ----------------------------------------------------------- *
836 * Signal handling *
837 * ----------------------------------------------------------- */
838
854 int fuse_set_signal_handlers(struct fuse_session *se);
855
867 void fuse_remove_signal_handlers(struct fuse_session *se);
868
874 struct fuse_loop_config *fuse_loop_cfg_create(void);
875
879 void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
880
884 void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
885 unsigned int value);
886
890 void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
891 unsigned int value);
892
896 void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
897 unsigned int value);
898
905 void fuse_loop_cfg_convert(struct fuse_loop_config *config,
906 struct fuse_loop_config_v1 *v1_conf);
907
908 /* ----------------------------------------------------------- *
909 * Compatibility stuff *
910 * ----------------------------------------------------------- */
911
912 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
913 # error only API version 30 or greater is supported
914 #endif
915
916 #ifdef __cplusplus
917 }
918 #endif
919
920
921 /*
922 * This interface uses 64 bit off_t.
923 *
924 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
925 */
926
927 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
928 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
929 #else
930 struct _fuse_off_t_must_be_64bit_dummy_struct \
931 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
932 #endif
933
934 #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