libfuse: fuse-3.18.2/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 LGPL2.txt.
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 <stdbool.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
50struct 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 */
139struct 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 (1UL << 0)
178
185#define FUSE_CAP_POSIX_LOCKS (1UL << 1)
186
194#define FUSE_CAP_ATOMIC_O_TRUNC (1UL << 3)
195
206#define FUSE_CAP_EXPORT_SUPPORT (1UL << 4)
207
214#define FUSE_CAP_DONT_MASK (1UL << 6)
215
222#define FUSE_CAP_SPLICE_WRITE (1UL << 7)
223
230#define FUSE_CAP_SPLICE_MOVE (1UL << 8)
231
239#define FUSE_CAP_SPLICE_READ (1UL << 9)
240
252#define FUSE_CAP_FLOCK_LOCKS (1UL << 10)
253
259#define FUSE_CAP_IOCTL_DIR (1UL << 11)
260
281#define FUSE_CAP_AUTO_INVAL_DATA (1UL << 12)
282
289#define FUSE_CAP_READDIRPLUS (1UL << 13)
290
317#define FUSE_CAP_READDIRPLUS_AUTO (1UL << 14)
318
328#define FUSE_CAP_ASYNC_DIO (1UL << 15)
329
337#define FUSE_CAP_WRITEBACK_CACHE (1UL << 16)
338
352#define FUSE_CAP_NO_OPEN_SUPPORT (1UL << 17)
353
360#define FUSE_CAP_PARALLEL_DIROPS (1UL << 18)
361
379#define FUSE_CAP_POSIX_ACL (1UL << 19)
380
388#define FUSE_CAP_HANDLE_KILLPRIV (1UL << 20)
389
405#define FUSE_CAP_HANDLE_KILLPRIV_V2 (1UL << 21)
406
418#define FUSE_CAP_CACHE_SYMLINKS (1UL << 23)
419
433#define FUSE_CAP_NO_OPENDIR_SUPPORT (1UL << 24)
434
456#define FUSE_CAP_EXPLICIT_INVAL_DATA (1UL << 25)
457
472#define FUSE_CAP_EXPIRE_ONLY (1UL << 26)
473
479#define FUSE_CAP_SETXATTR_EXT (1UL << 27)
480
488#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP (1UL << 28)
489
500#define FUSE_CAP_PASSTHROUGH (1UL << 29)
501
508#define FUSE_CAP_NO_EXPORT_SUPPORT (1UL << 30)
509
513#define FUSE_CAP_OVER_IO_URING (1UL << 31)
514
525#define FUSE_IOCTL_COMPAT (1 << 0)
526#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
527#define FUSE_IOCTL_RETRY (1 << 2)
528#define FUSE_IOCTL_DIR (1 << 4)
529
530#define FUSE_IOCTL_MAX_IOV 256
531
543struct fuse_conn_info {
547 uint32_t proto_major;
548
552 uint32_t proto_minor;
553
557 uint32_t max_write;
558
571 uint32_t max_read;
572
576 uint32_t max_readahead;
577
583 uint32_t capable;
584
595 uint32_t want;
596
625 uint32_t max_background;
626
635 uint32_t congestion_threshold;
636
652 uint32_t time_gran;
653
670#define FUSE_BACKING_STACKED_UNDER (0)
671#define FUSE_BACKING_STACKED_OVER (1)
672 uint32_t max_backing_stack_depth;
673
682 uint32_t no_interrupt : 1;
683
684 /* reserved bits for future use */
685 uint32_t padding : 31;
686
691 uint64_t capable_ext;
692
701 uint64_t want_ext;
702
707 uint16_t request_timeout;
708
712 uint16_t reserved[31];
713};
714
715struct fuse_session;
716struct fuse_pollhandle;
717struct fuse_conn_info_opts;
718
761struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
762
770void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
771 struct fuse_conn_info *conn);
772
779int fuse_daemonize(int foreground);
780
786int fuse_version(void);
787
793const char *fuse_pkgversion(void);
794
800void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
801
802/* ----------------------------------------------------------- *
803 * Data buffer *
804 * ----------------------------------------------------------- */
805
809 enum fuse_buf_flags {
816 FUSE_BUF_IS_FD = (1 << 1),
817
825 FUSE_BUF_FD_SEEK = (1 << 2),
826
834 FUSE_BUF_FD_RETRY = (1 << 3)
835};
836
840 enum fuse_buf_copy_flags {
850 FUSE_BUF_NO_SPLICE = (1 << 1),
851
858 FUSE_BUF_FORCE_SPLICE = (1 << 2),
859
867 FUSE_BUF_SPLICE_MOVE = (1 << 3),
868
876 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
877};
878
885struct fuse_buf {
889 size_t size;
890
894 enum fuse_buf_flags flags;
895
901 void *mem;
902
908 int fd;
909
915 off_t pos;
916
923 size_t mem_size;
924};
925
934struct fuse_bufvec {
938 size_t count;
939
943 size_t idx;
944
948 size_t off;
949
953 struct fuse_buf buf[1];
954};
955
960struct libfuse_version
961{
962 uint32_t major;
963 uint32_t minor;
964 uint32_t hotfix;
965 uint32_t padding;
966};
967
968/* Initialize bufvec with a single buffer of given size */
969#define FUSE_BUFVEC_INIT(size__) \
970 ((struct fuse_bufvec) { \
971 /* .count= */ 1, \
972 /* .idx = */ 0, \
973 /* .off = */ 0, \
974 /* .buf = */ { /* [0] = */ { \
975 /* .size = */ (size__), \
976 /* .flags = */ (enum fuse_buf_flags) 0, \
977 /* .mem = */ NULL, \
978 /* .fd = */ -1, \
979 /* .pos = */ 0, \
980 /* .mem_size = */ 0, \
981 } } \
982 } )
983
990size_t fuse_buf_size(const struct fuse_bufvec *bufv);
991
1000ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
1001 enum fuse_buf_copy_flags flags);
1002
1003/* ----------------------------------------------------------- *
1004 * Signal handling *
1005 * ----------------------------------------------------------- */
1006
1022int fuse_set_signal_handlers(struct fuse_session *se);
1023
1039int fuse_set_fail_signal_handlers(struct fuse_session *se);
1040
1052void fuse_remove_signal_handlers(struct fuse_session *se);
1053
1059#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
1065struct fuse_loop_config *fuse_loop_cfg_create(void);
1066
1070void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
1071
1075void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
1076 unsigned int value);
1077
1081void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
1082 unsigned int value);
1083
1087void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
1088 unsigned int value);
1089
1096void fuse_loop_cfg_convert(struct fuse_loop_config *config,
1097 struct fuse_loop_config_v1 *v1_conf);
1098#endif
1099
1107bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1108
1115void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1116
1124bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1125
1126/*
1127 * DO NOT USE: Not part of public API, for internal test use only.
1128 * The function signature or any use of it is not guaranteeed to
1129 * remain stable. And neither are results of what this function does.
1130 */
1131int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn);
1132
1133
1134
1135/* ----------------------------------------------------------- *
1136 * Compatibility stuff *
1137 * ----------------------------------------------------------- */
1138
1139#if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
1140# error only API version 30 or greater is supported
1141#endif
1142
1143#ifdef __cplusplus
1144}
1145#endif
1146
1147
1148/*
1149 * This interface uses 64 bit off_t.
1150 *
1151 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
1152 */
1153
1154#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
1155_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
1156#else
1157struct _fuse_off_t_must_be_64bit_dummy_struct \
1158 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
1159#endif
1160
1161#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_log.h
fuse_opt.h
fuse_args
Definition fuse_opt.h:109
fuse_buf
Definition fuse_common.h:874
fuse_bufvec
Definition fuse_common.h:923
fuse_conn_info
Definition fuse_common.h:538
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
libfuse_version
Definition fuse_common.h:950