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 16
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
38extern "C" {
39#endif
40
52 int flags;
53
60 unsigned int writepage : 1;
61
63 unsigned int direct_io : 1;
64
69 unsigned int keep_cache : 1;
70
73 unsigned int parallel_direct_writes : 1;
74
78 unsigned int flush : 1;
79
82 unsigned int nonseekable : 1;
83
84 /* Indicates that flock locks for this file should be
85 released. If set, lock_owner shall contain a valid value.
86 May only be set in ->release(). */
87 unsigned int flock_release : 1;
88
93 unsigned int cache_readdir : 1;
94
97 unsigned int noflush : 1;
98
100 unsigned int padding : 23;
101 unsigned int padding2 : 32;
102
106 uint64_t fh;
107
109 uint64_t lock_owner;
110
113 uint32_t poll_events;
114};
115
116
117
124#if FUSE_USE_VERSION < FUSE_MAKE_VERSION(3, 12)
125struct fuse_loop_config_v1; /* forward declarition */
127#else
128struct fuse_loop_config_v1 {
129#endif
135
146 unsigned int max_idle_threads;
147};
148
149
150/**************************************************************************
151 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
152 **************************************************************************/
153
164#define FUSE_CAP_ASYNC_READ (1 << 0)
165
172#define FUSE_CAP_POSIX_LOCKS (1 << 1)
173
181#define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
182
188#define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
189
196#define FUSE_CAP_DONT_MASK (1 << 6)
197
204#define FUSE_CAP_SPLICE_WRITE (1 << 7)
205
212#define FUSE_CAP_SPLICE_MOVE (1 << 8)
213
221#define FUSE_CAP_SPLICE_READ (1 << 9)
222
234#define FUSE_CAP_FLOCK_LOCKS (1 << 10)
235
241#define FUSE_CAP_IOCTL_DIR (1 << 11)
242
263#define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
264
271#define FUSE_CAP_READDIRPLUS (1 << 13)
272
299#define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
300
310#define FUSE_CAP_ASYNC_DIO (1 << 15)
311
319#define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
320
332#define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
333
342#define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
343
361#define FUSE_CAP_POSIX_ACL (1 << 19)
362
370#define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
371
383#define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
384
395#define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
396
418#define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
419
434#define FUSE_CAP_EXPIRE_ONLY (1 << 26)
435
441#define FUSE_CAP_SETXATTR_EXT (1 << 27)
442
453#define FUSE_IOCTL_COMPAT (1 << 0)
454#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
455#define FUSE_IOCTL_RETRY (1 << 2)
456#define FUSE_IOCTL_DIR (1 << 4)
457
458#define FUSE_IOCTL_MAX_IOV 256
459
471 unsigned proto_major;
472
476 unsigned proto_minor;
477
481 unsigned max_write;
482
495 unsigned max_read;
496
501
505 unsigned capable;
506
513 unsigned want;
514
544
554
570 unsigned time_gran;
571
575 unsigned reserved[22];
576};
577
578struct fuse_session;
579struct fuse_pollhandle;
580struct fuse_conn_info_opts;
581
624struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
625
633void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
634 struct fuse_conn_info *conn);
635
642int fuse_daemonize(int foreground);
643
649int fuse_version(void);
650
656const char *fuse_pkgversion(void);
657
663void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
664
665/* ----------------------------------------------------------- *
666 * Data buffer *
667 * ----------------------------------------------------------- */
668
679 FUSE_BUF_IS_FD = (1 << 1),
680
689
697 FUSE_BUF_FD_RETRY = (1 << 3)
699
714
722
731
741
748struct fuse_buf {
752 size_t size;
753
758
764 void *mem;
765
771 int fd;
772
778 off_t pos;
779};
780
793 size_t count;
794
798 size_t idx;
799
803 size_t off;
804
808 struct fuse_buf buf[1];
809};
810
811/* Initialize bufvec with a single buffer of given size */
812#define FUSE_BUFVEC_INIT(size__) \
813 ((struct fuse_bufvec) { \
814 /* .count= */ 1, \
815 /* .idx = */ 0, \
816 /* .off = */ 0, \
817 /* .buf = */ { /* [0] = */ { \
818 /* .size = */ (size__), \
819 /* .flags = */ (enum fuse_buf_flags) 0, \
820 /* .mem = */ NULL, \
821 /* .fd = */ -1, \
822 /* .pos = */ 0, \
823 } } \
824 } )
825
832size_t fuse_buf_size(const struct fuse_bufvec *bufv);
833
842ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
844
845/* ----------------------------------------------------------- *
846 * Signal handling *
847 * ----------------------------------------------------------- */
848
864int fuse_set_signal_handlers(struct fuse_session *se);
865
877void fuse_remove_signal_handlers(struct fuse_session *se);
878
885
889void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
890
895 unsigned int value);
896
901 unsigned int value);
902
907 unsigned int value);
908
915void fuse_loop_cfg_convert(struct fuse_loop_config *config,
916 struct fuse_loop_config_v1 *v1_conf);
917
918/* ----------------------------------------------------------- *
919 * Compatibility stuff *
920 * ----------------------------------------------------------- */
921
922#if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
923# error only API version 30 or greater is supported
924#endif
925
926#ifdef __cplusplus
927}
928#endif
929
930
931/*
932 * This interface uses 64 bit off_t.
933 *
934 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
935 */
936
937#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
938_Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
939#else
940struct _fuse_off_t_must_be_64bit_dummy_struct \
941 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
942#endif
943
944#endif /* FUSE_COMMON_H_ */
void fuse_loop_cfg_convert(struct fuse_loop_config *config, struct fuse_loop_config_v1 *v1_conf)
Definition: fuse_loop_mt.c:454
void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:462
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
struct fuse_loop_config * fuse_loop_cfg_create(void)
Definition: fuse_loop_mt.c:427
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:398
fuse_buf_flags
Definition: fuse_common.h:672
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:688
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:697
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:679
void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:482
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:445
void fuse_loop_cfg_destroy(struct fuse_loop_config *config)
Definition: fuse_loop_mt.c:441
const char * fuse_pkgversion(void)
Definition: fuse.c:5124
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition: fuse.c:5119
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
Definition: fuse_common.h:703
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:739
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:721
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:713
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:730
int fuse_daemonize(int foreground)
Definition: helper.c:253
void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:476
enum fuse_buf_flags flags
Definition: fuse_common.h:757
void * mem
Definition: fuse_common.h:764
off_t pos
Definition: fuse_common.h:778
size_t size
Definition: fuse_common.h:752
size_t off
Definition: fuse_common.h:803
size_t idx
Definition: fuse_common.h:798
size_t count
Definition: fuse_common.h:793
unsigned time_gran
Definition: fuse_common.h:570
unsigned congestion_threshold
Definition: fuse_common.h:553
unsigned max_background
Definition: fuse_common.h:543
unsigned proto_major
Definition: fuse_common.h:471
unsigned max_read
Definition: fuse_common.h:495
unsigned proto_minor
Definition: fuse_common.h:476
unsigned capable
Definition: fuse_common.h:505
unsigned max_readahead
Definition: fuse_common.h:500
unsigned max_write
Definition: fuse_common.h:481
unsigned want
Definition: fuse_common.h:513
unsigned int direct_io
Definition: fuse_common.h:63
unsigned int keep_cache
Definition: fuse_common.h:69
unsigned int nonseekable
Definition: fuse_common.h:82
uint64_t lock_owner
Definition: fuse_common.h:109
uint32_t poll_events
Definition: fuse_common.h:113
unsigned int noflush
Definition: fuse_common.h:97
unsigned int writepage
Definition: fuse_common.h:60
unsigned int flush
Definition: fuse_common.h:78
unsigned int padding
Definition: fuse_common.h:100
unsigned int parallel_direct_writes
Definition: fuse_common.h:73
unsigned int cache_readdir
Definition: fuse_common.h:93
unsigned int max_idle_threads
Definition: fuse_common.h:146