fuse.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2006 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. /*
  8. * This file defines the kernel interface of FUSE
  9. *
  10. * Protocol changelog:
  11. *
  12. * 7.9:
  13. * - new fuse_getattr_in input argument of GETATTR
  14. * - add lk_flags in fuse_lk_in
  15. */
  16. #include <asm/types.h>
  17. #include <linux/major.h>
  18. /** Version number of this interface */
  19. #define FUSE_KERNEL_VERSION 7
  20. /** Minor version number of this interface */
  21. #define FUSE_KERNEL_MINOR_VERSION 9
  22. /** The node ID of the root inode */
  23. #define FUSE_ROOT_ID 1
  24. /** The major number of the fuse character device */
  25. #define FUSE_MAJOR MISC_MAJOR
  26. /** The minor number of the fuse character device */
  27. #define FUSE_MINOR 229
  28. /* Make sure all structures are padded to 64bit boundary, so 32bit
  29. userspace works under 64bit kernels */
  30. struct fuse_attr {
  31. __u64 ino;
  32. __u64 size;
  33. __u64 blocks;
  34. __u64 atime;
  35. __u64 mtime;
  36. __u64 ctime;
  37. __u32 atimensec;
  38. __u32 mtimensec;
  39. __u32 ctimensec;
  40. __u32 mode;
  41. __u32 nlink;
  42. __u32 uid;
  43. __u32 gid;
  44. __u32 rdev;
  45. };
  46. struct fuse_kstatfs {
  47. __u64 blocks;
  48. __u64 bfree;
  49. __u64 bavail;
  50. __u64 files;
  51. __u64 ffree;
  52. __u32 bsize;
  53. __u32 namelen;
  54. __u32 frsize;
  55. __u32 padding;
  56. __u32 spare[6];
  57. };
  58. struct fuse_file_lock {
  59. __u64 start;
  60. __u64 end;
  61. __u32 type;
  62. __u32 pid; /* tgid */
  63. };
  64. /**
  65. * Bitmasks for fuse_setattr_in.valid
  66. */
  67. #define FATTR_MODE (1 << 0)
  68. #define FATTR_UID (1 << 1)
  69. #define FATTR_GID (1 << 2)
  70. #define FATTR_SIZE (1 << 3)
  71. #define FATTR_ATIME (1 << 4)
  72. #define FATTR_MTIME (1 << 5)
  73. #define FATTR_FH (1 << 6)
  74. #define FATTR_ATIME_NOW (1 << 7)
  75. #define FATTR_MTIME_NOW (1 << 8)
  76. /**
  77. * Flags returned by the OPEN request
  78. *
  79. * FOPEN_DIRECT_IO: bypass page cache for this open file
  80. * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
  81. */
  82. #define FOPEN_DIRECT_IO (1 << 0)
  83. #define FOPEN_KEEP_CACHE (1 << 1)
  84. /**
  85. * INIT request/reply flags
  86. */
  87. #define FUSE_ASYNC_READ (1 << 0)
  88. #define FUSE_POSIX_LOCKS (1 << 1)
  89. #define FUSE_FILE_OPS (1 << 2)
  90. #define FUSE_ATOMIC_O_TRUNC (1 << 3)
  91. /**
  92. * Release flags
  93. */
  94. #define FUSE_RELEASE_FLUSH (1 << 0)
  95. /**
  96. * Getattr flags
  97. */
  98. #define FUSE_GETATTR_FH (1 << 0)
  99. /**
  100. * Lock flags
  101. */
  102. #define FUSE_LK_FLOCK (1 << 0)
  103. /**
  104. * WRITE flags
  105. *
  106. * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
  107. */
  108. #define FUSE_WRITE_CACHE (1 << 0)
  109. enum fuse_opcode {
  110. FUSE_LOOKUP = 1,
  111. FUSE_FORGET = 2, /* no reply */
  112. FUSE_GETATTR = 3,
  113. FUSE_SETATTR = 4,
  114. FUSE_READLINK = 5,
  115. FUSE_SYMLINK = 6,
  116. FUSE_MKNOD = 8,
  117. FUSE_MKDIR = 9,
  118. FUSE_UNLINK = 10,
  119. FUSE_RMDIR = 11,
  120. FUSE_RENAME = 12,
  121. FUSE_LINK = 13,
  122. FUSE_OPEN = 14,
  123. FUSE_READ = 15,
  124. FUSE_WRITE = 16,
  125. FUSE_STATFS = 17,
  126. FUSE_RELEASE = 18,
  127. FUSE_FSYNC = 20,
  128. FUSE_SETXATTR = 21,
  129. FUSE_GETXATTR = 22,
  130. FUSE_LISTXATTR = 23,
  131. FUSE_REMOVEXATTR = 24,
  132. FUSE_FLUSH = 25,
  133. FUSE_INIT = 26,
  134. FUSE_OPENDIR = 27,
  135. FUSE_READDIR = 28,
  136. FUSE_RELEASEDIR = 29,
  137. FUSE_FSYNCDIR = 30,
  138. FUSE_GETLK = 31,
  139. FUSE_SETLK = 32,
  140. FUSE_SETLKW = 33,
  141. FUSE_ACCESS = 34,
  142. FUSE_CREATE = 35,
  143. FUSE_INTERRUPT = 36,
  144. FUSE_BMAP = 37,
  145. FUSE_DESTROY = 38,
  146. };
  147. /* The read buffer is required to be at least 8k, but may be much larger */
  148. #define FUSE_MIN_READ_BUFFER 8192
  149. struct fuse_entry_out {
  150. __u64 nodeid; /* Inode ID */
  151. __u64 generation; /* Inode generation: nodeid:gen must
  152. be unique for the fs's lifetime */
  153. __u64 entry_valid; /* Cache timeout for the name */
  154. __u64 attr_valid; /* Cache timeout for the attributes */
  155. __u32 entry_valid_nsec;
  156. __u32 attr_valid_nsec;
  157. struct fuse_attr attr;
  158. };
  159. struct fuse_forget_in {
  160. __u64 nlookup;
  161. };
  162. struct fuse_getattr_in {
  163. __u32 getattr_flags;
  164. __u32 dummy;
  165. __u64 fh;
  166. };
  167. struct fuse_attr_out {
  168. __u64 attr_valid; /* Cache timeout for the attributes */
  169. __u32 attr_valid_nsec;
  170. __u32 dummy;
  171. struct fuse_attr attr;
  172. };
  173. struct fuse_mknod_in {
  174. __u32 mode;
  175. __u32 rdev;
  176. };
  177. struct fuse_mkdir_in {
  178. __u32 mode;
  179. __u32 padding;
  180. };
  181. struct fuse_rename_in {
  182. __u64 newdir;
  183. };
  184. struct fuse_link_in {
  185. __u64 oldnodeid;
  186. };
  187. struct fuse_setattr_in {
  188. __u32 valid;
  189. __u32 padding;
  190. __u64 fh;
  191. __u64 size;
  192. __u64 unused1;
  193. __u64 atime;
  194. __u64 mtime;
  195. __u64 unused2;
  196. __u32 atimensec;
  197. __u32 mtimensec;
  198. __u32 unused3;
  199. __u32 mode;
  200. __u32 unused4;
  201. __u32 uid;
  202. __u32 gid;
  203. __u32 unused5;
  204. };
  205. struct fuse_open_in {
  206. __u32 flags;
  207. __u32 mode;
  208. };
  209. struct fuse_open_out {
  210. __u64 fh;
  211. __u32 open_flags;
  212. __u32 padding;
  213. };
  214. struct fuse_release_in {
  215. __u64 fh;
  216. __u32 flags;
  217. __u32 release_flags;
  218. __u64 lock_owner;
  219. };
  220. struct fuse_flush_in {
  221. __u64 fh;
  222. __u32 unused;
  223. __u32 padding;
  224. __u64 lock_owner;
  225. };
  226. struct fuse_read_in {
  227. __u64 fh;
  228. __u64 offset;
  229. __u32 size;
  230. __u32 padding;
  231. };
  232. struct fuse_write_in {
  233. __u64 fh;
  234. __u64 offset;
  235. __u32 size;
  236. __u32 write_flags;
  237. };
  238. struct fuse_write_out {
  239. __u32 size;
  240. __u32 padding;
  241. };
  242. #define FUSE_COMPAT_STATFS_SIZE 48
  243. struct fuse_statfs_out {
  244. struct fuse_kstatfs st;
  245. };
  246. struct fuse_fsync_in {
  247. __u64 fh;
  248. __u32 fsync_flags;
  249. __u32 padding;
  250. };
  251. struct fuse_setxattr_in {
  252. __u32 size;
  253. __u32 flags;
  254. };
  255. struct fuse_getxattr_in {
  256. __u32 size;
  257. __u32 padding;
  258. };
  259. struct fuse_getxattr_out {
  260. __u32 size;
  261. __u32 padding;
  262. };
  263. struct fuse_lk_in {
  264. __u64 fh;
  265. __u64 owner;
  266. struct fuse_file_lock lk;
  267. __u32 lk_flags;
  268. __u32 padding;
  269. };
  270. struct fuse_lk_out {
  271. struct fuse_file_lock lk;
  272. };
  273. struct fuse_access_in {
  274. __u32 mask;
  275. __u32 padding;
  276. };
  277. struct fuse_init_in {
  278. __u32 major;
  279. __u32 minor;
  280. __u32 max_readahead;
  281. __u32 flags;
  282. };
  283. struct fuse_init_out {
  284. __u32 major;
  285. __u32 minor;
  286. __u32 max_readahead;
  287. __u32 flags;
  288. __u32 unused;
  289. __u32 max_write;
  290. };
  291. struct fuse_interrupt_in {
  292. __u64 unique;
  293. };
  294. struct fuse_bmap_in {
  295. __u64 block;
  296. __u32 blocksize;
  297. __u32 padding;
  298. };
  299. struct fuse_bmap_out {
  300. __u64 block;
  301. };
  302. struct fuse_in_header {
  303. __u32 len;
  304. __u32 opcode;
  305. __u64 unique;
  306. __u64 nodeid;
  307. __u32 uid;
  308. __u32 gid;
  309. __u32 pid;
  310. __u32 padding;
  311. };
  312. struct fuse_out_header {
  313. __u32 len;
  314. __s32 error;
  315. __u64 unique;
  316. };
  317. struct fuse_dirent {
  318. __u64 ino;
  319. __u64 off;
  320. __u32 namelen;
  321. __u32 type;
  322. char name[0];
  323. };
  324. #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
  325. #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
  326. #define FUSE_DIRENT_SIZE(d) \
  327. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)