libfuse

cuse_lowlevel.h
1 /*
2 CUSE: Character device in Userspace
3 Copyright (C) 2008-2009 SUSE Linux Products GmbH
4 Copyright (C) 2008-2009 Tejun Heo <tj@kernel.org>
5
6 This program can be distributed under the terms of the GNU LGPLv2.
7 See the file COPYING.LIB.
8
9 Read example/cusexmp.c for usages.
10 */
11
12 #ifndef CUSE_LOWLEVEL_H_
13 #define CUSE_LOWLEVEL_H_
14
15 #ifndef FUSE_USE_VERSION
16 #define FUSE_USE_VERSION 29
17 #endif
18
19 #include "fuse_lowlevel.h"
20
21 #include <fcntl.h>
22 #include <sys/types.h>
23 #include <sys/uio.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #define CUSE_UNRESTRICTED_IOCTL (1 << 0) /* use unrestricted ioctl */
30
31 struct fuse_session;
32
33 struct cuse_info {
34 unsigned dev_major;
35 unsigned dev_minor;
36 unsigned dev_info_argc;
37 const char **dev_info_argv;
38 unsigned flags;
39 };
40
41 /*
42 * Most ops behave almost identically to the matching fuse_lowlevel
43 * ops except that they don't take @ino.
44 *
45 * init_done : called after initialization is complete
46 * read/write : always direct IO, simultaneous operations allowed
47 * ioctl : might be in unrestricted mode depending on ci->flags
48 */
49 struct cuse_lowlevel_ops {
50 void (*init) (void *userdata, struct fuse_conn_info *conn);
51 void (*init_done) (void *userdata);
52 void (*destroy) (void *userdata);
53 void (*open) (fuse_req_t req, struct fuse_file_info *fi);
54 void (*read) (fuse_req_t req, size_t size, off_t off,
55 struct fuse_file_info *fi);
56 void (*write) (fuse_req_t req, const char *buf, size_t size, off_t off,
57 struct fuse_file_info *fi);
58 void (*flush) (fuse_req_t req, struct fuse_file_info *fi);
59 void (*release) (fuse_req_t req, struct fuse_file_info *fi);
60 void (*fsync) (fuse_req_t req, int datasync, struct fuse_file_info *fi);
61 void (*ioctl) (fuse_req_t req, int cmd, void *arg,
62 struct fuse_file_info *fi, unsigned int flags,
63 const void *in_buf, size_t in_bufsz, size_t out_bufsz);
64 void (*poll) (fuse_req_t req, struct fuse_file_info *fi,
65 struct fuse_pollhandle *ph);
66 };
67
68 struct fuse_session *cuse_lowlevel_new(struct fuse_args *args,
69 const struct cuse_info *ci,
70 const struct cuse_lowlevel_ops *clop,
71 void *userdata);
72
73 struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[],
74 const struct cuse_info *ci,
75 const struct cuse_lowlevel_ops *clop,
76 int *multithreaded, void *userdata);
77
78 void cuse_lowlevel_teardown(struct fuse_session *se);
79
80 int cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci,
81 const struct cuse_lowlevel_ops *clop, void *userdata);
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /* CUSE_LOWLEVEL_H_ */
fuse_conn_info
Definition: fuse_common.h:421
fuse_lowlevel.h
fuse_req_t
struct fuse_req * fuse_req_t
Definition: fuse_lowlevel.h:49
fuse_file_info
Definition: fuse_common.h:44
fuse_file_info::flags
int flags
Definition: fuse_common.h:46
fuse_file_info::flush
unsigned int flush
Definition: fuse_common.h:69
fuse_args
Definition: fuse_opt.h:109