fuse.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2008 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. * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
  16. * - add blksize field to fuse_attr
  17. * - add file flags field to fuse_read_in and fuse_write_in
  18. *
  19. * 7.10
  20. * - add nonseekable open flag
  21. *
  22. * 7.11
  23. * - add IOCTL message
  24. * - add unsolicited notification support
  25. * - add POLL message and NOTIFY_POLL notification
  26. */
  27. #ifndef _LINUX_FUSE_H
  28. #define _LINUX_FUSE_H
  29. #include <linux/types.h>
  30. /** Version number of this interface */
  31. #define FUSE_KERNEL_VERSION 7
  32. /** Minor version number of this interface */
  33. #define FUSE_KERNEL_MINOR_VERSION 11
  34. /** The node ID of the root inode */
  35. #define FUSE_ROOT_ID 1
  36. /* Make sure all structures are padded to 64bit boundary, so 32bit
  37. userspace works under 64bit kernels */
  38. struct fuse_attr {
  39. __u64 ino;
  40. __u64 size;
  41. __u64 blocks;
  42. __u64 atime;
  43. __u64 mtime;
  44. __u64 ctime;
  45. __u32 atimensec;
  46. __u32 mtimensec;
  47. __u32 ctimensec;
  48. __u32 mode;
  49. __u32 nlink;
  50. __u32 uid;
  51. __u32 gid;
  52. __u32 rdev;
  53. __u32 blksize;
  54. __u32 padding;
  55. };
  56. struct fuse_kstatfs {
  57. __u64 blocks;
  58. __u64 bfree;
  59. __u64 bavail;
  60. __u64 files;
  61. __u64 ffree;
  62. __u32 bsize;
  63. __u32 namelen;
  64. __u32 frsize;
  65. __u32 padding;
  66. __u32 spare[6];
  67. };
  68. struct fuse_file_lock {
  69. __u64 start;
  70. __u64 end;
  71. __u32 type;
  72. __u32 pid; /* tgid */
  73. };
  74. /**
  75. * Bitmasks for fuse_setattr_in.valid
  76. */
  77. #define FATTR_MODE (1 << 0)
  78. #define FATTR_UID (1 << 1)
  79. #define FATTR_GID (1 << 2)
  80. #define FATTR_SIZE (1 << 3)
  81. #define FATTR_ATIME (1 << 4)
  82. #define FATTR_MTIME (1 << 5)
  83. #define FATTR_FH (1 << 6)
  84. #define FATTR_ATIME_NOW (1 << 7)
  85. #define FATTR_MTIME_NOW (1 << 8)
  86. #define FATTR_LOCKOWNER (1 << 9)
  87. /**
  88. * Flags returned by the OPEN request
  89. *
  90. * FOPEN_DIRECT_IO: bypass page cache for this open file
  91. * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
  92. * FOPEN_NONSEEKABLE: the file is not seekable
  93. */
  94. #define FOPEN_DIRECT_IO (1 << 0)
  95. #define FOPEN_KEEP_CACHE (1 << 1)
  96. #define FOPEN_NONSEEKABLE (1 << 2)
  97. /**
  98. * INIT request/reply flags
  99. *
  100. * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
  101. */
  102. #define FUSE_ASYNC_READ (1 << 0)
  103. #define FUSE_POSIX_LOCKS (1 << 1)
  104. #define FUSE_FILE_OPS (1 << 2)
  105. #define FUSE_ATOMIC_O_TRUNC (1 << 3)
  106. #define FUSE_EXPORT_SUPPORT (1 << 4)
  107. #define FUSE_BIG_WRITES (1 << 5)
  108. /**
  109. * Release flags
  110. */
  111. #define FUSE_RELEASE_FLUSH (1 << 0)
  112. /**
  113. * Getattr flags
  114. */
  115. #define FUSE_GETATTR_FH (1 << 0)
  116. /**
  117. * Lock flags
  118. */
  119. #define FUSE_LK_FLOCK (1 << 0)
  120. /**
  121. * WRITE flags
  122. *
  123. * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed
  124. * FUSE_WRITE_LOCKOWNER: lock_owner field is valid
  125. */
  126. #define FUSE_WRITE_CACHE (1 << 0)
  127. #define FUSE_WRITE_LOCKOWNER (1 << 1)
  128. /**
  129. * Read flags
  130. */
  131. #define FUSE_READ_LOCKOWNER (1 << 1)
  132. /**
  133. * Ioctl flags
  134. *
  135. * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
  136. * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
  137. * FUSE_IOCTL_RETRY: retry with new iovecs
  138. *
  139. * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
  140. */
  141. #define FUSE_IOCTL_COMPAT (1 << 0)
  142. #define FUSE_IOCTL_UNRESTRICTED (1 << 1)
  143. #define FUSE_IOCTL_RETRY (1 << 2)
  144. #define FUSE_IOCTL_MAX_IOV 256
  145. /**
  146. * Poll flags
  147. *
  148. * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify
  149. */
  150. #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
  151. enum fuse_opcode {
  152. FUSE_LOOKUP = 1,
  153. FUSE_FORGET = 2, /* no reply */
  154. FUSE_GETATTR = 3,
  155. FUSE_SETATTR = 4,
  156. FUSE_READLINK = 5,
  157. FUSE_SYMLINK = 6,
  158. FUSE_MKNOD = 8,
  159. FUSE_MKDIR = 9,
  160. FUSE_UNLINK = 10,
  161. FUSE_RMDIR = 11,
  162. FUSE_RENAME = 12,
  163. FUSE_LINK = 13,
  164. FUSE_OPEN = 14,
  165. FUSE_READ = 15,
  166. FUSE_WRITE = 16,
  167. FUSE_STATFS = 17,
  168. FUSE_RELEASE = 18,
  169. FUSE_FSYNC = 20,
  170. FUSE_SETXATTR = 21,
  171. FUSE_GETXATTR = 22,
  172. FUSE_LISTXATTR = 23,
  173. FUSE_REMOVEXATTR = 24,
  174. FUSE_FLUSH = 25,
  175. FUSE_INIT = 26,
  176. FUSE_OPENDIR = 27,
  177. FUSE_READDIR = 28,
  178. FUSE_RELEASEDIR = 29,
  179. FUSE_FSYNCDIR = 30,
  180. FUSE_GETLK = 31,
  181. FUSE_SETLK = 32,
  182. FUSE_SETLKW = 33,
  183. FUSE_ACCESS = 34,
  184. FUSE_CREATE = 35,
  185. FUSE_INTERRUPT = 36,
  186. FUSE_BMAP = 37,
  187. FUSE_DESTROY = 38,
  188. FUSE_IOCTL = 39,
  189. FUSE_POLL = 40,
  190. };
  191. enum fuse_notify_code {
  192. FUSE_NOTIFY_POLL = 1,
  193. FUSE_NOTIFY_CODE_MAX,
  194. };
  195. /* The read buffer is required to be at least 8k, but may be much larger */
  196. #define FUSE_MIN_READ_BUFFER 8192
  197. #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
  198. struct fuse_entry_out {
  199. __u64 nodeid; /* Inode ID */
  200. __u64 generation; /* Inode generation: nodeid:gen must
  201. be unique for the fs's lifetime */
  202. __u64 entry_valid; /* Cache timeout for the name */
  203. __u64 attr_valid; /* Cache timeout for the attributes */
  204. __u32 entry_valid_nsec;
  205. __u32 attr_valid_nsec;
  206. struct fuse_attr attr;
  207. };
  208. struct fuse_forget_in {
  209. __u64 nlookup;
  210. };
  211. struct fuse_getattr_in {
  212. __u32 getattr_flags;
  213. __u32 dummy;
  214. __u64 fh;
  215. };
  216. #define FUSE_COMPAT_ATTR_OUT_SIZE 96
  217. struct fuse_attr_out {
  218. __u64 attr_valid; /* Cache timeout for the attributes */
  219. __u32 attr_valid_nsec;
  220. __u32 dummy;
  221. struct fuse_attr attr;
  222. };
  223. struct fuse_mknod_in {
  224. __u32 mode;
  225. __u32 rdev;
  226. };
  227. struct fuse_mkdir_in {
  228. __u32 mode;
  229. __u32 padding;
  230. };
  231. struct fuse_rename_in {
  232. __u64 newdir;
  233. };
  234. struct fuse_link_in {
  235. __u64 oldnodeid;
  236. };
  237. struct fuse_setattr_in {
  238. __u32 valid;
  239. __u32 padding;
  240. __u64 fh;
  241. __u64 size;
  242. __u64 lock_owner;
  243. __u64 atime;
  244. __u64 mtime;
  245. __u64 unused2;
  246. __u32 atimensec;
  247. __u32 mtimensec;
  248. __u32 unused3;
  249. __u32 mode;
  250. __u32 unused4;
  251. __u32 uid;
  252. __u32 gid;
  253. __u32 unused5;
  254. };
  255. struct fuse_open_in {
  256. __u32 flags;
  257. __u32 mode;
  258. };
  259. struct fuse_open_out {
  260. __u64 fh;
  261. __u32 open_flags;
  262. __u32 padding;
  263. };
  264. struct fuse_release_in {
  265. __u64 fh;
  266. __u32 flags;
  267. __u32 release_flags;
  268. __u64 lock_owner;
  269. };
  270. struct fuse_flush_in {
  271. __u64 fh;
  272. __u32 unused;
  273. __u32 padding;
  274. __u64 lock_owner;
  275. };
  276. struct fuse_read_in {
  277. __u64 fh;
  278. __u64 offset;
  279. __u32 size;
  280. __u32 read_flags;
  281. __u64 lock_owner;
  282. __u32 flags;
  283. __u32 padding;
  284. };
  285. #define FUSE_COMPAT_WRITE_IN_SIZE 24
  286. struct fuse_write_in {
  287. __u64 fh;
  288. __u64 offset;
  289. __u32 size;
  290. __u32 write_flags;
  291. __u64 lock_owner;
  292. __u32 flags;
  293. __u32 padding;
  294. };
  295. struct fuse_write_out {
  296. __u32 size;
  297. __u32 padding;
  298. };
  299. #define FUSE_COMPAT_STATFS_SIZE 48
  300. struct fuse_statfs_out {
  301. struct fuse_kstatfs st;
  302. };
  303. struct fuse_fsync_in {
  304. __u64 fh;
  305. __u32 fsync_flags;
  306. __u32 padding;
  307. };
  308. struct fuse_setxattr_in {
  309. __u32 size;
  310. __u32 flags;
  311. };
  312. struct fuse_getxattr_in {
  313. __u32 size;
  314. __u32 padding;
  315. };
  316. struct fuse_getxattr_out {
  317. __u32 size;
  318. __u32 padding;
  319. };
  320. struct fuse_lk_in {
  321. __u64 fh;
  322. __u64 owner;
  323. struct fuse_file_lock lk;
  324. __u32 lk_flags;
  325. __u32 padding;
  326. };
  327. struct fuse_lk_out {
  328. struct fuse_file_lock lk;
  329. };
  330. struct fuse_access_in {
  331. __u32 mask;
  332. __u32 padding;
  333. };
  334. struct fuse_init_in {
  335. __u32 major;
  336. __u32 minor;
  337. __u32 max_readahead;
  338. __u32 flags;
  339. };
  340. struct fuse_init_out {
  341. __u32 major;
  342. __u32 minor;
  343. __u32 max_readahead;
  344. __u32 flags;
  345. __u32 unused;
  346. __u32 max_write;
  347. };
  348. struct fuse_interrupt_in {
  349. __u64 unique;
  350. };
  351. struct fuse_bmap_in {
  352. __u64 block;
  353. __u32 blocksize;
  354. __u32 padding;
  355. };
  356. struct fuse_bmap_out {
  357. __u64 block;
  358. };
  359. struct fuse_ioctl_in {
  360. __u64 fh;
  361. __u32 flags;
  362. __u32 cmd;
  363. __u64 arg;
  364. __u32 in_size;
  365. __u32 out_size;
  366. };
  367. struct fuse_ioctl_out {
  368. __s32 result;
  369. __u32 flags;
  370. __u32 in_iovs;
  371. __u32 out_iovs;
  372. };
  373. struct fuse_poll_in {
  374. __u64 fh;
  375. __u64 kh;
  376. __u32 flags;
  377. __u32 padding;
  378. };
  379. struct fuse_poll_out {
  380. __u32 revents;
  381. __u32 padding;
  382. };
  383. struct fuse_notify_poll_wakeup_out {
  384. __u64 kh;
  385. };
  386. struct fuse_in_header {
  387. __u32 len;
  388. __u32 opcode;
  389. __u64 unique;
  390. __u64 nodeid;
  391. __u32 uid;
  392. __u32 gid;
  393. __u32 pid;
  394. __u32 padding;
  395. };
  396. struct fuse_out_header {
  397. __u32 len;
  398. __s32 error;
  399. __u64 unique;
  400. };
  401. struct fuse_dirent {
  402. __u64 ino;
  403. __u64 off;
  404. __u32 namelen;
  405. __u32 type;
  406. char name[0];
  407. };
  408. #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
  409. #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
  410. #define FUSE_DIRENT_SIZE(d) \
  411. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
  412. #endif /* _LINUX_FUSE_H */