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 <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
37 struct fuse_file_info {
39 int flags;
40
43 unsigned int writepage : 1;
44
46 unsigned int direct_io : 1;
47
51 unsigned int keep_cache : 1;
52
56 unsigned int flush : 1;
57
60 unsigned int nonseekable : 1;
61
62 /* Indicates that flock locks for this file should be
63 released. If set, lock_owner shall contain a valid value.
64 May only be set in ->release(). */
65 unsigned int flock_release : 1;
66
68 unsigned int padding : 27;
69
72 uint64_t fh;
73
75 uint64_t lock_owner;
76
79 uint32_t poll_events;
80 };
81
86 struct fuse_loop_config {
91 int clone_fd;
92
103 unsigned int max_idle_threads;
104 };
105
106 /**************************************************************************
107 * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
108 **************************************************************************/
109
120 #define FUSE_CAP_ASYNC_READ (1 << 0)
121
128 #define FUSE_CAP_POSIX_LOCKS (1 << 1)
129
137 #define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
138
144 #define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
145
152 #define FUSE_CAP_DONT_MASK (1 << 6)
153
160 #define FUSE_CAP_SPLICE_WRITE (1 << 7)
161
168 #define FUSE_CAP_SPLICE_MOVE (1 << 8)
169
177 #define FUSE_CAP_SPLICE_READ (1 << 9)
178
190 #define FUSE_CAP_FLOCK_LOCKS (1 << 10)
191
197 #define FUSE_CAP_IOCTL_DIR (1 << 11)
198
219 #define FUSE_CAP_AUTO_INVAL_DATA (1 << 12)
220
227 #define FUSE_CAP_READDIRPLUS (1 << 13)
228
246 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
247
257 #define FUSE_CAP_ASYNC_DIO (1 << 15)
258
266 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
267
279 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
280
289 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
290
308 #define FUSE_CAP_POSIX_ACL (1 << 19)
309
317 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
318
329 #define FUSE_IOCTL_COMPAT (1 << 0)
330 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
331 #define FUSE_IOCTL_RETRY (1 << 2)
332 #define FUSE_IOCTL_DIR (1 << 4)
333
334 #define FUSE_IOCTL_MAX_IOV 256
335
343 struct fuse_conn_info {
347 unsigned proto_major;
348
352 unsigned proto_minor;
353
357 unsigned max_write;
358
371 unsigned max_read;
372
376 unsigned max_readahead;
377
381 unsigned capable;
382
389 unsigned want;
390
419 unsigned max_background;
420
429 unsigned congestion_threshold;
430
446 unsigned time_gran;
447
451 unsigned reserved[22];
452 };
453
454 struct fuse_session;
455 struct fuse_pollhandle;
456 struct fuse_conn_info_opts;
457
500 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
501
509 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
510 struct fuse_conn_info *conn);
511
518 int fuse_daemonize(int foreground);
519
525 int fuse_version(void);
526
532 const char *fuse_pkgversion(void);
533
539 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
540
541 /* ----------------------------------------------------------- *
542 * Data buffer *
543 * ----------------------------------------------------------- */
544
548 enum fuse_buf_flags {
555 FUSE_BUF_IS_FD = (1 << 1),
556
564 FUSE_BUF_FD_SEEK = (1 << 2),
565
573 FUSE_BUF_FD_RETRY = (1 << 3),
574 };
575
579 enum fuse_buf_copy_flags {
589 FUSE_BUF_NO_SPLICE = (1 << 1),
590
597 FUSE_BUF_FORCE_SPLICE = (1 << 2),
598
606 FUSE_BUF_SPLICE_MOVE = (1 << 3),
607
615 FUSE_BUF_SPLICE_NONBLOCK= (1 << 4),
616 };
617
624 struct fuse_buf {
628 size_t size;
629
633 enum fuse_buf_flags flags;
634
640 void *mem;
641
647 int fd;
648
654 off_t pos;
655 };
656
665 struct fuse_bufvec {
669 size_t count;
670
674 size_t idx;
675
679 size_t off;
680
684 struct fuse_buf buf[1];
685 };
686
687 /* Initialize bufvec with a single buffer of given size */
688 #define FUSE_BUFVEC_INIT(size__) \
689 ((struct fuse_bufvec) { \
690 /* .count= */ 1, \
691 /* .idx = */ 0, \
692 /* .off = */ 0, \
693 /* .buf = */ { /* [0] = */ { \
694 /* .size = */ (size__), \
695 /* .flags = */ (enum fuse_buf_flags) 0, \
696 /* .mem = */ NULL, \
697 /* .fd = */ -1, \
698 /* .pos = */ 0, \
699 } } \
700 } )
701
708 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
709
718 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
719 enum fuse_buf_copy_flags flags);
720
721 /* ----------------------------------------------------------- *
722 * Signal handling *
723 * ----------------------------------------------------------- */
724
740 int fuse_set_signal_handlers(struct fuse_session *se);
741
753 void fuse_remove_signal_handlers(struct fuse_session *se);
754
755 /* ----------------------------------------------------------- *
756 * Compatibility stuff *
757 * ----------------------------------------------------------- */
758
759 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
760 # error only API version 30 or greater is supported
761 #endif
762
763 #ifdef __cplusplus
764 }
765 #endif
766
767
768 /*
769 * This interface uses 64 bit off_t.
770 *
771 * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
772 */
773
774 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
775 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
776 #else
777 struct _fuse_off_t_must_be_64bit_dummy_struct \
778 { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
779 #endif
780
781 #endif /* FUSE_COMMON_H_ */
fuse_bufvec::off
size_t off
Definition: fuse_common.h:679
fuse_buf_flags
fuse_buf_flags
Definition: fuse_common.h:548
fuse_conn_info::capable
unsigned capable
Definition: fuse_common.h:381
fuse_file_info::fh
uint64_t fh
Definition: fuse_common.h:72
fuse_conn_info
Definition: fuse_common.h:343
fuse_file_info::writepage
unsigned int writepage
Definition: fuse_common.h:43
fuse_file_info::direct_io
unsigned int direct_io
Definition: fuse_common.h:46
FUSE_BUF_IS_FD
Definition: fuse_common.h:555
fuse_file_info::poll_events
uint32_t poll_events
Definition: fuse_common.h:79
fuse_daemonize
int fuse_daemonize(int foreground)
Definition: helper.c:225
fuse_conn_info::max_write
unsigned max_write
Definition: fuse_common.h:357
FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:597
fuse_conn_info::proto_minor
unsigned proto_minor
Definition: fuse_common.h:352
fuse_loop_config::max_idle_threads
unsigned int max_idle_threads
Definition: fuse_common.h:103
fuse_conn_info::max_background
unsigned max_background
Definition: fuse_common.h:419
FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:606
fuse_file_info::keep_cache
unsigned int keep_cache
Definition: fuse_common.h:51
fuse_file_info::lock_owner
uint64_t lock_owner
Definition: fuse_common.h:75
FUSE_BUF_FD_RETRY
Definition: fuse_common.h:573
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:654
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:37
fuse_version
int fuse_version(void)
Definition: fuse.c:5066
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:39
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:665
fuse_loop_config
Definition: fuse_common.h:86
fuse_bufvec::idx
size_t idx
Definition: fuse_common.h:674
fuse_bufvec::count
size_t count
Definition: fuse_common.h:669
fuse_opt.h
fuse_file_info::nonseekable
unsigned int nonseekable
Definition: fuse_common.h:60
fuse_conn_info::congestion_threshold
unsigned congestion_threshold
Definition: fuse_common.h:429
fuse_pollhandle_destroy
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
Definition: fuse_lowlevel.c:1766
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:56
fuse_conn_info::max_read
unsigned max_read
Definition: fuse_common.h:371
FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:589
fuse_conn_info::max_readahead
unsigned max_readahead
Definition: fuse_common.h:376
fuse_conn_info::proto_major
unsigned proto_major
Definition: fuse_common.h:347
fuse_buf::mem
void * mem
Definition: fuse_common.h:640
FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:615
fuse_conn_info::want
unsigned want
Definition: fuse_common.h:389
fuse_args
Definition: fuse_opt.h:109
fuse_pkgversion
const char * fuse_pkgversion(void)
Definition: fuse.c:5071
FUSE_BUF_FD_SEEK
Definition: fuse_common.h:564
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:628
fuse_buf_copy_flags
fuse_buf_copy_flags
Definition: fuse_common.h:579
fuse_buf::fd
int fd
Definition: fuse_common.h:647
fuse_loop_config::clone_fd
int clone_fd
Definition: fuse_common.h:91
fuse_file_info::padding
unsigned int padding
Definition: fuse_common.h:68
fuse_conn_info::time_gran
unsigned time_gran
Definition: fuse_common.h:446
fuse_buf
Definition: fuse_common.h:624