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 | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 14 | #define FUSE_KERNEL_VERSION 5 |
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 | e56818b | 2004-12-12 11:45:24 +0000 | [diff] [blame] | 17 | #define FUSE_KERNEL_MINOR_VERSION 1 |
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 | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 28 | struct fuse_attr { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 29 | __u64 ino; |
| 30 | __u64 size; |
| 31 | __u64 blocks; |
| 32 | __u64 atime; |
| 33 | __u64 mtime; |
| 34 | __u64 ctime; |
| 35 | __u32 atimensec; |
| 36 | __u32 mtimensec; |
| 37 | __u32 ctimensec; |
| 38 | __u32 mode; |
| 39 | __u32 nlink; |
| 40 | __u32 uid; |
| 41 | __u32 gid; |
| 42 | __u32 rdev; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
Miklos Szeredi | 24ed945 | 2002-10-07 10:24:26 +0000 | [diff] [blame] | 45 | struct fuse_kstatfs { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 46 | __u64 blocks; |
| 47 | __u64 bfree; |
| 48 | __u64 bavail; |
| 49 | __u64 files; |
| 50 | __u64 ffree; |
| 51 | __u32 bsize; |
| 52 | __u32 namelen; |
Miklos Szeredi | 24ed945 | 2002-10-07 10:24:26 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 55 | #define FATTR_MODE (1 << 0) |
| 56 | #define FATTR_UID (1 << 1) |
| 57 | #define FATTR_GID (1 << 2) |
| 58 | #define FATTR_SIZE (1 << 3) |
Miklos Szeredi | b595861 | 2004-02-20 14:10:49 +0000 | [diff] [blame] | 59 | #define FATTR_ATIME (1 << 4) |
| 60 | #define FATTR_MTIME (1 << 5) |
| 61 | #define FATTR_CTIME (1 << 6) |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 62 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 63 | enum fuse_opcode { |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 64 | FUSE_LOOKUP = 1, |
| 65 | FUSE_FORGET = 2, /* no reply */ |
| 66 | FUSE_GETATTR = 3, |
| 67 | FUSE_SETATTR = 4, |
| 68 | FUSE_READLINK = 5, |
| 69 | FUSE_SYMLINK = 6, |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 70 | FUSE_MKNOD = 8, |
| 71 | FUSE_MKDIR = 9, |
| 72 | FUSE_UNLINK = 10, |
| 73 | FUSE_RMDIR = 11, |
| 74 | FUSE_RENAME = 12, |
| 75 | FUSE_LINK = 13, |
| 76 | FUSE_OPEN = 14, |
| 77 | FUSE_READ = 15, |
| 78 | FUSE_WRITE = 16, |
| 79 | FUSE_STATFS = 17, |
Miklos Szeredi | 72cf5c9 | 2004-11-20 16:10:30 +0000 | [diff] [blame] | 80 | FUSE_RELEASE = 18, |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 81 | FUSE_FSYNC = 20, |
| 82 | FUSE_SETXATTR = 21, |
| 83 | FUSE_GETXATTR = 22, |
| 84 | FUSE_LISTXATTR = 23, |
| 85 | FUSE_REMOVEXATTR = 24, |
Miklos Szeredi | e2e4ac2 | 2004-05-18 08:45:28 +0000 | [diff] [blame] | 86 | FUSE_FLUSH = 25, |
Miklos Szeredi | 3ead28e | 2005-01-18 21:23:41 +0000 | [diff] [blame] | 87 | FUSE_INIT = 26, |
| 88 | FUSE_OPENDIR = 27, |
| 89 | FUSE_READDIR = 28, |
Miklos Szeredi | 4283ee7 | 2005-03-21 12:09:04 +0000 | [diff] [blame] | 90 | FUSE_RELEASEDIR = 29, |
| 91 | FUSE_FSYNCDIR = 30 |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | /* Conservative buffer size for the client */ |
| 95 | #define FUSE_MAX_IN 8192 |
| 96 | |
Miklos Szeredi | c26c14d | 2004-04-09 17:48:32 +0000 | [diff] [blame] | 97 | #define FUSE_NAME_MAX 1024 |
| 98 | #define FUSE_SYMLINK_MAX 4096 |
| 99 | #define FUSE_XATTR_SIZE_MAX 4096 |
| 100 | |
Miklos Szeredi | 254d5ed | 2004-03-02 11:11:24 +0000 | [diff] [blame] | 101 | struct fuse_entry_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 102 | __u64 nodeid; /* Inode ID */ |
| 103 | __u64 generation; /* Inode generation: nodeid:gen must |
| 104 | be unique for the fs's lifetime */ |
| 105 | __u64 entry_valid; /* Cache timeout for the name */ |
| 106 | __u64 attr_valid; /* Cache timeout for the attributes */ |
| 107 | __u32 entry_valid_nsec; |
| 108 | __u32 attr_valid_nsec; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 109 | struct fuse_attr attr; |
| 110 | }; |
| 111 | |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 112 | struct fuse_forget_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 113 | __u64 version; |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 114 | }; |
| 115 | |
Miklos Szeredi | 254d5ed | 2004-03-02 11:11:24 +0000 | [diff] [blame] | 116 | struct fuse_attr_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 117 | __u64 attr_valid; /* Cache timeout for the attributes */ |
| 118 | __u32 attr_valid_nsec; |
| 119 | __u32 dummy; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 120 | struct fuse_attr attr; |
| 121 | }; |
| 122 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 123 | struct fuse_mknod_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 124 | __u32 mode; |
| 125 | __u32 rdev; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 128 | struct fuse_mkdir_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 129 | __u32 mode; |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 132 | struct fuse_rename_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 133 | __u64 newdir; |
Miklos Szeredi | 19dff1b | 2001-10-30 15:06:52 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | struct fuse_link_in { |
Miklos Szeredi | ed6b5dd | 2005-01-26 17:07:59 +0000 | [diff] [blame] | 137 | __u64 oldnodeid; |
Miklos Szeredi | b483c93 | 2001-10-29 14:57:57 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 140 | struct fuse_setattr_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 141 | __u32 valid; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 142 | struct fuse_attr attr; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | struct fuse_open_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 146 | __u32 flags; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 149 | struct fuse_open_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 150 | __u64 fh; |
| 151 | __u32 open_flags; |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | struct fuse_release_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 155 | __u64 fh; |
| 156 | __u32 flags; |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | struct fuse_flush_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 160 | __u64 fh; |
| 161 | __u32 flush_flags; |
Miklos Szeredi | 209f5d0 | 2004-07-24 19:56:16 +0000 | [diff] [blame] | 162 | }; |
| 163 | |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 164 | struct fuse_read_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 165 | __u64 fh; |
| 166 | __u64 offset; |
| 167 | __u32 size; |
Miklos Szeredi | 5e18348 | 2001-10-31 14:52:35 +0000 | [diff] [blame] | 168 | }; |
| 169 | |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 170 | struct fuse_write_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 171 | __u64 fh; |
| 172 | __u64 offset; |
| 173 | __u32 size; |
| 174 | __u32 write_flags; |
Miklos Szeredi | a181e61 | 2001-11-06 12:03:23 +0000 | [diff] [blame] | 175 | }; |
| 176 | |
Miklos Szeredi | ad051c3 | 2004-07-02 09:22:50 +0000 | [diff] [blame] | 177 | struct fuse_write_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 178 | __u32 size; |
Miklos Szeredi | ad051c3 | 2004-07-02 09:22:50 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame] | 181 | struct fuse_statfs_out { |
Miklos Szeredi | 24ed945 | 2002-10-07 10:24:26 +0000 | [diff] [blame] | 182 | struct fuse_kstatfs st; |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame] | 183 | }; |
| 184 | |
Miklos Szeredi | 5e43f2c | 2003-12-12 14:06:41 +0000 | [diff] [blame] | 185 | struct fuse_fsync_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 186 | __u64 fh; |
| 187 | __u32 fsync_flags; |
Miklos Szeredi | 5e43f2c | 2003-12-12 14:06:41 +0000 | [diff] [blame] | 188 | }; |
| 189 | |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 190 | struct fuse_setxattr_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 191 | __u32 size; |
| 192 | __u32 flags; |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 195 | struct fuse_getxattr_in { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 196 | __u32 size; |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | struct fuse_getxattr_out { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 200 | __u32 size; |
Miklos Szeredi | 3ed8423 | 2004-03-30 15:17:26 +0000 | [diff] [blame] | 201 | }; |
| 202 | |
Miklos Szeredi | 3f0005f | 2005-01-04 19:24:31 +0000 | [diff] [blame] | 203 | struct fuse_init_in_out { |
| 204 | __u32 major; |
| 205 | __u32 minor; |
| 206 | }; |
| 207 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 208 | struct fuse_in_header { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 209 | __u32 len; |
| 210 | __u32 opcode; |
| 211 | __u64 unique; |
| 212 | __u64 nodeid; |
| 213 | __u32 uid; |
| 214 | __u32 gid; |
| 215 | __u32 pid; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 216 | }; |
| 217 | |
| 218 | struct fuse_out_header { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 219 | __u32 len; |
| 220 | __s32 error; |
| 221 | __u64 unique; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 222 | }; |
| 223 | |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 224 | struct fuse_dirent { |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 225 | __u64 ino; |
| 226 | __u32 namelen; |
| 227 | __u32 type; |
| 228 | char name[0]; |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 229 | }; |
| 230 | |
Miklos Szeredi | 0f62d72 | 2005-01-04 12:45:54 +0000 | [diff] [blame] | 231 | #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name) |
| 232 | #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) |
Miklos Szeredi | 85c74fc | 2001-10-28 19:44:14 +0000 | [diff] [blame] | 233 | #define FUSE_DIRENT_SIZE(d) \ |
| 234 | FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) |