You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.5 KiB

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