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 <stdint.h>
19 #include <sys/types.h>
20
22 #define FUSE_MAJOR_VERSION 3
23
25 #define FUSE_MINOR_VERSION 2
26
27 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (min))
28 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
43 struct fuse_file_info {
45 int flags;
46
53 unsigned int writepage : 1;
54
56 unsigned int direct_io : 1;
57
63 unsigned int keep_cache : 1;
64
68 unsigned int flush : 1;
69
72 unsigned int nonseekable : 1;
73
74 /* Indicates that flock locks for this file should be
75 released. If set, lock_owner shall contain a valid value.
76 May only be set in ->release(). */
77 unsigned int flock_release : 1;
78
83 unsigned int cache_readdir : 1;
84
86 unsigned int padding : 26;
87
91 uint64_t fh;
92
94 uint64_t lock_owner;
95
98 uint32_t poll_events;
99 };
100
105 struct fuse_loop_config {
110 int clone_fd;
111
122 unsigned int max_idle_threads;
123 };
124
125 /**************************************************************************
126 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
127 **************************************************************************/
128
139 #define FUSE_CAP_ASYNC_READ (1 << 0)
140
147 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
148
156 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
157
163 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
164
171 #define FUSE_CAP_DONT_MASK (1 << 6)
172
179 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
180
187 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
188
196 #define FUSE_CAP_SPLICE_READ (1 << 9)
197
209 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
210
216 #define FUSE_CAP_IOCTL_DIR (1 << 11)
217
238 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
239
246 #define FUSE_CAP_READDIRPLUS (1 << 13)
247
265 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
266
276 #define FUSE_CAP_ASYNC_DIO (1 << 15)
277
285 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
286
298 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
299
308 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
309
327 #define FUSE_CAP_POSIX_ACL (1 << 19)
328
336 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
337
348 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
349
360 #define FUSE_IOCTL_COMPAT (1 << 0)
361 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
362 #define FUSE_IOCTL_RETRY (1 << 2)
363 #define FUSE_IOCTL_DIR (1 << 4)
364
365 #define FUSE_IOCTL_MAX_IOV 256
366
374 struct fuse_conn_info {
378 unsigned proto_major;
379
383 unsigned proto_minor;
384
388 unsigned max_write;
389
402 unsigned max_read;
403
407 unsigned max_readahead;
408
412 unsigned capable;
413
420 unsigned want;
421
450 unsigned max_background;
451
460 unsigned congestion_threshold;
461
477 unsigned time_gran;
478
482 unsigned reserved[22];
483 };
484
485 struct fuse_session;
486 struct fuse_pollhandle;
487 struct fuse_conn_info_opts;
488
531 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
532
540 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
541 struct fuse_conn_info *conn);
542
549 int fuse_daemonize(int foreground);
550
556 int fuse_version(void);
557
563 const char *fuse_pkgversion(void);
564
570 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
571
572 /* ----------------------------------------------------------- *
573 * Data buffer *
574 * ----------------------------------------------------------- */
575
579 enum fuse_buf_flags {
586 FUSE_BUF_IS_FD = (1 << 1),
587
595 FUSE_BUF_FD_SEEK = (1 << 2),
596
604 FUSE_BUF_FD_RETRY = (1 << 3),
605 };
606
610 enum fuse_buf_copy_flags {
620 FUSE_BUF_NO_SPLICE = (1 << 1),
621
628 FUSE_BUF_FORCE_SPLICE = (1 << 2),
629
637 FUSE_BUF_SPLICE_MOVE = (1 << 3),
638
646 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4),
647 };
648
655 struct fuse_buf {
659 size_t size;
660
664 enum fuse_buf_flags flags;
665
671 void *mem;
672
678 int fd;
679
685 off_t pos;
686 };
687
696 struct fuse_bufvec {
700 size_t count;
701
705 size_t idx;
706
710 size_t off;
711
715 struct fuse_buf buf[1];
716 };
717
718 /* Initialize bufvec with a single buffer of given size */
719 #define FUSE_BUFVEC_INIT(size__) \
720 ((struct fuse_bufvec) { \
721 /* .count= */ 1, \
722 /* .idx = */ 0, \
723 /* .off = */ 0, \
724 /* .buf = */ { /* [0] = */ { \
725 /* .size = */ (size__), \
726 /* .flags = */ (enum fuse_buf_flags) 0, \
727 /* .mem = */ NULL, \
728 /* .fd = */ -1, \
729 /* .pos = */ 0, \
730 } } \
731 } )
732
739 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
740
749 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
750 enum fuse_buf_copy_flags flags);
751
752 /* ----------------------------------------------------------- *
753 * Signal handling *
754 * ----------------------------------------------------------- */
755
771 int fuse_set_signal_handlers(struct fuse_session *se);
772
784 void fuse_remove_signal_handlers(struct fuse_session *se);
785
786 /* ----------------------------------------------------------- *
787 * Compatibility stuff *
788 * ----------------------------------------------------------- */
789
790 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
791 # error only API version 30 or greater is supported
792 #endif
793
794 #ifdef __cplusplus
795 }
796 #endif
797
798
799 /*
800 * This interface uses 64 bit off_t.
801 *
802 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
803 */
804
805 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
806 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
807 #else
808 struct _fuse_off_t_must_be_64bit_dummy_struct \
809 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
810 #endif
811
812 #endif /* FUSE_COMMON_H_ */
fuse_bufvec::off
size_t off
Definition: fuse_common.h:710
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:412
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:91
fuse_conn_info
Definition: fuse_common.h:374
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:53
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:56
FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:628
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:98
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:388
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:579
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:383
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:610
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:122
FUSE_BUF_FD_RETRY
Definition: fuse_common.h:604
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:450
fuse_version
int fuse_version(void)
Definition: fuse.c:5068
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
FUSE_BUF_IS_FD
Definition: fuse_common.h:586
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:63
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5073
FUSE_BUF_FD_SEEK
Definition: fuse_common.h:595
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:94
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf::pos
off_t pos
Definition: fuse_common.h:685
fuse_buf_size
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
fuse_file_info
Definition: fuse_common.h:43
FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:646
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1770
fuse_file_info::flags
int flags
Definition: fuse_common.h:45
fuse_bufvec
Definition: fuse_common.h:696
fuse_loop_config
Definition: fuse_common.h:105
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:705
fuse_bufvec::count
size_t count
Definition: fuse_common.h:700
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:72
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:460
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:68
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_NO_SPLICE
Definition: fuse_common.h:620
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:402
fuse_opt.h
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:407
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:378
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_file_info::cache_readdir
unsigned int cache_readdir
Definition: fuse_common.h:83
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:420
fuse_buf::mem
void * mem
Definition: fuse_common.h:671
fuse_args
Definition: fuse_opt.h:109
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::size
size_t size
Definition: fuse_common.h:659
fuse_buf::fd
int fd
Definition: fuse_common.h:678
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:110
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:225
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:86
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:477
fuse_buf
Definition: fuse_common.h:655
FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:637