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 #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
371 #define FUSE_IOCTL_COMPAT (1 << 0)
372 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
373 #define FUSE_IOCTL_RETRY (1 << 2)
374 #define FUSE_IOCTL_DIR (1 << 4)
375
376 #define FUSE_IOCTL_MAX_IOV 256
377
385 struct fuse_conn_info {
389 unsigned proto_major;
390
394 unsigned proto_minor;
395
399 unsigned max_write;
400
413 unsigned max_read;
414
418 unsigned max_readahead;
419
423 unsigned capable;
424
431 unsigned want;
432
461 unsigned max_background;
462
471 unsigned congestion_threshold;
472
488 unsigned time_gran;
489
493 unsigned reserved[22];
494 };
495
496 struct fuse_session;
497 struct fuse_pollhandle;
498 struct fuse_conn_info_opts;
499
542 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
543
551 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
552 struct fuse_conn_info *conn);
553
560 int fuse_daemonize(int foreground);
561
567 int fuse_version(void);
568
574 const char *fuse_pkgversion(void);
575
581 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
582
583 /* ----------------------------------------------------------- *
584 * Data buffer *
585 * ----------------------------------------------------------- */
586
590 enum fuse_buf_flags {
597 FUSE_BUF_IS_FD = (1 << 1),
598
606 FUSE_BUF_FD_SEEK = (1 << 2),
607
615 FUSE_BUF_FD_RETRY = (1 << 3),
616 };
617
621 enum fuse_buf_copy_flags {
631 FUSE_BUF_NO_SPLICE = (1 << 1),
632
639 FUSE_BUF_FORCE_SPLICE = (1 << 2),
640
648 FUSE_BUF_SPLICE_MOVE = (1 << 3),
649
657 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4),
658 };
659
666 struct fuse_buf {
670 size_t size;
671
675 enum fuse_buf_flags flags;
676
682 void *mem;
683
689 int fd;
690
696 off_t pos;
697 };
698
707 struct fuse_bufvec {
711 size_t count;
712
716 size_t idx;
717
721 size_t off;
722
726 struct fuse_buf buf[1];
727 };
728
729 /* Initialize bufvec with a single buffer of given size */
730 #define FUSE_BUFVEC_INIT(size__) \
731 ((struct fuse_bufvec) { \
732 /* .count= */ 1, \
733 /* .idx = */ 0, \
734 /* .off = */ 0, \
735 /* .buf = */ { /* [0] = */ { \
736 /* .size = */ (size__), \
737 /* .flags = */ (enum fuse_buf_flags) 0, \
738 /* .mem = */ NULL, \
739 /* .fd = */ -1, \
740 /* .pos = */ 0, \
741 } } \
742 } )
743
750 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
751
760 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
761 enum fuse_buf_copy_flags flags);
762
763 /* ----------------------------------------------------------- *
764 * Signal handling *
765 * ----------------------------------------------------------- */
766
782 int fuse_set_signal_handlers(struct fuse_session *se);
783
795 void fuse_remove_signal_handlers(struct fuse_session *se);
796
797 /* ----------------------------------------------------------- *
798 * Compatibility stuff *
799 * ----------------------------------------------------------- */
800
801 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
802 # error only API version 30 or greater is supported
803 #endif
804
805 #ifdef __cplusplus
806 }
807 #endif
808
809
810 /*
811 * This interface uses 64 bit off_t.
812 *
813 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
814 */
815
816 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
817 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
818 #else
819 struct _fuse_off_t_must_be_64bit_dummy_struct \
820 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
821 #endif
822
823 #endif /* FUSE_COMMON_H_ */
fuse_bufvec::off
size_t off
Definition: fuse_common.h:721
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:590
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:423
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_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:57
FUSE_BUF_IS_FD
Definition: fuse_common.h:597
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:100
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:225
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:399
FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:639
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:394
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:124
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:461
FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:648
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_FD_RETRY
Definition: fuse_common.h:615
fuse_set_signal_handlers
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
fuse_buf::pos
off_t pos
Definition: fuse_common.h:696
fuse_remove_signal_handlers
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_file_info
Definition: fuse_common.h:44
fuse_version
int fuse_version(void)
Definition: fuse.c:5112
fuse_parse_conn_info_opts
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
fuse_file_info::flags
int flags
Definition: fuse_common.h:46
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_bufvec
Definition: fuse_common.h:707
fuse_loop_config
Definition: fuse_common.h:107
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:716
fuse_bufvec::count
size_t count
Definition: fuse_common.h:711
fuse_opt.h
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:73
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:471
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1812
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:69
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:413
FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:631
fuse_log.h
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:418
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:389
fuse_buf::mem
void * mem
Definition: fuse_common.h:682
fuse_file_info::cache_readdir
unsigned int cache_readdir
Definition: fuse_common.h:84
FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:657
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:431
fuse_args
Definition: fuse_opt.h:109
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5117
FUSE_BUF_FD_SEEK
Definition: fuse_common.h:606
fuse_buf_size
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
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:670
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:621
fuse_buf::fd
int fd
Definition: fuse_common.h:689
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:112
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:87
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:488
fuse_buf
Definition: fuse_common.h:666