Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | FUSE: Filesystem in Userspace |
Miklos Szeredi | 149f607 | 2005-01-10 12:29:28 +0000 | [diff] [blame] | 3 | Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 4 | |
| 5 | This program can be distributed under the terms of the GNU GPL. |
| 6 | See the file COPYING. |
| 7 | */ |
| 8 | |
| 9 | /* This file defines the kernel interface of FUSE */ |
| 10 | |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 11 | #include <asm/types.h> |
| 12 | |
Miklos Szeredi | 8cffdb9 | 2001-11-09 14:49:18 +0000 | [diff] [blame] | 13 | /** Version number of this interface */ |
Miklos Szeredi | 3800902 | 2005-05-08 19:47:22 +0000 | [diff] [blame] | 14 | #define FUSE_KERNEL_VERSION 7 |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 15 | |
Miklos Szeredi | 2f3d940 | 2003-12-15 12:11:33 +0000 | [diff] [blame] | 16 | /** Minor version number of this interface */ |
Miklos Szeredi | e3b8309 | 2005-07-22 17:24:30 +0000 | [diff] [blame] | 17 | #define FUSE_KERNEL_MINOR_VERSION 2 |
Miklos Szeredi | 2f3d940 | 2003-12-15 12:11:33 +0000 | [diff] [blame] | 18 | |
Miklos Szeredi | a13d900 | 2004-11-02 17:32:03 +0000 | [diff] [blame] | 19 | /** The node ID of the root inode */ |
| 20 | #define FUSE_ROOT_ID 1 |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 21 | |
Miklos Szeredi | a25d4c2 | 2004-11-23 22:32:16 +0000 | [diff] [blame] | 22 | /** The major number of the fuse character device */ |
| 23 | #define FUSE_MAJOR 10 |
| 24 | |
| 25 | /** The minor number of the fuse character device */ |
| 26 | #define FUSE_MINOR 229 |
| 27 | |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 28 | /* Make sure all structures are padded to 64bit boundary, so 32bit |
| 29 | userspace works under 64bit kernels */ |
| 30 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 31 | struct fuse_attr { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 32 | __u64 ino; |
| 33 | __u64 size; |
| 34 | __u64 blocks; |
| 35 | __u64 atime; |
| 36 | __u64 mtime; |
| 37 | __u64 ctime; |
| 38 | __u32 atimensec; |
| 39 | __u32 mtimensec; |
| 40 | __u32 ctimensec; |
| 41 | __u32 mode; |
| 42 | __u32 nlink; |
| 43 | __u32 uid; |
| 44 | __u32 gid; |
| 45 | __u32 rdev; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
Miklos Szeredi | 24ed945 | 2002-10-07 10:24:26 +0000 | [diff] [blame] | 48 | struct fuse_kstatfs { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 49 | __u64 blocks; |
| 50 | __u64 bfree; |
| 51 | __u64 bavail; |
| 52 | __u64 files; |
| 53 | __u64 ffree; |
| 54 | __u32 bsize; |
| 55 | __u32 namelen; |
Miklos Szeredi | 24ed945 | 2002-10-07 10:24:26 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
Miklos Szeredi | e3b8309 | 2005-07-22 17:24:30 +0000 | [diff] [blame] | 58 | struct fuse_file_lock { |
| 59 | __u64 start; |
| 60 | __u64 end; |
| 61 | __u64 owner; |
| 62 | __u32 pid; |
| 63 | __u32 type; |
| 64 | }; |
| 65 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 66 | #define FATTR_MODE (1 << 0) |
| 67 | #define FATTR_UID (1 << 1) |
| 68 | #define FATTR_GID (1 << 2) |
| 69 | #define FATTR_SIZE (1 << 3) |
Miklos Szeredi | b595861 | 2004-02-20 14:10:49 +0000 | [diff] [blame] | 70 | #define FATTR_ATIME (1 << 4) |
| 71 | #define FATTR_MTIME (1 << 5) |
| 72 | #define FATTR_CTIME (1 << 6) |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 73 | |
Miklos Szeredi | e77cc07 | 2005-08-01 11:58:51 +0000 | [diff] [blame] | 74 | #define FOPEN_DIRECT_IO (1 << 0) |
| 75 | #define FOPEN_KEEP_CACHE (1 << 1) |
| 76 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 77 | enum fuse_opcode { |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 78 | FUSE_LOOKUP = 1, |
| 79 | FUSE_FORGET = 2, /* no reply */ |
| 80 | FUSE_GETATTR = 3, |
| 81 | FUSE_SETATTR = 4, |
| 82 | FUSE_READLINK = 5, |
| 83 | FUSE_SYMLINK = 6, |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 84 | FUSE_MKNOD = 8, |
| 85 | FUSE_MKDIR = 9, |
| 86 | FUSE_UNLINK = 10, |
| 87 | FUSE_RMDIR = 11, |
| 88 | FUSE_RENAME = 12, |
| 89 | FUSE_LINK = 13, |
| 90 | FUSE_OPEN = 14, |
| 91 | FUSE_READ = 15, |
| 92 | FUSE_WRITE = 16, |
| 93 | FUSE_STATFS = 17, |
Miklos Szeredi | 72cf5c9 | 2004-11-20 16:10:30 +0000 | [diff] [blame] | 94 | FUSE_RELEASE = 18, |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 95 | FUSE_FSYNC = 20, |
| 96 | FUSE_SETXATTR = 21, |
| 97 | FUSE_GETXATTR = 22, |
| 98 | FUSE_LISTXATTR = 23, |
| 99 | FUSE_REMOVEXATTR = 24, |
Miklos Szeredi | e2e4ac2 | 2004-05-18 08:45:28 +0000 | [diff] [blame] | 100 | FUSE_FLUSH = 25, |
Miklos Szeredi | 3ead28e | 2005-01-18 21:23:41 +0000 | [diff] [blame] | 101 | FUSE_INIT = 26, |
| 102 | FUSE_OPENDIR = 27, |
| 103 | FUSE_READDIR = 28, |
Miklos Szeredi | 4283ee7 | 2005-03-21 12:09:04 +0000 | [diff] [blame] | 104 | FUSE_RELEASEDIR = 29, |
Miklos Szeredi | e3b8309 | 2005-07-22 17:24:30 +0000 | [diff] [blame] | 105 | FUSE_FSYNCDIR = 30, |
| 106 | FUSE_GETLK = 31, |
| 107 | FUSE_SETLK = 32, |
Miklos Szeredi | 7b28eae | 2005-08-01 12:48:30 +0000 | [diff] [blame] | 108 | FUSE_SETLKW = 33, |
Miklos Szeredi | b0c52c5 | 2005-08-23 15:39:43 +0000 | [diff] [blame] | 109 | FUSE_ACCESS = 34, |
Miklos Szeredi | ecce1bf | 2005-08-25 15:19:06 +0000 | [diff] [blame^] | 110 | FUSE_CREATE = 35, |
| 111 | FUSE_FSETATTR = 36 |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | /* Conservative buffer size for the client */ |
| 115 | #define FUSE_MAX_IN 8192 |
| 116 | |
Miklos Szeredi | c26c14d | 2004-04-09 17:48:32 +0000 | [diff] [blame] | 117 | #define FUSE_NAME_MAX 1024 |
| 118 | #define FUSE_SYMLINK_MAX 4096 |
| 119 | #define FUSE_XATTR_SIZE_MAX 4096 |
| 120 | |
Miklos Szeredi | 254d5ed | 2004-03-02 11:11:24 +0000 | [diff] [blame] | 121 | struct fuse_entry_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 122 | __u64 nodeid; /* Inode ID */ |
| 123 | __u64 generation; /* Inode generation: nodeid:gen must |
| 124 | be unique for the fs's lifetime */ |
| 125 | __u64 entry_valid; /* Cache timeout for the name */ |
| 126 | __u64 attr_valid; /* Cache timeout for the attributes */ |
| 127 | __u32 entry_valid_nsec; |
| 128 | __u32 attr_valid_nsec; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 129 | struct fuse_attr attr; |
| 130 | }; |
| 131 | |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 132 | struct fuse_forget_in { |
Miklos Szeredi | 3800902 | 2005-05-08 19:47:22 +0000 | [diff] [blame] | 133 | __u64 nlookup; |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
Miklos Szeredi | 254d5ed | 2004-03-02 11:11:24 +0000 | [diff] [blame] | 136 | struct fuse_attr_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 137 | __u64 attr_valid; /* Cache timeout for the attributes */ |
| 138 | __u32 attr_valid_nsec; |
| 139 | __u32 dummy; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 140 | struct fuse_attr attr; |
| 141 | }; |
| 142 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 143 | struct fuse_mknod_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 144 | __u32 mode; |
| 145 | __u32 rdev; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 148 | struct fuse_mkdir_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 149 | __u32 mode; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 150 | __u32 padding; |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 151 | }; |
| 152 | |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 153 | struct fuse_rename_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 154 | __u64 newdir; |
Miklos Szeredi | 19dff1b | 2001-10-30 15:06:52 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
| 157 | struct fuse_link_in { |
Miklos Szeredi | ed6b5dd | 2005-01-26 17:07:59 +0000 | [diff] [blame] | 158 | __u64 oldnodeid; |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 161 | struct fuse_setattr_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 162 | __u32 valid; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 163 | __u32 padding; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 164 | struct fuse_attr attr; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 165 | }; |
| 166 | |
Miklos Szeredi | ecce1bf | 2005-08-25 15:19:06 +0000 | [diff] [blame^] | 167 | struct fuse_fsetattr_in { |
| 168 | __u64 fh; |
| 169 | struct fuse_setattr_in setattr; |
| 170 | }; |
| 171 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 172 | struct fuse_open_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 173 | __u32 flags; |
Miklos Szeredi | b0c52c5 | 2005-08-23 15:39:43 +0000 | [diff] [blame] | 174 | __u32 mode; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 175 | }; |
| 176 | |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 177 | struct fuse_open_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 178 | __u64 fh; |
| 179 | __u32 open_flags; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 180 | __u32 padding; |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 181 | }; |
| 182 | |
| 183 | struct fuse_release_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 184 | __u64 fh; |
| 185 | __u32 flags; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 186 | __u32 padding; |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 187 | }; |
| 188 | |
| 189 | struct fuse_flush_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 190 | __u64 fh; |
| 191 | __u32 flush_flags; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 192 | __u32 padding; |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 195 | struct fuse_read_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 196 | __u64 fh; |
| 197 | __u64 offset; |
| 198 | __u32 size; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 199 | __u32 padding; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 200 | }; |
| 201 | |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 202 | struct fuse_write_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 203 | __u64 fh; |
| 204 | __u64 offset; |
| 205 | __u32 size; |
| 206 | __u32 write_flags; |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 207 | }; |
| 208 | |
Miklos Szeredi | ad051c3 | 2004-07-02 09:22:50 +0000 | [diff] [blame] | 209 | struct fuse_write_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 210 | __u32 size; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 211 | __u32 padding; |
Miklos Szeredi | ad051c3 | 2004-07-02 09:22:50 +0000 | [diff] [blame] | 212 | }; |
| 213 | |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame] | 214 | struct fuse_statfs_out { |
Miklos Szeredi | 24ed945 | 2002-10-07 10:24:26 +0000 | [diff] [blame] | 215 | struct fuse_kstatfs st; |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame] | 216 | }; |
| 217 | |
Miklos Szeredi | 5e43f2c | 2003-12-12 14:06:41 +0000 | [diff] [blame] | 218 | struct fuse_fsync_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 219 | __u64 fh; |
| 220 | __u32 fsync_flags; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 221 | __u32 padding; |
Miklos Szeredi | 5e43f2c | 2003-12-12 14:06:41 +0000 | [diff] [blame] | 222 | }; |
| 223 | |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 224 | struct fuse_setxattr_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 225 | __u32 size; |
| 226 | __u32 flags; |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 227 | }; |
| 228 | |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 229 | struct fuse_getxattr_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 230 | __u32 size; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 231 | __u32 padding; |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | struct fuse_getxattr_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 235 | __u32 size; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 236 | __u32 padding; |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 237 | }; |
| 238 | |
Miklos Szeredi | e3b8309 | 2005-07-22 17:24:30 +0000 | [diff] [blame] | 239 | struct fuse_lk_in_out { |
| 240 | struct fuse_file_lock lk; |
| 241 | }; |
| 242 | |
Miklos Szeredi | 7b28eae | 2005-08-01 12:48:30 +0000 | [diff] [blame] | 243 | struct fuse_access_in { |
| 244 | __u32 mask; |
| 245 | __u32 padding; |
| 246 | }; |
| 247 | |
Miklos Szeredi | 3f0005f | 2005-01-04 19:24:31 +0000 | [diff] [blame] | 248 | struct fuse_init_in_out { |
| 249 | __u32 major; |
| 250 | __u32 minor; |
| 251 | }; |
| 252 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 253 | struct fuse_in_header { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 254 | __u32 len; |
| 255 | __u32 opcode; |
| 256 | __u64 unique; |
| 257 | __u64 nodeid; |
| 258 | __u32 uid; |
| 259 | __u32 gid; |
| 260 | __u32 pid; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 261 | __u32 padding; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 262 | }; |
| 263 | |
| 264 | struct fuse_out_header { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 265 | __u32 len; |
| 266 | __s32 error; |
| 267 | __u64 unique; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 268 | }; |
| 269 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 270 | struct fuse_dirent { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 271 | __u64 ino; |
Miklos Szeredi | eab72ef | 2005-03-31 19:59:12 +0000 | [diff] [blame] | 272 | __u64 off; |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 273 | __u32 namelen; |
| 274 | __u32 type; |
| 275 | char name[0]; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 276 | }; |
| 277 | |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 278 | #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name) |
| 279 | #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 280 | #define FUSE_DIRENT_SIZE(d) \ |
| 281 | FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) |