16881f68fSopenharmony_ci/* 26881f68fSopenharmony_ci CUSE: Character device in Userspace 36881f68fSopenharmony_ci Copyright (C) 2008-2009 SUSE Linux Products GmbH 46881f68fSopenharmony_ci Copyright (C) 2008-2009 Tejun Heo <tj@kernel.org> 56881f68fSopenharmony_ci 66881f68fSopenharmony_ci This program can be distributed under the terms of the GNU LGPLv2. 76881f68fSopenharmony_ci See the file COPYING.LIB. 86881f68fSopenharmony_ci 96881f68fSopenharmony_ci Read example/cusexmp.c for usages. 106881f68fSopenharmony_ci*/ 116881f68fSopenharmony_ci 126881f68fSopenharmony_ci#ifndef CUSE_LOWLEVEL_H_ 136881f68fSopenharmony_ci#define CUSE_LOWLEVEL_H_ 146881f68fSopenharmony_ci 156881f68fSopenharmony_ci#ifndef FUSE_USE_VERSION 166881f68fSopenharmony_ci#define FUSE_USE_VERSION 29 176881f68fSopenharmony_ci#endif 186881f68fSopenharmony_ci 196881f68fSopenharmony_ci#include "fuse_lowlevel.h" 206881f68fSopenharmony_ci 216881f68fSopenharmony_ci#include <fcntl.h> 226881f68fSopenharmony_ci#include <sys/types.h> 236881f68fSopenharmony_ci#include <sys/uio.h> 246881f68fSopenharmony_ci 256881f68fSopenharmony_ci#ifdef __cplusplus 266881f68fSopenharmony_ciextern "C" { 276881f68fSopenharmony_ci#endif 286881f68fSopenharmony_ci 296881f68fSopenharmony_ci#define CUSE_UNRESTRICTED_IOCTL (1 << 0) /* use unrestricted ioctl */ 306881f68fSopenharmony_ci 316881f68fSopenharmony_cistruct fuse_session; 326881f68fSopenharmony_ci 336881f68fSopenharmony_cistruct cuse_info { 346881f68fSopenharmony_ci unsigned dev_major; 356881f68fSopenharmony_ci unsigned dev_minor; 366881f68fSopenharmony_ci unsigned dev_info_argc; 376881f68fSopenharmony_ci const char **dev_info_argv; 386881f68fSopenharmony_ci unsigned flags; 396881f68fSopenharmony_ci}; 406881f68fSopenharmony_ci 416881f68fSopenharmony_ci/* 426881f68fSopenharmony_ci * Most ops behave almost identically to the matching fuse_lowlevel 436881f68fSopenharmony_ci * ops except that they don't take @ino. 446881f68fSopenharmony_ci * 456881f68fSopenharmony_ci * init_done : called after initialization is complete 466881f68fSopenharmony_ci * read/write : always direct IO, simultaneous operations allowed 476881f68fSopenharmony_ci * ioctl : might be in unrestricted mode depending on ci->flags 486881f68fSopenharmony_ci */ 496881f68fSopenharmony_cistruct cuse_lowlevel_ops { 506881f68fSopenharmony_ci void (*init) (void *userdata, struct fuse_conn_info *conn); 516881f68fSopenharmony_ci void (*init_done) (void *userdata); 526881f68fSopenharmony_ci void (*destroy) (void *userdata); 536881f68fSopenharmony_ci void (*open) (fuse_req_t req, struct fuse_file_info *fi); 546881f68fSopenharmony_ci void (*read) (fuse_req_t req, size_t size, off_t off, 556881f68fSopenharmony_ci struct fuse_file_info *fi); 566881f68fSopenharmony_ci void (*write) (fuse_req_t req, const char *buf, size_t size, off_t off, 576881f68fSopenharmony_ci struct fuse_file_info *fi); 586881f68fSopenharmony_ci void (*flush) (fuse_req_t req, struct fuse_file_info *fi); 596881f68fSopenharmony_ci void (*release) (fuse_req_t req, struct fuse_file_info *fi); 606881f68fSopenharmony_ci void (*fsync) (fuse_req_t req, int datasync, struct fuse_file_info *fi); 616881f68fSopenharmony_ci void (*ioctl) (fuse_req_t req, int cmd, void *arg, 626881f68fSopenharmony_ci struct fuse_file_info *fi, unsigned int flags, 636881f68fSopenharmony_ci const void *in_buf, size_t in_bufsz, size_t out_bufsz); 646881f68fSopenharmony_ci void (*poll) (fuse_req_t req, struct fuse_file_info *fi, 656881f68fSopenharmony_ci struct fuse_pollhandle *ph); 666881f68fSopenharmony_ci}; 676881f68fSopenharmony_ci 686881f68fSopenharmony_cistruct fuse_session *cuse_lowlevel_new(struct fuse_args *args, 696881f68fSopenharmony_ci const struct cuse_info *ci, 706881f68fSopenharmony_ci const struct cuse_lowlevel_ops *clop, 716881f68fSopenharmony_ci void *userdata); 726881f68fSopenharmony_ci 736881f68fSopenharmony_cistruct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], 746881f68fSopenharmony_ci const struct cuse_info *ci, 756881f68fSopenharmony_ci const struct cuse_lowlevel_ops *clop, 766881f68fSopenharmony_ci int *multithreaded, void *userdata); 776881f68fSopenharmony_ci 786881f68fSopenharmony_civoid cuse_lowlevel_teardown(struct fuse_session *se); 796881f68fSopenharmony_ci 806881f68fSopenharmony_ciint cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci, 816881f68fSopenharmony_ci const struct cuse_lowlevel_ops *clop, void *userdata); 826881f68fSopenharmony_ci 836881f68fSopenharmony_ci#ifdef __cplusplus 846881f68fSopenharmony_ci} 856881f68fSopenharmony_ci#endif 866881f68fSopenharmony_ci 876881f68fSopenharmony_ci#endif /* CUSE_LOWLEVEL_H_ */ 88