fuse.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 8
  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. /**
  80. * Release flags
  81. */
  82. #define FUSE_RELEASE_FLUSH (1 << 0)
  83. enum fuse_opcode {
  84. FUSE_LOOKUP = 1,
  85. FUSE_FORGET = 2, /* no reply */
  86. FUSE_GETATTR = 3,
  87. FUSE_SETATTR = 4,
  88. FUSE_READLINK = 5,
  89. FUSE_SYMLINK = 6,
  90. FUSE_MKNOD = 8,
  91. FUSE_MKDIR = 9,
  92. FUSE_UNLINK = 10,
  93. FUSE_RMDIR = 11,
  94. FUSE_RENAME = 12,
  95. FUSE_LINK = 13,
  96. FUSE_OPEN = 14,
  97. FUSE_READ = 15,
  98. FUSE_WRITE = 16,
  99. FUSE_STATFS = 17,
  100. FUSE_RELEASE = 18,
  101. FUSE_FSYNC = 20,
  102. FUSE_SETXATTR = 21,
  103. FUSE_GETXATTR = 22,
  104. FUSE_LISTXATTR = 23,
  105. FUSE_REMOVEXATTR = 24,
  106. FUSE_FLUSH = 25,
  107. FUSE_INIT = 26,
  108. FUSE_OPENDIR = 27,
  109. FUSE_READDIR = 28,
  110. FUSE_RELEASEDIR = 29,
  111. FUSE_FSYNCDIR = 30,
  112. FUSE_GETLK = 31,
  113. FUSE_SETLK = 32,
  114. FUSE_SETLKW = 33,
  115. FUSE_ACCESS = 34,
  116. FUSE_CREATE = 35,
  117. FUSE_INTERRUPT = 36,
  118. FUSE_BMAP = 37,
  119. FUSE_DESTROY = 38,
  120. };
  121. /* The read buffer is required to be at least 8k, but may be much larger */
  122. #define FUSE_MIN_READ_BUFFER 8192
  123. struct fuse_entry_out {
  124. __u64 nodeid; /* Inode ID */
  125. __u64 generation; /* Inode generation: nodeid:gen must
  126. be unique for the fs's lifetime */
  127. __u64 entry_valid; /* Cache timeout for the name */
  128. __u64 attr_valid; /* Cache timeout for the attributes */
  129. __u32 entry_valid_nsec;
  130. __u32 attr_valid_nsec;
  131. struct fuse_attr attr;
  132. };
  133. struct fuse_forget_in {
  134. __u64 nlookup;
  135. };
  136. struct fuse_attr_out {
  137. __u64 attr_valid; /* Cache timeout for the attributes */
  138. __u32 attr_valid_nsec;
  139. __u32 dummy;
  140. struct fuse_attr attr;
  141. };
  142. struct fuse_mknod_in {
  143. __u32 mode;
  144. __u32 rdev;
  145. };
  146. struct fuse_mkdir_in {
  147. __u32 mode;
  148. __u32 padding;
  149. };
  150. struct fuse_rename_in {
  151. __u64 newdir;
  152. };
  153. struct fuse_link_in {
  154. __u64 oldnodeid;
  155. };
  156. struct fuse_setattr_in {
  157. __u32 valid;
  158. __u32 padding;
  159. __u64 fh;
  160. __u64 size;
  161. __u64 unused1;
  162. __u64 atime;
  163. __u64 mtime;
  164. __u64 unused2;
  165. __u32 atimensec;
  166. __u32 mtimensec;
  167. __u32 unused3;
  168. __u32 mode;
  169. __u32 unused4;
  170. __u32 uid;
  171. __u32 gid;
  172. __u32 unused5;
  173. };
  174. struct fuse_open_in {
  175. __u32 flags;
  176. __u32 mode;
  177. };
  178. struct fuse_open_out {
  179. __u64 fh;
  180. __u32 open_flags;
  181. __u32 padding;
  182. };
  183. struct fuse_release_in {
  184. __u64 fh;
  185. __u32 flags;
  186. __u32 release_flags;
  187. __u64 lock_owner;
  188. };
  189. struct fuse_flush_in {
  190. __u64 fh;
  191. __u32 unused;
  192. __u32 padding;
  193. __u64 lock_owner;
  194. };
  195. struct fuse_read_in {
  196. __u64 fh;
  197. __u64 offset;
  198. __u32 size;
  199. __u32 padding;
  200. };
  201. struct fuse_write_in {
  202. __u64 fh;
  203. __u64 offset;
  204. __u32 size;
  205. __u32 write_flags;
  206. };
  207. struct fuse_write_out {
  208. __u32 size;
  209. __u32 padding;
  210. };
  211. #define FUSE_COMPAT_STATFS_SIZE 48
  212. struct fuse_statfs_out {
  213. struct fuse_kstatfs st;
  214. };
  215. struct fuse_fsync_in {
  216. __u64 fh;
  217. __u32 fsync_flags;
  218. __u32 padding;
  219. };
  220. struct fuse_setxattr_in {
  221. __u32 size;
  222. __u32 flags;
  223. };
  224. struct fuse_getxattr_in {
  225. __u32 size;
  226. __u32 padding;
  227. };
  228. struct fuse_getxattr_out {
  229. __u32 size;
  230. __u32 padding;
  231. };
  232. struct fuse_lk_in {
  233. __u64 fh;
  234. __u64 owner;
  235. struct fuse_file_lock lk;
  236. };
  237. struct fuse_lk_out {
  238. struct fuse_file_lock lk;
  239. };
  240. struct fuse_access_in {
  241. __u32 mask;
  242. __u32 padding;
  243. };
  244. struct fuse_init_in {
  245. __u32 major;
  246. __u32 minor;
  247. __u32 max_readahead;
  248. __u32 flags;
  249. };
  250. struct fuse_init_out {
  251. __u32 major;
  252. __u32 minor;
  253. __u32 max_readahead;
  254. __u32 flags;
  255. __u32 unused;
  256. __u32 max_write;
  257. };
  258. struct fuse_interrupt_in {
  259. __u64 unique;
  260. };
  261. struct fuse_bmap_in {
  262. __u64 block;
  263. __u32 blocksize;
  264. __u32 padding;
  265. };
  266. struct fuse_bmap_out {
  267. __u64 block;
  268. };
  269. struct fuse_in_header {
  270. __u32 len;
  271. __u32 opcode;
  272. __u64 unique;
  273. __u64 nodeid;
  274. __u32 uid;
  275. __u32 gid;
  276. __u32 pid;
  277. __u32 padding;
  278. };
  279. struct fuse_out_header {
  280. __u32 len;
  281. __s32 error;
  282. __u64 unique;
  283. };
  284. struct fuse_dirent {
  285. __u64 ino;
  286. __u64 off;
  287. __u32 namelen;
  288. __u32 type;
  289. char name[0];
  290. };
  291. #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
  292. #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
  293. #define FUSE_DIRENT_SIZE(d) \
  294. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)