Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
[qemu.git] / tools / virtiofsd / fuse_i.h
1 /*
2 * FUSE: Filesystem in Userspace
3 * Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
4 *
5 * This program can be distributed under the terms of the GNU LGPLv2.
6 * See the file COPYING.LIB
7 */
8
9 #ifndef FUSE_I_H
10 #define FUSE_I_H
11
12 #define FUSE_USE_VERSION 31
13 #include "fuse_lowlevel.h"
14
15 struct fv_VuDev;
16 struct fv_QueueInfo;
17
18 struct fuse_req {
19 struct fuse_session *se;
20 uint64_t unique;
21 int ctr;
22 pthread_mutex_t lock;
23 struct fuse_ctx ctx;
24 struct fuse_chan *ch;
25 int interrupted;
26 unsigned int ioctl_64bit:1;
27 union {
28 struct {
29 uint64_t unique;
30 } i;
31 struct {
32 fuse_interrupt_func_t func;
33 void *data;
34 } ni;
35 } u;
36 struct fuse_req *next;
37 struct fuse_req *prev;
38 };
39
40 struct fuse_notify_req {
41 uint64_t unique;
42 void (*reply)(struct fuse_notify_req *, fuse_req_t, fuse_ino_t,
43 const void *, const struct fuse_buf *);
44 struct fuse_notify_req *next;
45 struct fuse_notify_req *prev;
46 };
47
48 struct fuse_session {
49 char *mountpoint;
50 volatile int exited;
51 int fd;
52 int debug;
53 int deny_others;
54 struct fuse_lowlevel_ops op;
55 int got_init;
56 struct cuse_data *cuse_data;
57 void *userdata;
58 uid_t owner;
59 struct fuse_conn_info conn;
60 struct fuse_req list;
61 struct fuse_req interrupts;
62 pthread_mutex_t lock;
63 pthread_rwlock_t init_rwlock;
64 int got_destroy;
65 int broken_splice_nonblock;
66 uint64_t notify_ctr;
67 struct fuse_notify_req notify_list;
68 size_t bufsize;
69 int error;
70 char *vu_socket_path;
71 char *vu_socket_group;
72 int vu_listen_fd;
73 int vu_socketfd;
74 struct fv_VuDev *virtio_dev;
75 int thread_pool_size;
76 };
77
78 struct fuse_chan {
79 pthread_mutex_t lock;
80 int ctr;
81 int fd;
82 struct fv_QueueInfo *qi;
83 };
84
85 int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
86 int count);
87 void fuse_free_req(fuse_req_t req);
88
89 void fuse_session_process_buf_int(struct fuse_session *se,
90 struct fuse_bufvec *bufv,
91 struct fuse_chan *ch);
92
93
94 #define FUSE_MAX_MAX_PAGES 256
95 #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
96
97 /* room needed in buffer to accommodate header */
98 #define FUSE_BUFFER_HEADER_SIZE 0x1000
99
100 #endif