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
9
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
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
98
105 uint32_t kill_suidgid : 1;
106
108 uint32_t padding : 22;
109 uint32_t padding2 : 32;
110 uint32_t padding3 : 32;
111
115 uint64_t fh;
116
118 uint64_t lock_owner;
119
122 uint32_t poll_events;
123
127 int32_t backing_id;
128
130 uint64_t compat_flags;
131
132 uint64_t reserved[2];
133};
134
145#if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
146struct fuse_loop_config_v1; /* forward declaration */
148#else
149struct fuse_loop_config_v1 {
150#endif
156
167 unsigned int max_idle_threads;
168};
169
170
171/**************************************************************************
172 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
173 **************************************************************************/
174
185#define FUSE_CAP_ASYNC_READ (1UL << 0)
186
193#define FUSE_CAP_POSIX_LOCKS (1UL << 1)
194
202#define FUSE_CAP_ATOMIC_O_TRUNC (1UL << 3)
203
214#define FUSE_CAP_EXPORT_SUPPORT (1UL << 4)
215
222#define FUSE_CAP_DONT_MASK (1UL << 6)
223
230#define FUSE_CAP_SPLICE_WRITE (1UL << 7)
231
238#define FUSE_CAP_SPLICE_MOVE (1UL << 8)
239
247#define FUSE_CAP_SPLICE_READ (1UL << 9)
248
260#define FUSE_CAP_FLOCK_LOCKS (1UL << 10)
261
267#define FUSE_CAP_IOCTL_DIR (1UL << 11)
268
289#define FUSE_CAP_AUTO_INVAL_DATA (1UL << 12)
290
297#define FUSE_CAP_READDIRPLUS (1UL << 13)
298
325#define FUSE_CAP_READDIRPLUS_AUTO (1UL << 14)
326
336#define FUSE_CAP_ASYNC_DIO (1UL << 15)
337
345#define FUSE_CAP_WRITEBACK_CACHE (1UL << 16)
346
360#define FUSE_CAP_NO_OPEN_SUPPORT (1UL << 17)
361
368#define FUSE_CAP_PARALLEL_DIROPS (1UL << 18)
369
387#define FUSE_CAP_POSIX_ACL (1UL << 19)
388
396#define FUSE_CAP_HANDLE_KILLPRIV (1UL << 20)
397
413#define FUSE_CAP_HANDLE_KILLPRIV_V2 (1UL << 21)
414
426#define FUSE_CAP_CACHE_SYMLINKS (1UL << 23)
427
441#define FUSE_CAP_NO_OPENDIR_SUPPORT (1UL << 24)
442
464#define FUSE_CAP_EXPLICIT_INVAL_DATA (1UL << 25)
465
480#define FUSE_CAP_EXPIRE_ONLY (1UL << 26)
481
487#define FUSE_CAP_SETXATTR_EXT (1UL << 27)
488
496#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP (1UL << 28)
497
508#define FUSE_CAP_PASSTHROUGH (1UL << 29)
509
516#define FUSE_CAP_NO_EXPORT_SUPPORT (1UL << 30)
517
521#define FUSE_CAP_OVER_IO_URING (1UL << 31)
522
533#define FUSE_IOCTL_COMPAT (1 << 0)
534#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
535#define FUSE_IOCTL_RETRY (1 << 2)
536#define FUSE_IOCTL_DIR (1 << 4)
537
538#define FUSE_IOCTL_MAX_IOV 256
539
555 uint32_t proto_major;
556
560 uint32_t proto_minor;
561
565 uint32_t max_write;
566
579 uint32_t max_read;
580
585
591 uint32_t capable;
592
603 uint32_t want;
604
634
644
660 uint32_t time_gran;
661
678#define FUSE_BACKING_STACKED_UNDER (0)
679#define FUSE_BACKING_STACKED_OVER (1)
680 uint32_t max_backing_stack_depth;
681
690 uint32_t no_interrupt : 1;
691
692 /* reserved bits for future use */
693 uint32_t padding : 31;
694
699 uint64_t capable_ext;
700
709 uint64_t want_ext;
710
716
720 uint16_t reserved[31];
721};
722
723struct fuse_session;
724struct fuse_pollhandle;
725struct fuse_conn_info_opts;
726
769struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
770
778void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
779 struct fuse_conn_info *conn);
780
787int fuse_daemonize(int foreground);
788
794int fuse_version(void);
795
801const char *fuse_pkgversion(void);
802
808void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
809
810/* ----------------------------------------------------------- *
811 * Data buffer *
812 * ----------------------------------------------------------- */
813
824 FUSE_BUF_IS_FD = (1 << 1),
825
834
843};
844
886
893struct fuse_buf {
897 size_t size;
898
903
909 void *mem;
910
916 int fd;
917
923 off_t pos;
924
931 size_t mem_size;
932};
933
946 size_t count;
947
951 size_t idx;
952
956 size_t off;
957
961 struct fuse_buf buf[1];
962};
963
969{
970 uint32_t major;
971 uint32_t minor;
972 uint32_t hotfix;
973 uint32_t padding;
974};
975
976/* Initialize bufvec with a single buffer of given size */
977#define FUSE_BUFVEC_INIT(size__) \
978 ((struct fuse_bufvec) { \
979 /* .count= */ 1, \
980 /* .idx = */ 0, \
981 /* .off = */ 0, \
982 /* .buf = */ { /* [0] = */ { \
983 /* .size = */ (size__), \
984 /* .flags = */ (enum fuse_buf_flags) 0, \
985 /* .mem = */ NULL, \
986 /* .fd = */ -1, \
987 /* .pos = */ 0, \
988 /* .mem_size = */ 0, \
989 } } \
990 } )
991
998size_t fuse_buf_size(const struct fuse_bufvec *bufv);
999
1008ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
1009 enum fuse_buf_copy_flags flags);
1010
1011/* ----------------------------------------------------------- *
1012 * Signal handling *
1013 * ----------------------------------------------------------- */
1014
1030int fuse_set_signal_handlers(struct fuse_session *se);
1031
1047int fuse_set_fail_signal_handlers(struct fuse_session *se);
1048
1060void fuse_remove_signal_handlers(struct fuse_session *se);
1061
1067#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
1073struct fuse_loop_config *fuse_loop_cfg_create(void);
1074
1078void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
1079
1083void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
1084 unsigned int value);
1085
1089void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
1090 unsigned int value);
1091
1095void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
1096 unsigned int value);
1097
1104void fuse_loop_cfg_convert(struct fuse_loop_config *config,
1105 struct fuse_loop_config_v1 *v1_conf);
1106#endif
1107
1115bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1116
1123void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1124
1132bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1133
1134/*
1135 * DO NOT USE: Not part of public API, for internal test use only.
1136 * The function signature or any use of it is not guaranteeed to
1137 * remain stable. And neither are results of what this function does.
1138 */
1140
1141
1142
1143/* ----------------------------------------------------------- *
1144 * Compatibility stuff *
1145 * ----------------------------------------------------------- */
1146
1147#if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
1148# error only API version 30 or greater is supported
1149#endif
1150
1151#ifdef __cplusplus
1152}
1153#endif
1154
1155
1156/*
1157 * This interface uses 64 bit off_t.
1158 *
1159 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
1160 */
1161
1162#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
1163_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
1164#else
1165struct _fuse_off_t_must_be_64bit_dummy_struct \
1166 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
1167#endif
1168
1169#endif /* FUSE_COMMON_H_ */
void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
int fuse_convert_to_conn_want_ext(struct fuse_conn_info *conn)
int fuse_set_fail_signal_handlers(struct fuse_session *se)
bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
int fuse_set_signal_handlers(struct fuse_session *se)
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition buffer.c:22
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
Definition helper.c:422
fuse_buf_flags
@ FUSE_BUF_FD_SEEK
@ FUSE_BUF_FD_RETRY
@ FUSE_BUF_IS_FD
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition buffer.c:284
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition helper.c:476
bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
const char * fuse_pkgversion(void)
Definition fuse.c:5274
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition fuse.c:5269
void fuse_remove_signal_handlers(struct fuse_session *se)
fuse_buf_copy_flags
@ FUSE_BUF_SPLICE_NONBLOCK
@ FUSE_BUF_FORCE_SPLICE
@ FUSE_BUF_NO_SPLICE
@ FUSE_BUF_SPLICE_MOVE
int fuse_daemonize(int foreground)
Definition helper.c:253
enum fuse_buf_flags flags
size_t mem_size
void * mem
off_t pos
size_t size
struct fuse_buf buf[1]
uint32_t time_gran
uint16_t request_timeout
uint32_t proto_major
uint32_t congestion_threshold
uint32_t proto_minor
uint32_t max_write
uint64_t capable_ext
uint32_t max_readahead
uint32_t no_interrupt
uint32_t max_read
uint32_t max_background
uint32_t capable
uint64_t want_ext
uint16_t reserved[31]
uint64_t lock_owner
uint32_t kill_suidgid
uint32_t writepage
Definition fuse_common.h:60
uint32_t poll_events
uint32_t cache_readdir
Definition fuse_common.h:89
uint32_t nonseekable
Definition fuse_common.h:78
int32_t backing_id
uint32_t parallel_direct_writes
Definition fuse_common.h:97
uint32_t padding
uint32_t noflush
Definition fuse_common.h:93
uint64_t compat_flags
uint32_t flush
Definition fuse_common.h:74
uint32_t direct_io
Definition fuse_common.h:63
uint32_t keep_cache
Definition fuse_common.h:69
unsigned int max_idle_threads