libfuse: 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#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
50 struct fuse_file_info {
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 */
126 struct fuse_loop_config {
127#else
128struct fuse_loop_config_v1 {
129#endif
134 int clone_fd;
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
467 struct fuse_conn_info {
471 unsigned proto_major;
472
476 unsigned proto_minor;
477
481 unsigned max_write;
482
495 unsigned max_read;
496
500 unsigned max_readahead;
501
505 unsigned capable;
506
513 unsigned want;
514
543 unsigned max_background;
544
553 unsigned congestion_threshold;
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
672 enum fuse_buf_flags {
679 FUSE_BUF_IS_FD = (1 << 1),
680
688 FUSE_BUF_FD_SEEK = (1 << 2),
689
697 FUSE_BUF_FD_RETRY = (1 << 3)
698};
699
703 enum fuse_buf_copy_flags {
713 FUSE_BUF_NO_SPLICE = (1 << 1),
714
721 FUSE_BUF_FORCE_SPLICE = (1 << 2),
722
730 FUSE_BUF_SPLICE_MOVE = (1 << 3),
731
739 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
740};
741
748 struct fuse_buf {
752 size_t size;
753
757 enum fuse_buf_flags flags;
758
764 void *mem;
765
771 int fd;
772
778 off_t pos;
779};
780
789 struct fuse_bufvec {
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,
843 enum fuse_buf_copy_flags flags);
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
884struct fuse_loop_config *fuse_loop_cfg_create(void);
885
889void fuse_loop_cfg_destroy(struct fuse_loop_config *config);
890
894void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config,
895 unsigned int value);
896
900void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config,
901 unsigned int value);
902
906void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config,
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_ */
fuse_loop_cfg_convert
void fuse_loop_cfg_convert(struct fuse_loop_config *config, struct fuse_loop_config_v1 *v1_conf)
Definition: fuse_loop_mt.c:454
fuse_loop_cfg_set_idle_threads
void fuse_loop_cfg_set_idle_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:462
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
fuse_loop_cfg_create
struct fuse_loop_config * fuse_loop_cfg_create(void)
Definition: fuse_loop_mt.c:427
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:398
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:672
FUSE_BUF_FD_SEEK
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:688
FUSE_BUF_FD_RETRY
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:697
FUSE_BUF_IS_FD
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:679
fuse_loop_cfg_set_clone_fd
void fuse_loop_cfg_set_clone_fd(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:482
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:445
fuse_loop_cfg_destroy
void fuse_loop_cfg_destroy(struct fuse_loop_config *config)
Definition: fuse_loop_mt.c:441
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5124
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1845
fuse_version
int fuse_version(void)
Definition: fuse.c:5119
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:703
FUSE_BUF_SPLICE_NONBLOCK
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:739
FUSE_BUF_FORCE_SPLICE
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:721
FUSE_BUF_NO_SPLICE
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:713
FUSE_BUF_SPLICE_MOVE
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:730
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:253
fuse_loop_cfg_set_max_threads
void fuse_loop_cfg_set_max_threads(struct fuse_loop_config *config, unsigned int value)
Definition: fuse_loop_mt.c:476
fuse_log.h
fuse_opt.h
fuse_args
Definition: fuse_opt.h:109
fuse_buf
Definition: fuse_common.h:748
fuse_buf::flags
enum fuse_buf_flags flags
Definition: fuse_common.h:757
fuse_buf::mem
void * mem
Definition: fuse_common.h:764
fuse_buf::fd
int fd
Definition: fuse_common.h:771
fuse_buf::pos
off_t pos
Definition: fuse_common.h:778
fuse_buf::size
size_t size
Definition: fuse_common.h:752
fuse_bufvec
Definition: fuse_common.h:789
fuse_bufvec::off
size_t off
Definition: fuse_common.h:803
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:798
fuse_bufvec::count
size_t count
Definition: fuse_common.h:793
fuse_conn_info
Definition: fuse_common.h:467
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:570
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:553
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:543
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:471
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:495
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:476
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:505
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:500
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:481
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:513
fuse_file_info
Definition: fuse_common.h:50
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:63
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:69
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:82
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:109
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:106
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:113
fuse_file_info::noflush
unsigned int noflush
Definition: fuse_common.h:97
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:60
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:78
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:100
fuse_file_info::parallel_direct_writes
unsigned int parallel_direct_writes
Definition: fuse_common.h:73
fuse_file_info::flags
int flags
Definition: fuse_common.h:52
fuse_file_info::cache_readdir
unsigned int cache_readdir
Definition: fuse_common.h:93
fuse_loop_config
Definition: fuse_common.h:126
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:134
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:146