blob: fb445a773914409e281ec18a99e5e74ca5aef8b7 [file] [log] [blame]
bigbiff bigbiff9c754052013-01-09 09:09:08 -05001/*
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
26extern "C" {
27#endif
28
29#define CUSE_UNRESTRICTED_IOCTL (1 << 0) /* use unrestricted ioctl */
30
31struct fuse_session;
32
33struct 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 */
49struct 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);
Matt Mower523a0592015-12-13 11:31:00 -060054 void (*read) (fuse_req_t req, size_t size, loff_t off,
bigbiff bigbiff9c754052013-01-09 09:09:08 -050055 struct fuse_file_info *fi);
Matt Mower523a0592015-12-13 11:31:00 -060056 void (*write) (fuse_req_t req, const char *buf, size_t size, loff_t off,
bigbiff bigbiff9c754052013-01-09 09:09:08 -050057 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
68struct 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
73struct 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
78void cuse_lowlevel_teardown(struct fuse_session *se);
79
80int 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_ */