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 
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 
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 
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 
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 
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 
631  FUSE_BUF_NO_SPLICE = (1 << 1),
632 
640 
649 
658 };
659 
666 struct fuse_buf {
670  size_t size;
671 
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,
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_ */
size_t off
Definition: fuse_common.h:721
unsigned capable
Definition: fuse_common.h:423
uint64_t fh
Definition: fuse_common.h:93
unsigned int writepage
Definition: fuse_common.h:54
int fuse_set_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:62
unsigned int direct_io
Definition: fuse_common.h:57
uint32_t poll_events
Definition: fuse_common.h:100
unsigned max_write
Definition: fuse_common.h:399
unsigned proto_minor
Definition: fuse_common.h:394
unsigned int max_idle_threads
Definition: fuse_common.h:124
unsigned max_background
Definition: fuse_common.h:461
unsigned int keep_cache
Definition: fuse_common.h:64
uint64_t lock_owner
Definition: fuse_common.h:96
off_t pos
Definition: fuse_common.h:696
fuse_buf_copy_flags
Definition: fuse_common.h:621
const char * fuse_pkgversion(void)
Definition: fuse.c:5117
int fuse_version(void)
Definition: fuse.c:5112
size_t idx
Definition: fuse_common.h:716
size_t count
Definition: fuse_common.h:711
void fuse_remove_signal_handlers(struct fuse_session *se)
Definition: fuse_signals.c:79
unsigned int nonseekable
Definition: fuse_common.h:73
unsigned congestion_threshold
Definition: fuse_common.h:471
unsigned int flush
Definition: fuse_common.h:69
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
Definition: buffer.c:281
unsigned max_read
Definition: fuse_common.h:413
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
Definition: buffer.c:22
int fuse_daemonize(int foreground)
Definition: helper.c:225
unsigned max_readahead
Definition: fuse_common.h:418
unsigned proto_major
Definition: fuse_common.h:389
unsigned int cache_readdir
Definition: fuse_common.h:84
unsigned want
Definition: fuse_common.h:431
void * mem
Definition: fuse_common.h:682
struct fuse_conn_info_opts * fuse_parse_conn_info_opts(struct fuse_args *args)
Definition: helper.c:408
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts, struct fuse_conn_info *conn)
Definition: helper.c:361
size_t size
Definition: fuse_common.h:670
unsigned int padding
Definition: fuse_common.h:87
unsigned time_gran
Definition: fuse_common.h:488
fuse_buf_flags
Definition: fuse_common.h:590