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 HAVE_STATIC_ASSERT
34#define fuse_static_assert(condition, message) static_assert(condition, message)
35#else
36#define fuse_static_assert(condition, message)
37#endif
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
58 int32_t flags;
59
66 uint32_t writepage : 1;
67
69 uint32_t direct_io : 1;
70
75 uint32_t keep_cache : 1;
76
80 uint32_t flush : 1;
81
84 uint32_t nonseekable : 1;
85
86 /* Indicates that flock locks for this file should be
87 released. If set, lock_owner shall contain a valid value.
88 May only be set in ->release(). */
89 uint32_t flock_release : 1;
90
95 uint32_t cache_readdir : 1;
96
99 uint32_t noflush : 1;
100
104
106 uint32_t padding : 23;
107 uint32_t padding2 : 32;
108 uint32_t padding3 : 32;
109
113 uint64_t fh;
114
116 uint64_t lock_owner;
117
120 uint32_t poll_events;
121
125 int32_t backing_id;
126
128 uint64_t compat_flags;
129
130 uint64_t reserved[2];
131};
132fuse_static_assert(sizeof(struct fuse_file_info) == 64,
133 "fuse_file_info size mismatch");
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 (1 << 0)
186
193#define FUSE_CAP_POSIX_LOCKS (1 << 1)
194
202#define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
203
214#define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
215
222#define FUSE_CAP_DONT_MASK (1 << 6)
223
230#define FUSE_CAP_SPLICE_WRITE (1 << 7)
231
238#define FUSE_CAP_SPLICE_MOVE (1 << 8)
239
247#define FUSE_CAP_SPLICE_READ (1 << 9)
248
260#define FUSE_CAP_FLOCK_LOCKS (1 << 10)
261
267#define FUSE_CAP_IOCTL_DIR (1 << 11)
268
289#define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
290
297#define FUSE_CAP_READDIRPLUS (1 << 13)
298
325#define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
326
336#define FUSE_CAP_ASYNC_DIO (1 << 15)
337
345#define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
346
360#define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
361
368#define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
369
387#define FUSE_CAP_POSIX_ACL (1 << 19)
388
396#define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
397
413#define FUSE_CAP_HANDLE_KILLPRIV_V2 (1 << 21)
414
426#define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
427
441#define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
442
464#define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
465
480#define FUSE_CAP_EXPIRE_ONLY (1 << 26)
481
487#define FUSE_CAP_SETXATTR_EXT (1 << 27)
488
496#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP (1 << 28)
497
508#define FUSE_CAP_PASSTHROUGH (1 << 29)
509
516#define FUSE_CAP_NO_EXPORT_SUPPORT (1 << 30)
517
528#define FUSE_IOCTL_COMPAT (1 << 0)
529#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
530#define FUSE_IOCTL_RETRY (1 << 2)
531#define FUSE_IOCTL_DIR (1 << 4)
532
533#define FUSE_IOCTL_MAX_IOV 256
534
550 uint32_t proto_major;
551
555 uint32_t proto_minor;
556
560 uint32_t max_write;
561
574 uint32_t max_read;
575
580
586 uint32_t capable;
587
598 uint32_t want;
599
629
639
655 uint32_t time_gran;
656
673#define FUSE_BACKING_STACKED_UNDER (0)
674#define FUSE_BACKING_STACKED_OVER (1)
675 uint32_t max_backing_stack_depth;
676
685 uint32_t no_interrupt : 1;
686
687 /* reserved bits for future use */
688 uint32_t padding : 31;
689
694 uint64_t capable_ext;
695
704 uint64_t want_ext;
705
709 uint32_t reserved[16];
710};
711fuse_static_assert(sizeof(struct fuse_conn_info) == 128,
712 "Size of struct fuse_conn_info must be 128 bytes");
713
714struct fuse_session;
715struct fuse_pollhandle;
716struct fuse_conn_info_opts;
717
760struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
761
769void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
770 struct fuse_conn_info *conn);
771
778int fuse_daemonize(int foreground);
779
785int fuse_version(void);
786
792const char *fuse_pkgversion(void);
793
799void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
800
801/* ----------------------------------------------------------- *
802 * Data buffer *
803 * ----------------------------------------------------------- */
804
815 FUSE_BUF_IS_FD = (1 << 1),
816
825
833 FUSE_BUF_FD_RETRY = (1 << 3)
835
877
884struct fuse_buf {
888 size_t size;
889
894
900 void *mem;
901
907 int fd;
908
914 off_t pos;
915
922 size_t mem_size;
923};
924
937 size_t count;
938
942 size_t idx;
943
947 size_t off;
948
952 struct fuse_buf buf[1];
953};
954
960{
961 uint32_t major;
962 uint32_t minor;
963 uint32_t hotfix;
964 uint32_t padding;
965};
966
967/* Initialize bufvec with a single buffer of given size */
968#define FUSE_BUFVEC_INIT(size__) \
969 ((struct fuse_bufvec) { \
970 /* .count= */ 1, \
971 /* .idx = */ 0, \
972 /* .off = */ 0, \
973 /* .buf = */ { /* [0] = */ { \
974 /* .size = */ (size__), \
975 /* .flags = */ (enum fuse_buf_flags) 0, \
976 /* .mem = */ NULL, \
977 /* .fd = */ -1, \
978 /* .pos = */ 0, \
979 /* .mem_size = */ 0, \
980 } } \
981 } )
982
989size_t fuse_buf_size(const struct fuse_bufvec *bufv);
990
999ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
1000 enum fuse_buf_copy_flags flags);
1001
1002/* ----------------------------------------------------------- *
1003 * Signal handling *
1004 * ----------------------------------------------------------- */
1005
1021int fuse_set_signal_handlers(struct fuse_session *se);
1022
1038int fuse_set_fail_signal_handlers(struct fuse_session *se);
1039
1051void fuse_remove_signal_handlers(struct fuse_session *se);
1052
1058#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
1064struct fuse_loop_config *fuse_loop_cfg_create(void);
1065
1069void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
1070
1074void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
1075 unsigned int value);
1076
1080void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
1081 unsigned int value);
1082
1086void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
1087 unsigned int value);
1088
1095void fuse_loop_cfg_convert(struct fuse_loop_config *config,
1096 struct fuse_loop_config_v1 *v1_conf);
1097#endif
1098
1106bool fuse_set_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1107
1114void fuse_unset_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1115
1123bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag);
1124
1125/*
1126 * DO NOT USE: Not part of public API, for internal test use only.
1127 * The function signature or any use of it is not guaranteeed to
1128 * remain stable. And neither are results of what this function does.
1129 */
1131
1132
1133
1134/* ----------------------------------------------------------- *
1135 * Compatibility stuff *
1136 * ----------------------------------------------------------- */
1137
1138#if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
1139# error only API version 30 or greater is supported
1140#endif
1141
1142#ifdef __cplusplus
1143}
1144#endif
1145
1146
1147/*
1148 * This interface uses 64 bit off_t.
1149 *
1150 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
1151 */
1152
1153#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
1154_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
1155#else
1156struct _fuse_off_t_must_be_64bit_dummy_struct \
1157 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
1158#endif
1159
1160#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:412
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:466
bool fuse_get_feature_flag(struct fuse_conn_info *conn, uint64_t flag)
const char * fuse_pkgversion(void)
Definition fuse.c:5211
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition fuse.c:5206
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
uint32_t time_gran
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
uint64_t lock_owner
uint32_t writepage
Definition fuse_common.h:66
uint32_t poll_events
uint32_t cache_readdir
Definition fuse_common.h:95
uint32_t nonseekable
Definition fuse_common.h:84
int32_t backing_id
uint32_t parallel_direct_writes
uint32_t padding
uint32_t noflush
Definition fuse_common.h:99
uint64_t compat_flags
uint32_t flush
Definition fuse_common.h:80
uint32_t direct_io
Definition fuse_common.h:69
uint32_t keep_cache
Definition fuse_common.h:75
unsigned int max_idle_threads