fuse.h 7.8 KB

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