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