libfuse: fuse-3.17.4/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#include <stdbool.h>
11#if !defined(FUSE_H_) && !defined(FUSE_LOWLEVEL_H_)
12#error "Never include <fuse_common.h> directly; use <fuse.h> or <fuse_lowlevel.h> instead."
13#endif
14
15#ifndef FUSE_COMMON_H_
16#define FUSE_COMMON_H_
17
18#ifdef HAVE_LIBFUSE_PRIVATE_CONFIG_H
19#include "fuse_config.h"
20#endif
21
22#include "libfuse_config.h"
23
24#include "fuse_opt.h"
25#include "fuse_log.h"
26#include <stdint.h>
27#include <sys/types.h>
28#include <assert.h>
29
30#define FUSE_MAKE_VERSION(maj, min) ((maj) * 100 + (min))
31#define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
50 struct fuse_file_info {
52 int32_t flags;
53
60 uint32_t writepage : 1;
61
63 uint32_t direct_io : 1;
64
69 uint32_t keep_cache : 1;
70
74 uint32_t flush : 1;
75
78 uint32_t nonseekable : 1;
79
80 /* Indicates that flock locks for this file should be
81 released. If set, lock_owner shall contain a valid value.
82 May only be set in ->release(). */
83 uint32_t flock_release : 1;
84
89 uint32_t cache_readdir : 1;
90
93 uint32_t noflush : 1;
94
97 uint32_t parallel_direct_writes : 1;
98
100 uint32_t padding : 23;
101 uint32_t padding2 : 32;
102 uint32_t padding3 : 32;
103
107 uint64_t fh;
108
110 uint64_t lock_owner;
111
114 uint32_t poll_events;
115
119 int32_t backing_id;
120
122 uint64_t compat_flags;
123
124 uint64_t reserved[2];
125};
126
137#if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
138struct fuse_loop_config_v1; /* forward declaration */
139 struct fuse_loop_config {
140#else
141struct fuse_loop_config_v1 {
142#endif
147 int clone_fd;
148
159 unsigned int max_idle_threads;
160};
161
162
163/**************************************************************************
164 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
165 **************************************************************************/
166
177#define FUSE_CAP_ASYNC_READ (1 << 0)
178
185#define FUSE_CAP_POSIX_LOCKS (1 << 1)
186
194#define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
195
206#define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
207
214#define FUSE_CAP_DONT_MASK (1 << 6)
215
222#define FUSE_CAP_SPLICE_WRITE (1 << 7)
223
230#define FUSE_CAP_SPLICE_MOVE (1 << 8)
231
239#define FUSE_CAP_SPLICE_READ (1 << 9)
240
252#define FUSE_CAP_FLOCK_LOCKS (1 << 10)
253
259#define FUSE_CAP_IOCTL_DIR (1 << 11)
260
281#define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
282
289#define FUSE_CAP_READDIRPLUS (1 << 13)
290
317#define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
318
328#define FUSE_CAP_ASYNC_DIO (1 << 15)
329
337#define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
338
352#define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
353
360#define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
361
379#define FUSE_CAP_POSIX_ACL (1 << 19)
380
388#define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
389
405#define FUSE_CAP_HANDLE_KILLPRIV_V2 (1 << 21)
406
418#define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
419
433#define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
434
456#define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
457
472#define FUSE_CAP_EXPIRE_ONLY (1 << 26)
473
479#define FUSE_CAP_SETXATTR_EXT (1 << 27)
480
488#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP (1 << 28)
489
500#define FUSE_CAP_PASSTHROUGH (1 << 29)
501
508#define FUSE_CAP_NO_EXPORT_SUPPORT (1 << 30)
509
520#define FUSE_IOCTL_COMPAT (1 << 0)
521#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
522#define FUSE_IOCTL_RETRY (1 << 2)
523#define FUSE_IOCTL_DIR (1 << 4)
524
525#define FUSE_IOCTL_MAX_IOV 256
526
538 struct fuse_conn_info {
542 uint32_t proto_major;
543
547 uint32_t proto_minor;
548
552 uint32_t max_write;
553
566 uint32_t max_read;
567
571 uint32_t max_readahead;
572
578 uint32_t capable;
579
590 uint32_t want;
591
620 uint32_t max_background;
621
630 uint32_t congestion_threshold;
631
647 uint32_t time_gran;
648
665#define FUSE_BACKING_STACKED_UNDER (0)
666#define FUSE_BACKING_STACKED_OVER (1)
667 uint32_t max_backing_stack_depth;
668
677 uint32_t no_interrupt : 1;
678
679 /* reserved bits for future use */
680 uint32_t padding : 31;
681
686 uint64_t capable_ext;
687
696 uint64_t want_ext;
697
701 uint32_t reserved[16];
702};
703
704struct fuse_session;
705struct fuse_pollhandle;
706struct fuse_conn_info_opts;
707
750struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
751
759void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
760 struct fuse_conn_info *conn);
761
768int fuse_daemonize(int foreground);
769
775int fuse_version(void);
776
782const char *fuse_pkgversion(void);
783
789void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
790
791/* ----------------------------------------------------------- *
792 * Data buffer *
793 * ----------------------------------------------------------- */
794
798 enum fuse_buf_flags {
805 FUSE_BUF_IS_FD = (1 << 1),
806
814 FUSE_BUF_FD_SEEK = (1 << 2),
815
823 FUSE_BUF_FD_RETRY = (1 << 3)
824};
825
829 enum fuse_buf_copy_flags {
839 FUSE_BUF_NO_SPLICE = (1 << 1),
840
847 FUSE_BUF_FORCE_SPLICE = (1 << 2),
848
856 FUSE_BUF_SPLICE_MOVE = (1 << 3),
857
865 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
866};
867
874 struct fuse_buf {
878 size_t size;
879
883 enum fuse_buf_flags flags;
884
890 void *mem;
891
897 int fd;
898
904 off_t pos;
905
912 size_t mem_size;
913};
914
923 struct fuse_bufvec {
927 size_t count;
928
932 size_t idx;
933
937 size_t off;
938
942 struct fuse_buf buf[1];
943};
944
949 struct libfuse_version
950{
951 uint32_t major;
952 uint32_t minor;
953 uint32_t hotfix;
954 uint32_t padding;
955};
956
957/* Initialize bufvec with a single buffer of given size */
958#define FUSE_BUFVEC_INIT(size__) \
959 ((struct fuse_bufvec) { \
960 /* .count= */ 1, \
961 /* .idx = */ 0, \
962 /* .off = */ 0, \
963 /* .buf = */ { /* [0] = */ { \
964 /* .size = */ (size__), \
965 /* .flags = */ (enum fuse_buf_flags) 0, \
966 /* .mem = */ NULL, \
967 /* .fd = */ -1, \
968 /* .pos = */ 0, \
969 /* .mem_size = */ 0, \
970 } } \
971 } )
972
979size_t fuse_buf_size(const struct fuse_bufvec *bufv);
980
989ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
990 enum fuse_buf_copy_flags flags);
991
992/* ----------------------------------------------------------- *
993 * Signal handling *
994 * ----------------------------------------------------------- */
995
1011int fuse_set_signal_handlers(struct fuse_session *se);
1012
1028int fuse_set_fail_signal_handlers(struct fuse_session *se);
1029
1041void fuse_remove_signal_handlers(struct fuse_session *se);
1042
1048#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
1054struct fuse_loop_config *fuse_loop_cfg_create(void);
1055
1059void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
1060
1064void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
1065 unsigned int value);
1066
1070void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
1071 unsigned int value);
1072
1076void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
1077 unsigned int value);
1078
1085void fuse_loop_cfg_convert(struct fuse_loop_config *config,
1086 struct fuse_loop_config_v1 *v1_conf);
1087#endif
1088
1096bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1097
1104void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1105
1113bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1114
1115/*
1116 * DO NOT USE: Not part of public API, for internal test use only.
1117 * The function signature or any use of it is not guaranteeed to
1118 * remain stable. And neither are results of what this function does.
1119 */
1120int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn);
1121
1122
1123
1124/* ----------------------------------------------------------- *
1125 * Compatibility stuff *
1126 * ----------------------------------------------------------- */
1127
1128#if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
1129# error only API version 30 or greater is supported
1130#endif
1131
1132#ifdef __cplusplus
1133}
1134#endif
1135
1136
1137/*
1138 * This interface uses 64 bit off_t.
1139 *
1140 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
1141 */
1142
1143#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
1144_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
1145#else
1146struct _fuse_off_t_must_be_64bit_dummy_struct \
1147 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
1148#endif
1149
1150#endif /* FUSE_COMMON_H_ */
fuse_unset_feature_flag
void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
Definition fuse_lowlevel.c:2050
fuse_convert_to_conn_want_ext
int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn)
Definition fuse_lowlevel.c:2000
fuse_set_fail_signal_handlers
int fuse_set_fail_signal_handlers(struct fuse_session *se)
Definition fuse_signals.c:165
fuse_set_feature_flag
bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
Definition fuse_lowlevel.c:2035
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition fuse_signals.c:140
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:412
fuse_buf_flags
fuse_buf_flags
Definition fuse_common.h:798
FUSE_BUF_FD_SEEK
@ FUSE_BUF_FD_SEEK
Definition fuse_common.h:814
FUSE_BUF_FD_RETRY
@ FUSE_BUF_FD_RETRY
Definition fuse_common.h:823
FUSE_BUF_IS_FD
@ FUSE_BUF_IS_FD
Definition fuse_common.h:805
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_parse_conn_info_opts
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition helper.c:466
fuse_get_feature_flag
bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
Definition fuse_lowlevel.c:2061
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition fuse.c:5211
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition fuse_lowlevel.c:1903
fuse_version
int fuse_version(void)
Definition fuse.c:5206
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition fuse_signals.c:187
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition fuse_common.h:829
FUSE_BUF_SPLICE_NONBLOCK
@ FUSE_BUF_SPLICE_NONBLOCK
Definition fuse_common.h:865
FUSE_BUF_FORCE_SPLICE
@ FUSE_BUF_FORCE_SPLICE
Definition fuse_common.h:847
FUSE_BUF_NO_SPLICE
@ FUSE_BUF_NO_SPLICE
Definition fuse_common.h:839
FUSE_BUF_SPLICE_MOVE
@ FUSE_BUF_SPLICE_MOVE
Definition fuse_common.h:856
fuse_daemonize
int fuse_daemonize(int foreground)
Definition helper.c:253
fuse_buf_flags
fuse_buf_flags
Definition fuse_common.h:809
fuse_log.h
fuse_opt.h
fuse_args
Definition fuse_opt.h:109
fuse_buf
Definition fuse_common.h:874
fuse_buf::flags
enum fuse_buf_flags flags
Definition fuse_common.h:883
fuse_buf::mem_size
size_t mem_size
Definition fuse_common.h:912
fuse_buf::fd
int fd
Definition fuse_common.h:897
fuse_buf::pos
off_t pos
Definition fuse_common.h:904
fuse_buf::mem
void * mem
Definition fuse_common.h:890
fuse_buf::size
size_t size
Definition fuse_common.h:878
fuse_bufvec
Definition fuse_common.h:923
fuse_bufvec::off
size_t off
Definition fuse_common.h:937
fuse_bufvec::idx
size_t idx
Definition fuse_common.h:932
fuse_bufvec::count
size_t count
Definition fuse_common.h:927
fuse_conn_info
Definition fuse_common.h:538
fuse_conn_info::time_gran
uint32_t time_gran
Definition fuse_common.h:647
fuse_conn_info::proto_major
uint32_t proto_major
Definition fuse_common.h:542
fuse_conn_info::want
uint32_t want
Definition fuse_common.h:590
fuse_conn_info::congestion_threshold
uint32_t congestion_threshold
Definition fuse_common.h:630
fuse_conn_info::proto_minor
uint32_t proto_minor
Definition fuse_common.h:547
fuse_conn_info::max_write
uint32_t max_write
Definition fuse_common.h:552
fuse_conn_info::capable_ext
uint64_t capable_ext
Definition fuse_common.h:686
fuse_conn_info::max_readahead
uint32_t max_readahead
Definition fuse_common.h:571
fuse_conn_info::no_interrupt
uint32_t no_interrupt
Definition fuse_common.h:677
fuse_conn_info::max_read
uint32_t max_read
Definition fuse_common.h:566
fuse_conn_info::max_background
uint32_t max_background
Definition fuse_common.h:620
fuse_conn_info::capable
uint32_t capable
Definition fuse_common.h:578
fuse_conn_info::want_ext
uint64_t want_ext
Definition fuse_common.h:696
fuse_file_info
Definition fuse_common.h:50
fuse_file_info::lock_owner
uint64_t lock_owner
Definition fuse_common.h:110
fuse_file_info::fh
uint64_t fh
Definition fuse_common.h:107
fuse_file_info::writepage
uint32_t writepage
Definition fuse_common.h:60
fuse_file_info::poll_events
uint32_t poll_events
Definition fuse_common.h:114
fuse_file_info::cache_readdir
uint32_t cache_readdir
Definition fuse_common.h:89
fuse_file_info::nonseekable
uint32_t nonseekable
Definition fuse_common.h:78
fuse_file_info::backing_id
int32_t backing_id
Definition fuse_common.h:119
fuse_file_info::parallel_direct_writes
uint32_t parallel_direct_writes
Definition fuse_common.h:97
fuse_file_info::padding
uint32_t padding
Definition fuse_common.h:100
fuse_file_info::noflush
uint32_t noflush
Definition fuse_common.h:93
fuse_file_info::compat_flags
uint64_t compat_flags
Definition fuse_common.h:122
fuse_file_info::flush
uint32_t flush
Definition fuse_common.h:74
fuse_file_info::direct_io
uint32_t direct_io
Definition fuse_common.h:63
fuse_file_info::keep_cache
uint32_t keep_cache
Definition fuse_common.h:69
fuse_file_info::flags
int32_t flags
Definition fuse_common.h:52
fuse_loop_config
Definition fuse_common.h:139
fuse_loop_config::clone_fd
int clone_fd
Definition fuse_common.h:147
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition fuse_common.h:159
libfuse_version
Definition fuse_common.h:950