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 10
27 
28 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 100 + (min))
29 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
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 
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 
360 #define FUSE_CAP_CACHE_SYMLINKS (1 << 23)
361 
372 #define FUSE_CAP_NO_OPENDIR_SUPPORT (1 << 24)
373 
395 #define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
396 
407 #define FUSE_IOCTL_COMPAT (1 << 0)
408 #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
409 #define FUSE_IOCTL_RETRY (1 << 2)
410 #define FUSE_IOCTL_DIR (1 << 4)
411 
412 #define FUSE_IOCTL_MAX_IOV 256
413 
425  unsigned proto_major;
426 
430  unsigned proto_minor;
431 
435  unsigned max_write;
436 
449  unsigned max_read;
450 
454  unsigned max_readahead;
455 
459  unsigned capable;
460 
467  unsigned want;
468 
497  unsigned max_background;
498 
508 
524  unsigned time_gran;
525 
529  unsigned reserved[22];
530 };
531 
532 struct fuse_session;
533 struct fuse_pollhandle;
534 struct fuse_conn_info_opts;
535 
578 struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args);
579 
587 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
588  struct fuse_conn_info *conn);
589 
596 int fuse_daemonize(int foreground);
597 
603 int fuse_version(void);
604 
610 const char *fuse_pkgversion(void);
611 
617 void fuse_pollhandle_destroy(struct fuse_pollhandle *ph);
618 
619 /* ----------------------------------------------------------- *
620  * Data buffer *
621  * ----------------------------------------------------------- */
622 
633  FUSE_BUF_IS_FD = (1 << 1),
634 
642  FUSE_BUF_FD_SEEK = (1 << 2),
643 
651  FUSE_BUF_FD_RETRY = (1 << 3)
652 };
653 
667  FUSE_BUF_NO_SPLICE = (1 << 1),
668 
676 
685 
693  FUSE_BUF_SPLICE_NONBLOCK= (1 << 4)
694 };
695 
702 struct fuse_buf {
706  size_t size;
707 
711  enum fuse_buf_flags flags;
712 
718  void *mem;
719 
725  int fd;
726 
732  off_t pos;
733 };
734 
743 struct fuse_bufvec {
747  size_t count;
748 
752  size_t idx;
753 
757  size_t off;
758 
762  struct fuse_buf buf[1];
763 };
764 
765 /* Initialize bufvec with a single buffer of given size */
766 #define FUSE_BUFVEC_INIT(size__) \
767  ((struct fuse_bufvec) { \
768  /* .count= */ 1, \
769  /* .idx = */ 0, \
770  /* .off = */ 0, \
771  /* .buf = */ { /* [0] = */ { \
772  /* .size = */ (size__), \
773  /* .flags = */ (enum fuse_buf_flags) 0, \
774  /* .mem = */ NULL, \
775  /* .fd = */ -1, \
776  /* .pos = */ 0, \
777  } } \
778  } )
779 
786 size_t fuse_buf_size(const struct fuse_bufvec *bufv);
787 
796 ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
798 
799 /* ----------------------------------------------------------- *
800  * Signal handling *
801  * ----------------------------------------------------------- */
802 
818 int fuse_set_signal_handlers(struct fuse_session *se);
819 
831 void fuse_remove_signal_handlers(struct fuse_session *se);
832 
833 /* ----------------------------------------------------------- *
834  * Compatibility stuff *
835  * ----------------------------------------------------------- */
836 
837 #if !defined(FUSE_USE_VERSION) || FUSE_USE_VERSION < 30
838 # error only API version 30 or greater is supported
839 #endif
840 
841 #ifdef __cplusplus
842 }
843 #endif
844 
845 
846 /*
847  * This interface uses 64 bit off_t.
848  *
849  * On 32bit systems please add -D_FILE_OFFSET_BITS=64 to your compile flags!
850  */
851 
852 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && !defined __cplusplus
853 _Static_assert(sizeof(off_t) == 8, "fuse: off_t must be 64bit");
854 #else
855 struct _fuse_off_t_must_be_64bit_dummy_struct \
856  { unsigned _fuse_off_t_must_be_64bit:((sizeof(off_t) == 8) ? 1 : -1); };
857 #endif
858 
859 #endif /* FUSE_COMMON_H_ */
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
Definition: helper.c:361
fuse_buf_flags
Definition: fuse_common.h:626
@ FUSE_BUF_FD_SEEK
Definition: fuse_common.h:642
@ FUSE_BUF_FD_RETRY
Definition: fuse_common.h:651
@ FUSE_BUF_IS_FD
Definition: fuse_common.h:633
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition: buffer.c:284
const char * fuse_pkgversion(void)
Definition: fuse.c:5122
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
int fuse_version(void)
Definition: fuse.c:5117
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
fuse_buf_copy_flags
Definition: fuse_common.h:657
@ FUSE_BUF_SPLICE_NONBLOCK
Definition: fuse_common.h:693
@ FUSE_BUF_FORCE_SPLICE
Definition: fuse_common.h:675
@ FUSE_BUF_NO_SPLICE
Definition: fuse_common.h:667
@ FUSE_BUF_SPLICE_MOVE
Definition: fuse_common.h:684
int fuse_daemonize(int foreground)
Definition: helper.c:225
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
enum fuse_buf_flags flags
Definition: fuse_common.h:711
off_t pos
Definition: fuse_common.h:732
void * mem
Definition: fuse_common.h:718
size_t size
Definition: fuse_common.h:706
size_t off
Definition: fuse_common.h:757
struct fuse_buf buf[1]
Definition: fuse_common.h:762
size_t idx
Definition: fuse_common.h:752
size_t count
Definition: fuse_common.h:747
unsigned time_gran
Definition: fuse_common.h:524
unsigned congestion_threshold
Definition: fuse_common.h:507
unsigned max_background
Definition: fuse_common.h:497
unsigned proto_major
Definition: fuse_common.h:425
unsigned max_read
Definition: fuse_common.h:449
unsigned proto_minor
Definition: fuse_common.h:430
unsigned capable
Definition: fuse_common.h:459
unsigned reserved[22]
Definition: fuse_common.h:529
unsigned max_readahead
Definition: fuse_common.h:454
unsigned max_write
Definition: fuse_common.h:435
unsigned want
Definition: fuse_common.h:467
unsigned int direct_io
Definition: fuse_common.h:57
unsigned int keep_cache
Definition: fuse_common.h:64
unsigned int nonseekable
Definition: fuse_common.h:73
uint64_t lock_owner
Definition: fuse_common.h:96
uint64_t fh
Definition: fuse_common.h:93
uint32_t poll_events
Definition: fuse_common.h:100
unsigned int writepage
Definition: fuse_common.h:54
unsigned int flush
Definition: fuse_common.h:69
unsigned int padding
Definition: fuse_common.h:87
unsigned int cache_readdir
Definition: fuse_common.h:84
unsigned int max_idle_threads
Definition: fuse_common.h:124