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 2
27
28 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (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
87 unsigned int padding : 25;
88 unsigned int padding2 : 32;
89
93 uint64_t fh;
94
96 uint64_t lock_owner;
97
100 uint32_t poll_events;
101 };
102
107 struct fuse_loop_config {
112 int clone_fd;
113
124 unsigned int max_idle_threads;
125 };
126
127 /**************************************************************************
128 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
129 **************************************************************************/
130
141 #define FUSE_CAP_ASYNC_READ (1 << 0)
142
149 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
150
158 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
159
165 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
166
173 #define FUSE_CAP_DONT_MASK (1 << 6)
174
181 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
182
189 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
190
198 #define FUSE_CAP_SPLICE_READ (1 << 9)
199
211 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
212
218 #define FUSE_CAP_IOCTL_DIR (1 << 11)
219
240 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
241
248 #define FUSE_CAP_READDIRPLUS (1 << 13)
249
276 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
277
287 #define FUSE_CAP_ASYNC_DIO (1 << 15)
288
296 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
297
309 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
310
319 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
320
338 #define FUSE_CAP_POSIX_ACL (1 << 19)
339
347 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
348
359 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
360
382 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
383
394 #define FUSE_IOCTL_COMPAT (1 << 0)
395 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
396 #define FUSE_IOCTL_RETRY (1 << 2)
397 #define FUSE_IOCTL_DIR (1 << 4)
398
399 #define FUSE_IOCTL_MAX_IOV 256
400
408 struct fuse_conn_info {
412 unsigned proto_major;
413
417 unsigned proto_minor;
418
422 unsigned max_write;
423
436 unsigned max_read;
437
441 unsigned max_readahead;
442
446 unsigned capable;
447
454 unsigned want;
455
484 unsigned max_background;
485
494 unsigned congestion_threshold;
495
511 unsigned time_gran;
512
516 unsigned reserved[22];
517 };
518
519 struct fuse_session;
520 struct fuse_pollhandle;
521 struct fuse_conn_info_opts;
522
565 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
566
574 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
575 struct fuse_conn_info *conn);
576
583 int fuse_daemonize(int foreground);
584
590 int fuse_version(void);
591
597 const char *fuse_pkgversion(void);
598
604 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
605
606 /* ----------------------------------------------------------- *
607 * Data buffer *
608 * ----------------------------------------------------------- */
609
613 enum fuse_buf_flags {
620 FUSE_BUF_IS_FD = (1 << 1),
621
629 FUSE_BUF_FD_SEEK = (1 << 2),
630
638 FUSE_BUF_FD_RETRY = (1 << 3),
639 };
640
644 enum fuse_buf_copy_flags {
654 FUSE_BUF_NO_SPLICE = (1 << 1),
655
662 FUSE_BUF_FORCE_SPLICE = (1 << 2),
663
671 FUSE_BUF_SPLICE_MOVE = (1 << 3),
672
680 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4),
681 };
682
689 struct fuse_buf {
693 size_t size;
694
698 enum fuse_buf_flags flags;
699
705 void *mem;
706
712 int fd;
713
719 off_t pos;
720 };
721
730 struct fuse_bufvec {
734 size_t count;
735
739 size_t idx;
740
744 size_t off;
745
749 struct fuse_buf buf[1];
750 };
751
752 /* Initialize bufvec with a single buffer of given size */
753 #define FUSE_BUFVEC_INIT(size__) \
754 ((struct fuse_bufvec) { \
755 /* .count= */ 1, \
756 /* .idx = */ 0, \
757 /* .off = */ 0, \
758 /* .buf = */ { /* [0] = */ { \
759 /* .size = */ (size__), \
760 /* .flags = */ (enum fuse_buf_flags) 0, \
761 /* .mem = */ NULL, \
762 /* .fd = */ -1, \
763 /* .pos = */ 0, \
764 } } \
765 } )
766
773 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
774
783 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
784 enum fuse_buf_copy_flags flags);
785
786 /* ----------------------------------------------------------- *
787 * Signal handling *
788 * ----------------------------------------------------------- */
789
805 int fuse_set_signal_handlers(struct fuse_session *se);
806
818 void fuse_remove_signal_handlers(struct fuse_session *se);
819
820 /* ----------------------------------------------------------- *
821 * Compatibility stuff *
822 * ----------------------------------------------------------- */
823
824 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
825 # error only API version 30 or greater is supported
826 #endif
827
828 #ifdef __cplusplus
829 }
830 #endif
831
832
833 /*
834 * This interface uses 64 bit off_t.
835 *
836 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
837 */
838
839 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
840 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
841 #else
842 struct _fuse_off_t_must_be_64bit_dummy_struct \
843 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
844 #endif
845
846 #endif /* FUSE_COMMON_H_ */
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:93
fuse_conn_info
Definition: fuse_common.h:385
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:54
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:57
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:100
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:64
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:96
FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:639
fuse_file_info
Definition: fuse_common.h:44
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:621
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5117
fuse_version
int fuse_version(void)
Definition: fuse.c:5112
fuse_file_info::flags
int flags
Definition: fuse_common.h:46
fuse_bufvec
Definition: fuse_common.h:707
fuse_loop_config
Definition: fuse_common.h:107
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:73
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:69
FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:657
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:281
FUSE_BUF_FD_SEEK
Definition: fuse_common.h:606
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1812
fuse_buf_size
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
fuse_log.h
fuse_opt.h
FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:648
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:225
fuse_file_info::cache_readdir
unsigned int cache_readdir
Definition: fuse_common.h:84
fuse_args
Definition: fuse_opt.h:109
fuse_parse_conn_info_opts
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
FUSE_BUF_FD_RETRY
Definition: fuse_common.h:615
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_NO_SPLICE
Definition: fuse_common.h:631
FUSE_BUF_IS_FD
Definition: fuse_common.h:597
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:87
fuse_buf
Definition: fuse_common.h:666
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:590