android_fuse.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause WITH Linux-syscall-note */
  2. /* Copyright (c) 2022 Google LLC */
  3. #ifndef _LINUX_ANDROID_FUSE_H
  4. #define _LINUX_ANDROID_FUSE_H
  5. #ifdef __KERNEL__
  6. #include <linux/types.h>
  7. #else
  8. #include <stdint.h>
  9. #endif
  10. #define FUSE_ACTION_KEEP 0
  11. #define FUSE_ACTION_REMOVE 1
  12. #define FUSE_ACTION_REPLACE 2
  13. struct fuse_entry_bpf_out {
  14. uint64_t backing_action;
  15. uint64_t backing_fd;
  16. uint64_t bpf_action;
  17. uint64_t bpf_fd;
  18. };
  19. struct fuse_entry_bpf {
  20. struct fuse_entry_bpf_out out;
  21. struct file *backing_file;
  22. struct file *bpf_file;
  23. };
  24. struct fuse_read_out {
  25. uint64_t offset;
  26. uint32_t again;
  27. uint32_t padding;
  28. };
  29. struct fuse_in_postfilter_header {
  30. uint32_t len;
  31. uint32_t opcode;
  32. uint64_t unique;
  33. uint64_t nodeid;
  34. uint32_t uid;
  35. uint32_t gid;
  36. uint32_t pid;
  37. uint32_t error_in;
  38. };
  39. /*
  40. * Fuse BPF Args
  41. *
  42. * Used to communicate with bpf programs to allow checking or altering certain values.
  43. * The end_offset allows the bpf verifier to check boundaries statically. This reflects
  44. * the ends of the buffer. size shows the length that was actually used.
  45. *
  46. */
  47. /** One input argument of a request */
  48. struct fuse_bpf_in_arg {
  49. uint32_t size;
  50. uint32_t padding;
  51. union {
  52. const void *value;
  53. uint64_t padding2;
  54. };
  55. union {
  56. const void *end_offset;
  57. uint64_t padding3;
  58. };
  59. };
  60. /** One output argument of a request */
  61. struct fuse_bpf_arg {
  62. uint32_t size;
  63. uint32_t padding;
  64. union {
  65. void *value;
  66. uint64_t padding2;
  67. };
  68. union {
  69. void *end_offset;
  70. uint64_t padding3;
  71. };
  72. };
  73. #define FUSE_MAX_IN_ARGS 5
  74. #define FUSE_MAX_OUT_ARGS 3
  75. #define FUSE_BPF_FORCE (1 << 0)
  76. #define FUSE_BPF_OUT_ARGVAR (1 << 6)
  77. struct fuse_bpf_args {
  78. uint64_t nodeid;
  79. uint32_t opcode;
  80. uint32_t error_in;
  81. uint32_t in_numargs;
  82. uint32_t out_numargs;
  83. uint32_t flags;
  84. uint32_t padding;
  85. struct fuse_bpf_in_arg in_args[FUSE_MAX_IN_ARGS];
  86. struct fuse_bpf_arg out_args[FUSE_MAX_OUT_ARGS];
  87. };
  88. #define FUSE_BPF_USER_FILTER 1
  89. #define FUSE_BPF_BACKING 2
  90. #define FUSE_BPF_POST_FILTER 4
  91. #define FUSE_OPCODE_FILTER 0x0ffff
  92. #define FUSE_PREFILTER 0x10000
  93. #define FUSE_POSTFILTER 0x20000
  94. struct bpf_prog *fuse_get_bpf_prog(struct file *file);
  95. #endif /* _LINUX_ANDROID_FUSE_H */