fuse.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. };
  114. /* The read buffer is required to be at least 8k, but may be much larger */
  115. #define FUSE_MIN_READ_BUFFER 8192
  116. struct fuse_entry_out {
  117. __u64 nodeid; /* Inode ID */
  118. __u64 generation; /* Inode generation: nodeid:gen must
  119. be unique for the fs's lifetime */
  120. __u64 entry_valid; /* Cache timeout for the name */
  121. __u64 attr_valid; /* Cache timeout for the attributes */
  122. __u32 entry_valid_nsec;
  123. __u32 attr_valid_nsec;
  124. struct fuse_attr attr;
  125. };
  126. struct fuse_forget_in {
  127. __u64 nlookup;
  128. };
  129. struct fuse_attr_out {
  130. __u64 attr_valid; /* Cache timeout for the attributes */
  131. __u32 attr_valid_nsec;
  132. __u32 dummy;
  133. struct fuse_attr attr;
  134. };
  135. struct fuse_mknod_in {
  136. __u32 mode;
  137. __u32 rdev;
  138. };
  139. struct fuse_mkdir_in {
  140. __u32 mode;
  141. __u32 padding;
  142. };
  143. struct fuse_rename_in {
  144. __u64 newdir;
  145. };
  146. struct fuse_link_in {
  147. __u64 oldnodeid;
  148. };
  149. struct fuse_setattr_in {
  150. __u32 valid;
  151. __u32 padding;
  152. __u64 fh;
  153. __u64 size;
  154. __u64 unused1;
  155. __u64 atime;
  156. __u64 mtime;
  157. __u64 unused2;
  158. __u32 atimensec;
  159. __u32 mtimensec;
  160. __u32 unused3;
  161. __u32 mode;
  162. __u32 unused4;
  163. __u32 uid;
  164. __u32 gid;
  165. __u32 unused5;
  166. };
  167. struct fuse_open_in {
  168. __u32 flags;
  169. __u32 mode;
  170. };
  171. struct fuse_open_out {
  172. __u64 fh;
  173. __u32 open_flags;
  174. __u32 padding;
  175. };
  176. struct fuse_release_in {
  177. __u64 fh;
  178. __u32 flags;
  179. __u32 padding;
  180. };
  181. struct fuse_flush_in {
  182. __u64 fh;
  183. __u32 flush_flags;
  184. __u32 padding;
  185. __u64 lock_owner;
  186. };
  187. struct fuse_read_in {
  188. __u64 fh;
  189. __u64 offset;
  190. __u32 size;
  191. __u32 padding;
  192. };
  193. struct fuse_write_in {
  194. __u64 fh;
  195. __u64 offset;
  196. __u32 size;
  197. __u32 write_flags;
  198. };
  199. struct fuse_write_out {
  200. __u32 size;
  201. __u32 padding;
  202. };
  203. #define FUSE_COMPAT_STATFS_SIZE 48
  204. struct fuse_statfs_out {
  205. struct fuse_kstatfs st;
  206. };
  207. struct fuse_fsync_in {
  208. __u64 fh;
  209. __u32 fsync_flags;
  210. __u32 padding;
  211. };
  212. struct fuse_setxattr_in {
  213. __u32 size;
  214. __u32 flags;
  215. };
  216. struct fuse_getxattr_in {
  217. __u32 size;
  218. __u32 padding;
  219. };
  220. struct fuse_getxattr_out {
  221. __u32 size;
  222. __u32 padding;
  223. };
  224. struct fuse_lk_in {
  225. __u64 fh;
  226. __u64 owner;
  227. struct fuse_file_lock lk;
  228. };
  229. struct fuse_lk_out {
  230. struct fuse_file_lock lk;
  231. };
  232. struct fuse_access_in {
  233. __u32 mask;
  234. __u32 padding;
  235. };
  236. struct fuse_init_in {
  237. __u32 major;
  238. __u32 minor;
  239. __u32 max_readahead;
  240. __u32 flags;
  241. };
  242. struct fuse_init_out {
  243. __u32 major;
  244. __u32 minor;
  245. __u32 max_readahead;
  246. __u32 flags;
  247. __u32 unused;
  248. __u32 max_write;
  249. };
  250. struct fuse_in_header {
  251. __u32 len;
  252. __u32 opcode;
  253. __u64 unique;
  254. __u64 nodeid;
  255. __u32 uid;
  256. __u32 gid;
  257. __u32 pid;
  258. __u32 padding;
  259. };
  260. struct fuse_out_header {
  261. __u32 len;
  262. __s32 error;
  263. __u64 unique;
  264. };
  265. struct fuse_dirent {
  266. __u64 ino;
  267. __u64 off;
  268. __u32 namelen;
  269. __u32 type;
  270. char name[0];
  271. };
  272. #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
  273. #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
  274. #define FUSE_DIRENT_SIZE(d) \
  275. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)