fuse.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2005 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. /** Version number of this interface */
  10. #define FUSE_KERNEL_VERSION 7
  11. /** Minor version number of this interface */
  12. #define FUSE_KERNEL_MINOR_VERSION 1
  13. /** The node ID of the root inode */
  14. #define FUSE_ROOT_ID 1
  15. /** The major number of the fuse character device */
  16. #define FUSE_MAJOR 10
  17. /** The minor number of the fuse character device */
  18. #define FUSE_MINOR 229
  19. /* Make sure all structures are padded to 64bit boundary, so 32bit
  20. userspace works under 64bit kernels */
  21. struct fuse_attr {
  22. __u64 ino;
  23. __u64 size;
  24. __u64 blocks;
  25. __u64 atime;
  26. __u64 mtime;
  27. __u64 ctime;
  28. __u32 atimensec;
  29. __u32 mtimensec;
  30. __u32 ctimensec;
  31. __u32 mode;
  32. __u32 nlink;
  33. __u32 uid;
  34. __u32 gid;
  35. __u32 rdev;
  36. };
  37. struct fuse_kstatfs {
  38. __u64 blocks;
  39. __u64 bfree;
  40. __u64 bavail;
  41. __u64 files;
  42. __u64 ffree;
  43. __u32 bsize;
  44. __u32 namelen;
  45. };
  46. #define FATTR_MODE (1 << 0)
  47. #define FATTR_UID (1 << 1)
  48. #define FATTR_GID (1 << 2)
  49. #define FATTR_SIZE (1 << 3)
  50. #define FATTR_ATIME (1 << 4)
  51. #define FATTR_MTIME (1 << 5)
  52. #define FATTR_CTIME (1 << 6)
  53. enum fuse_opcode {
  54. FUSE_LOOKUP = 1,
  55. FUSE_FORGET = 2, /* no reply */
  56. FUSE_GETATTR = 3,
  57. FUSE_SETATTR = 4,
  58. FUSE_READLINK = 5,
  59. FUSE_SYMLINK = 6,
  60. FUSE_GETDIR = 7,
  61. FUSE_MKNOD = 8,
  62. FUSE_MKDIR = 9,
  63. FUSE_UNLINK = 10,
  64. FUSE_RMDIR = 11,
  65. FUSE_RENAME = 12,
  66. FUSE_LINK = 13,
  67. FUSE_OPEN = 14,
  68. FUSE_READ = 15,
  69. FUSE_WRITE = 16,
  70. FUSE_STATFS = 17,
  71. FUSE_RELEASE = 18,
  72. FUSE_FSYNC = 20,
  73. FUSE_SETXATTR = 21,
  74. FUSE_GETXATTR = 22,
  75. FUSE_LISTXATTR = 23,
  76. FUSE_REMOVEXATTR = 24,
  77. FUSE_FLUSH = 25,
  78. FUSE_INIT = 26
  79. };
  80. /* Conservative buffer size for the client */
  81. #define FUSE_MAX_IN 8192
  82. #define FUSE_NAME_MAX 1024
  83. #define FUSE_SYMLINK_MAX 4096
  84. #define FUSE_XATTR_SIZE_MAX 4096
  85. struct fuse_entry_out {
  86. __u64 nodeid; /* Inode ID */
  87. __u64 generation; /* Inode generation: nodeid:gen must
  88. be unique for the fs's lifetime */
  89. __u64 entry_valid; /* Cache timeout for the name */
  90. __u64 attr_valid; /* Cache timeout for the attributes */
  91. __u32 entry_valid_nsec;
  92. __u32 attr_valid_nsec;
  93. struct fuse_attr attr;
  94. };
  95. struct fuse_forget_in {
  96. __u64 nlookup;
  97. };
  98. struct fuse_attr_out {
  99. __u64 attr_valid; /* Cache timeout for the attributes */
  100. __u32 attr_valid_nsec;
  101. __u32 dummy;
  102. struct fuse_attr attr;
  103. };
  104. struct fuse_getdir_out {
  105. __u32 fd;
  106. };
  107. struct fuse_mknod_in {
  108. __u32 mode;
  109. __u32 rdev;
  110. };
  111. struct fuse_mkdir_in {
  112. __u32 mode;
  113. __u32 padding;
  114. };
  115. struct fuse_rename_in {
  116. __u64 newdir;
  117. };
  118. struct fuse_link_in {
  119. __u64 oldnodeid;
  120. };
  121. struct fuse_setattr_in {
  122. __u32 valid;
  123. __u32 padding;
  124. struct fuse_attr attr;
  125. };
  126. struct fuse_open_in {
  127. __u32 flags;
  128. __u32 padding;
  129. };
  130. struct fuse_open_out {
  131. __u64 fh;
  132. __u32 open_flags;
  133. __u32 padding;
  134. };
  135. struct fuse_release_in {
  136. __u64 fh;
  137. __u32 flags;
  138. __u32 padding;
  139. };
  140. struct fuse_flush_in {
  141. __u64 fh;
  142. __u32 flush_flags;
  143. __u32 padding;
  144. };
  145. struct fuse_read_in {
  146. __u64 fh;
  147. __u64 offset;
  148. __u32 size;
  149. __u32 padding;
  150. };
  151. struct fuse_write_in {
  152. __u64 fh;
  153. __u64 offset;
  154. __u32 size;
  155. __u32 write_flags;
  156. };
  157. struct fuse_write_out {
  158. __u32 size;
  159. __u32 padding;
  160. };
  161. struct fuse_statfs_out {
  162. struct fuse_kstatfs st;
  163. };
  164. struct fuse_fsync_in {
  165. __u64 fh;
  166. __u32 fsync_flags;
  167. __u32 padding;
  168. };
  169. struct fuse_setxattr_in {
  170. __u32 size;
  171. __u32 flags;
  172. };
  173. struct fuse_getxattr_in {
  174. __u32 size;
  175. __u32 padding;
  176. };
  177. struct fuse_getxattr_out {
  178. __u32 size;
  179. __u32 padding;
  180. };
  181. struct fuse_init_in_out {
  182. __u32 major;
  183. __u32 minor;
  184. };
  185. struct fuse_in_header {
  186. __u32 len;
  187. __u32 opcode;
  188. __u64 unique;
  189. __u64 nodeid;
  190. __u32 uid;
  191. __u32 gid;
  192. __u32 pid;
  193. __u32 padding;
  194. };
  195. struct fuse_out_header {
  196. __u32 len;
  197. __s32 error;
  198. __u64 unique;
  199. };
  200. struct fuse_dirent {
  201. __u64 ino;
  202. __u64 off;
  203. __u32 namelen;
  204. __u32 type;
  205. char name[0];
  206. };
  207. #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
  208. #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
  209. #define FUSE_DIRENT_SIZE(d) \
  210. FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)