fuse.h 9.4 KB

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