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 
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 
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 
235 #define FUSE_CAP_READDIRPLUS_AUTO (1 << 14)
236 
246 #define FUSE_CAP_ASYNC_DIO (1 << 15)
247 
255 #define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
256 
268 #define FUSE_CAP_NO_OPEN_SUPPORT (1 << 17)
269 
278 #define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
279 
297 #define FUSE_CAP_POSIX_ACL (1 << 19)
298 
306 #define FUSE_CAP_HANDLE_KILLPRIV (1 << 20)
307 
318 #define FUSE_IOCTL_COMPAT (1 << 0)
319 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
320 #define FUSE_IOCTL_RETRY (1 << 2)
321 #define FUSE_IOCTL_DIR (1 << 4)
322 
323 #define FUSE_IOCTL_MAX_IOV 256
324 
336  unsigned proto_major;
337 
341  unsigned proto_minor;
342 
346  unsigned max_write;
347 
360  unsigned max_read;
361 
365  unsigned max_readahead;
366 
370  unsigned capable;
371 
378  unsigned want;
379 
408  unsigned max_background;
409 
419 
435  unsigned time_gran;
436 
440  unsigned reserved[22];
441 };
442 
443 struct fuse_session;
444 struct fuse_pollhandle;
445 struct fuse_conn_info_opts;
446 
489 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
490 
498 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
499  struct fuse_conn_info *conn);
500 
507 int fuse_daemonize(int foreground);
508 
514 int fuse_version(void);
515 
521 const char *fuse_pkgversion(void);
522 
528 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
529 
530 /* ----------------------------------------------------------- *
531  * Data buffer *
532  * ----------------------------------------------------------- */
533 
544  FUSE_BUF_IS_FD = (1 << 1),
545 
553  FUSE_BUF_FD_SEEK = (1 << 2),
554 
562  FUSE_BUF_FD_RETRY = (1 << 3),
563 };
564 
578  FUSE_BUF_NO_SPLICE = (1 << 1),
579 
587 
596 
605 };
606 
613 struct fuse_buf {
617  size_t size;
618 
623 
629  void *mem;
630 
636  int fd;
637 
643  off_t pos;
644 };
645 
654 struct fuse_bufvec {
658  size_t count;
659 
663  size_t idx;
664 
668  size_t off;
669 
673  struct fuse_buf buf[1];
674 };
675 
676 /* Initialize bufvec with a single buffer of given size */
677 #define FUSE_BUFVEC_INIT(size__) \
678  ((struct fuse_bufvec) { \
679  /* .count= */ 1, \
680  /* .idx = */ 0, \
681  /* .off = */ 0, \
682  /* .buf = */ { /* [0] = */ { \
683  /* .size = */ (size__), \
684  /* .flags = */ (enum fuse_buf_flags) 0, \
685  /* .mem = */ NULL, \
686  /* .fd = */ -1, \
687  /* .pos = */ 0, \
688  } } \
689  } )
690 
697 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
698 
707 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
709 
710 /* ----------------------------------------------------------- *
711  * Signal handling *
712  * ----------------------------------------------------------- */
713 
729 int fuse_set_signal_handlers(struct fuse_session *se);
730 
742 void fuse_remove_signal_handlers(struct fuse_session *se);
743 
744 /* ----------------------------------------------------------- *
745  * Compatibility stuff *
746  * ----------------------------------------------------------- */
747 
748 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
749 # error only API version 30 or greater is supported
750 #endif
751 
752 #ifdef __cplusplus
753 }
754 #endif
755 
756 
757 /*
758  * This interface uses 64 bit off_t.
759  *
760  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
761  */
762 
763 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
764 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
765 #else
766 struct _fuse_off_t_must_be_64bit_dummy_struct \
767  { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
768 #endif
769 
770 #endif /* FUSE_COMMON_H_ */
size_t off
Definition: fuse_common.h:668
unsigned capable
Definition: fuse_common.h:370
uint64_t fh
Definition: fuse_common.h:72
unsigned int writepage
Definition: fuse_common.h:43
unsigned int direct_io
Definition: fuse_common.h:46
uint32_t poll_events
Definition: fuse_common.h:79
unsigned max_write
Definition: fuse_common.h:346
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
Definition: helper.c:356
unsigned proto_minor
Definition: fuse_common.h:341
unsigned int max_idle_threads
Definition: fuse_common.h:103
unsigned max_background
Definition: fuse_common.h:408
const char * fuse_pkgversion(void)
Definition: fuse.c:4926
unsigned int keep_cache
Definition: fuse_common.h:51
uint64_t lock_owner
Definition: fuse_common.h:75
int fuse_version(void)
Definition: fuse.c:4921
off_t pos
Definition: fuse_common.h:643
int fuse_daemonize(int foreground)
Definition: helper.c:220
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition: buffer.c:281
size_t idx
Definition: fuse_common.h:663
size_t count
Definition: fuse_common.h:658
unsigned int nonseekable
Definition: fuse_common.h:60
unsigned congestion_threshold
Definition: fuse_common.h:418
unsigned int flush
Definition: fuse_common.h:56
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
unsigned max_read
Definition: fuse_common.h:360
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:403
unsigned max_readahead
Definition: fuse_common.h:365
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
unsigned proto_major
Definition: fuse_common.h:336
fuse_buf_copy_flags
Definition: fuse_common.h:568
unsigned want
Definition: fuse_common.h:378
void * mem
Definition: fuse_common.h:629
size_t size
Definition: fuse_common.h:617
fuse_buf_flags
Definition: fuse_common.h:537
unsigned int padding
Definition: fuse_common.h:68
unsigned time_gran
Definition: fuse_common.h:435
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79