fuse.h 6.0 KB

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