libfuse: fuse-3.11.0/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 #include "fuse_opt.h"
18 #include "fuse_log.h"
19 #include <stdint.h>
20 #include <sys/types.h>
21
23 #define FUSE_MAJOR_VERSION 3
24
26 #define FUSE_MINOR_VERSION 11
27
28 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 100 + (min))
29 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
44 struct fuse_file_info {
46 int flags;
47
54 unsigned int writepage : 1;
55
57 unsigned int direct_io : 1;
58
64 unsigned int keep_cache : 1;
65
69 unsigned int flush : 1;
70
73 unsigned int nonseekable : 1;
74
75 /* Indicates that flock locks for this file should be
76 released. If set, lock_owner shall contain a valid value.
77 May only be set in ->release(). */
78 unsigned int flock_release : 1;
79
84 unsigned int cache_readdir : 1;
85
88 unsigned int noflush : 1;
89
91 unsigned int padding : 24;
92 unsigned int padding2 : 32;
93
97 uint64_t fh;
98
100 uint64_t lock_owner;
101
104 uint32_t poll_events;
105 };
106
111 struct fuse_loop_config {
116 int clone_fd;
117
128 unsigned int max_idle_threads;
129 };
130
131 /**************************************************************************
132 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
133 **************************************************************************/
134
145 #define FUSE_CAP_ASYNC_READ (1 << 0)
146
153 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
154
162 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
163
169 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
170
177 #define FUSE_CAP_DONT_MASK (1 << 6)
178
185 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
186
193 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
194
202 #define FUSE_CAP_SPLICE_READ (1 << 9)
203
215 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
216
222 #define FUSE_CAP_IOCTL_DIR (1 << 11)
223
244 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
245
252 #define FUSE_CAP_READDIRPLUS (1 << 13)
253
280 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
281
291 #define FUSE_CAP_ASYNC_DIO (1 << 15)
292
300 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
301
313 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
314
323 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
324
342 #define FUSE_CAP_POSIX_ACL (1 << 19)
343
351 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
352
364 #define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
365
376 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
377
399 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
400
411 #define FUSE_IOCTL_COMPAT (1 << 0)
412 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
413 #define FUSE_IOCTL_RETRY (1 << 2)
414 #define FUSE_IOCTL_DIR (1 << 4)
415
416 #define FUSE_IOCTL_MAX_IOV 256
417
425 struct fuse_conn_info {
429 unsigned proto_major;
430
434 unsigned proto_minor;
435
439 unsigned max_write;
440
453 unsigned max_read;
454
458 unsigned max_readahead;
459
463 unsigned capable;
464
471 unsigned want;
472
501 unsigned max_background;
502
511 unsigned congestion_threshold;
512
528 unsigned time_gran;
529
533 unsigned reserved[22];
534 };
535
536 struct fuse_session;
537 struct fuse_pollhandle;
538 struct fuse_conn_info_opts;
539
582 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
583
591 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
592 struct fuse_conn_info *conn);
593
600 int fuse_daemonize(int foreground);
601
607 int fuse_version(void);
608
614 const char *fuse_pkgversion(void);
615
621 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
622
623 /* ----------------------------------------------------------- *
624 * Data buffer *
625 * ----------------------------------------------------------- */
626
630 enum fuse_buf_flags {
637 FUSE_BUF_IS_FD = (1 << 1),
638
646 FUSE_BUF_FD_SEEK = (1 << 2),
647
655 FUSE_BUF_FD_RETRY = (1 << 3)
656 };
657
661 enum fuse_buf_copy_flags {
671 FUSE_BUF_NO_SPLICE = (1 << 1),
672
679 FUSE_BUF_FORCE_SPLICE = (1 << 2),
680
688 FUSE_BUF_SPLICE_MOVE = (1 << 3),
689
697 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
698 };
699
706 struct fuse_buf {
710 size_t size;
711
715 enum fuse_buf_flags flags;
716
722 void *mem;
723
729 int fd;
730
736 off_t pos;
737 };
738
747 struct fuse_bufvec {
751 size_t count;
752
756 size_t idx;
757
761 size_t off;
762
766 struct fuse_buf buf[1];
767 };
768
769 /* Initialize bufvec with a single buffer of given size */
770 #define FUSE_BUFVEC_INIT(size__) \
771 ((struct fuse_bufvec) { \
772 /* .count= */ 1, \
773 /* .idx = */ 0, \
774 /* .off = */ 0, \
775 /* .buf = */ { /* [0] = */ { \
776 /* .size = */ (size__), \
777 /* .flags = */ (enum fuse_buf_flags) 0, \
778 /* .mem = */ NULL, \
779 /* .fd = */ -1, \
780 /* .pos = */ 0, \
781 } } \
782 } )
783
790 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
791
800 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
801 enum fuse_buf_copy_flags flags);
802
803 /* ----------------------------------------------------------- *
804 * Signal handling *
805 * ----------------------------------------------------------- */
806
822 int fuse_set_signal_handlers(struct fuse_session *se);
823
835 void fuse_remove_signal_handlers(struct fuse_session *se);
836
837 /* ----------------------------------------------------------- *
838 * Compatibility stuff *
839 * ----------------------------------------------------------- */
840
841 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
842 # error only API version 30 or greater is supported
843 #endif
844
845 #ifdef __cplusplus
846 }
847 #endif
848
849
850 /*
851 * This interface uses 64 bit off_t.
852 *
853 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
854 */
855
856 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
857 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
858 #else
859 struct _fuse_off_t_must_be_64bit_dummy_struct \
860 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
861 #endif
862
863 #endif /* FUSE_COMMON_H_ */
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
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:361
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:626
FUSE_BUF_FD_SEEK
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:642
FUSE_BUF_FD_RETRY
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:651
FUSE_BUF_IS_FD
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:633
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_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5122
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1809
fuse_version
int fuse_version(void)
Definition: fuse.c:5117
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:657
FUSE_BUF_SPLICE_NONBLOCK
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:693
FUSE_BUF_FORCE_SPLICE
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:675
FUSE_BUF_NO_SPLICE
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:667
FUSE_BUF_SPLICE_MOVE
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:684
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:225
fuse_parse_conn_info_opts
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
fuse_log.h
fuse_opt.h
fuse_args
Definition: fuse_opt.h:109
fuse_buf
Definition: fuse_common.h:702
fuse_buf::flags
enum fuse_buf_flags flags
Definition: fuse_common.h:711
fuse_buf::fd
int fd
Definition: fuse_common.h:725
fuse_buf::pos
off_t pos
Definition: fuse_common.h:732
fuse_buf::mem
void * mem
Definition: fuse_common.h:718
fuse_buf::size
size_t size
Definition: fuse_common.h:706
fuse_bufvec
Definition: fuse_common.h:743
fuse_bufvec::off
size_t off
Definition: fuse_common.h:757
fuse_bufvec::buf
struct fuse_buf buf[1]
Definition: fuse_common.h:762
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:752
fuse_bufvec::count
size_t count
Definition: fuse_common.h:747
fuse_conn_info
Definition: fuse_common.h:421
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:524
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:507
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:497
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:425
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:449
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:430
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:459
fuse_conn_info::reserved
unsigned reserved[22]
Definition: fuse_common.h:529
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:454
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:435
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:467
fuse_file_info
Definition: fuse_common.h:44
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:57
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:64
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:73
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:96
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:93
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:100
fuse_file_info::noflush
unsigned int noflush
Definition: fuse_common.h:88
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:54
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:69
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:87
fuse_file_info::flags
int flags
Definition: fuse_common.h:46
fuse_file_info::cache_readdir
unsigned int cache_readdir
Definition: fuse_common.h:84
fuse_loop_config
Definition: fuse_common.h:107
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:112
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:124