fuse.h 6.7 KB

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