fuse.h 5.5 KB

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