fuse.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
  4. This program can be distributed under the terms of the GNU GPL.
  5. See the file COPYING.
  6. */
  7. /* This file defines the kernel interface of FUSE */
  8. #include <asm/types.h>
  9. /** Version number of this interface */
  10. #define FUSE_KERNEL_VERSION 7
  11. /** Minor version number of this interface */
  12. #define FUSE_KERNEL_MINOR_VERSION 6
  13. /** The node ID of the root inode */
  14. #define FUSE_ROOT_ID 1
  15. /** The major number of the fuse character device */
  16. #define FUSE_MAJOR 10
  17. /** The minor number of the fuse character device */
  18. #define FUSE_MINOR 229
  19. /* Make sure all structures are padded to 64bit boundary, so 32bit
  20. userspace works under 64bit kernels */
  21. struct fuse_attr {
  22. __u64 ino;
  23. __u64 size;
  24. __u64 blocks;
  25. __u64 atime;
  26. __u64 mtime;
  27. __u64 ctime;
  28. __u32 atimensec;
  29. __u32 mtimensec;
  30. __u32 ctimensec;
  31. __u32 mode;
  32. __u32 nlink;
  33. __u32 uid;
  34. __u32 gid;
  35. __u32 rdev;
  36. };
  37. struct fuse_kstatfs {
  38. __u64 blocks;
  39. __u64 bfree;
  40. __u64 bavail;
  41. __u64 files;
  42. __u64 ffree;
  43. __u32 bsize;
  44. __u32 namelen;
  45. __u32 frsize;
  46. __u32 padding;
  47. __u32 spare[6];
  48. };
  49. /**
  50. * Bitmasks for fuse_setattr_in.valid
  51. */
  52. #define FATTR_MODE (1 << 0)
  53. #define FATTR_UID (1 << 1)
  54. #define FATTR_GID (1 << 2)
  55. #define FATTR_SIZE (1 << 3)
  56. #define FATTR_ATIME (1 << 4)
  57. #define FATTR_MTIME (1 << 5)
  58. #define FATTR_FH (1 << 6)
  59. /**
  60. * Flags returned by the OPEN request
  61. *
  62. * FOPEN_DIRECT_IO: bypass page cache for this open file
  63. * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
  64. */
  65. #define FOPEN_DIRECT_IO (1 << 0)
  66. #define FOPEN_KEEP_CACHE (1 << 1)
  67. /**
  68. * INIT request/reply flags
  69. */
  70. #define FUSE_ASYNC_READ (1 << 0)
  71. enum fuse_opcode {
  72. FUSE_LOOKUP = 1,
  73. FUSE_FORGET = 2, /* no reply */
  74. FUSE_GETATTR = 3,
  75. FUSE_SETATTR = 4,
  76. FUSE_READLINK = 5,
  77. FUSE_SYMLINK = 6,
  78. FUSE_MKNOD = 8,
  79. FUSE_MKDIR = 9,
  80. FUSE_UNLINK = 10,
  81. FUSE_RMDIR = 11,
  82. FUSE_RENAME = 12,
  83. FUSE_LINK = 13,
  84. FUSE_OPEN = 14,
  85. FUSE_READ = 15,
  86. FUSE_WRITE = 16,
  87. FUSE_STATFS = 17,
  88. FUSE_RELEASE = 18,
  89. FUSE_FSYNC = 20,
  90. FUSE_SETXATTR = 21,
  91. FUSE_GETXATTR = 22,
  92. FUSE_LISTXATTR = 23,
  93. FUSE_REMOVEXATTR = 24,
  94. FUSE_FLUSH = 25,
  95. FUSE_INIT = 26,
  96. FUSE_OPENDIR = 27,
  97. FUSE_READDIR = 28,
  98. FUSE_RELEASEDIR = 29,
  99. FUSE_FSYNCDIR = 30,
  100. FUSE_ACCESS = 34,
  101. FUSE_CREATE = 35
  102. };
  103. /* The read buffer is required to be at least 8k, but may be much larger */
  104. #define FUSE_MIN_READ_BUFFER 8192
  105. struct fuse_entry_out {
  106. __u64 nodeid; /* Inode ID */
  107. __u64 generation; /* Inode generation: nodeid:gen must
  108. be unique for the fs's lifetime */
  109. __u64 entry_valid; /* Cache timeout for the name */
  110. __u64 attr_valid; /* Cache timeout for the attributes */
  111. __u32 entry_valid_nsec;
  112. __u32 attr_valid_nsec;
  113. struct fuse_attr attr;
  114. };
  115. struct fuse_forget_in {
  116. __u64 nlookup;
  117. };
  118. struct fuse_attr_out {
  119. __u64 attr_valid; /* Cache timeout for the attributes */
  120. __u32 attr_valid_nsec;
  121. __u32 dummy;
  122. struct fuse_attr attr;
  123. };
  124. struct fuse_mknod_in {
  125. __u32 mode;
  126. __u32 rdev;
  127. };
  128. struct fuse_mkdir_in {
  129. __u32 mode;
  130. __u32 padding;
  131. };
  132. struct fuse_rename_in {
  133. __u64 newdir;
  134. };
  135. struct fuse_link_in {
  136. __u64 oldnodeid;
  137. };
  138. struct fuse_setattr_in {
  139. __u32 valid;
  140. __u32 padding;
  141. __u64 fh;
  142. __u64 size;
  143. __u64 unused1;
  144. __u64 atime;
  145. __u64 mtime;
  146. __u64 unused2;
  147. __u32 atimensec;
  148. __u32 mtimensec;
  149. __u32 unused3;
  150. __u32 mode;
  151. __u32 unused4;
  152. __u32 uid;
  153. __u32 gid;
  154. __u32 unused5;
  155. };
  156. struct fuse_open_in {
  157. __u32 flags;
  158. __u32 mode;
  159. };
  160. struct fuse_open_out {
  161. __u64 fh;
  162. __u32 open_flags;
  163. __u32 padding;
  164. };
  165. struct fuse_release_in {
  166. __u64 fh;
  167. __u32 flags;
  168. __u32 padding;
  169. };
  170. struct fuse_flush_in {
  171. __u64 fh;
  172. __u32 flush_flags;
  173. __u32 padding;
  174. };
  175. struct fuse_read_in {
  176. __u64 fh;
  177. __u64 offset;
  178. __u32 size;
  179. __u32 padding;
  180. };
  181. struct fuse_write_in {
  182. __u64 fh;
  183. __u64 offset;
  184. __u32 size;
  185. __u32 write_flags;
  186. };
  187. struct fuse_write_out {
  188. __u32 size;
  189. __u32 padding;
  190. };
  191. #define FUSE_COMPAT_STATFS_SIZE 48
  192. struct fuse_statfs_out {
  193. struct fuse_kstatfs st;
  194. };
  195. struct fuse_fsync_in {
  196. __u64 fh;
  197. __u32 fsync_flags;
  198. __u32 padding;
  199. };
  200. struct fuse_setxattr_in {
  201. __u32 size;
  202. __u32 flags;
  203. };
  204. struct fuse_getxattr_in {
  205. __u32 size;
  206. __u32 padding;
  207. };
  208. struct fuse_getxattr_out {
  209. __u32 size;
  210. __u32 padding;
  211. };
  212. struct fuse_access_in {
  213. __u32 mask;
  214. __u32 padding;
  215. };
  216. struct fuse_init_in {
  217. __u32 major;
  218. __u32 minor;
  219. __u32 max_readahead;
  220. __u32 flags;
  221. };
  222. struct fuse_init_out {
  223. __u32 major;
  224. __u32 minor;
  225. __u32 max_readahead;
  226. __u32 flags;
  227. __u32 unused;
  228. __u32 max_write;
  229. };
  230. struct fuse_in_header {
  231. __u32 len;
  232. __u32 opcode;
  233. __u64 unique;
  234. __u64 nodeid;
  235. __u32 uid;
  236. __u32 gid;
  237. __u32 pid;
  238. __u32 padding;
  239. };
  240. struct fuse_out_header {
  241. __u32 len;
  242. __s32 error;
  243. __u64 unique;
  244. };
  245. struct fuse_dirent {
  246. __u64 ino;
  247. __u64 off;
  248. __u32 namelen;
  249. __u32 type;
  250. char name[0];
  251. };
  252. #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
  253. #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
  254. #define FUSE_DIRENT_SIZE(d) \
  255. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)