fuse: add atomic open+truncate support
[linux-2.6/kvm.git] / include / linux / fuse.h
blob436047093bc4ddd44a7fff743e52abcb2910f93e
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7 */
9 /*
10 * This file defines the kernel interface of FUSE
12 * Protocol changelog:
14 * 7.9:
15 * - new fuse_getattr_in input argument of GETATTR
18 #include <asm/types.h>
19 #include <linux/major.h>
21 /** Version number of this interface */
22 #define FUSE_KERNEL_VERSION 7
24 /** Minor version number of this interface */
25 #define FUSE_KERNEL_MINOR_VERSION 9
27 /** The node ID of the root inode */
28 #define FUSE_ROOT_ID 1
30 /** The major number of the fuse character device */
31 #define FUSE_MAJOR MISC_MAJOR
33 /** The minor number of the fuse character device */
34 #define FUSE_MINOR 229
36 /* Make sure all structures are padded to 64bit boundary, so 32bit
37 userspace works under 64bit kernels */
39 struct fuse_attr {
40 __u64 ino;
41 __u64 size;
42 __u64 blocks;
43 __u64 atime;
44 __u64 mtime;
45 __u64 ctime;
46 __u32 atimensec;
47 __u32 mtimensec;
48 __u32 ctimensec;
49 __u32 mode;
50 __u32 nlink;
51 __u32 uid;
52 __u32 gid;
53 __u32 rdev;
56 struct fuse_kstatfs {
57 __u64 blocks;
58 __u64 bfree;
59 __u64 bavail;
60 __u64 files;
61 __u64 ffree;
62 __u32 bsize;
63 __u32 namelen;
64 __u32 frsize;
65 __u32 padding;
66 __u32 spare[6];
69 struct fuse_file_lock {
70 __u64 start;
71 __u64 end;
72 __u32 type;
73 __u32 pid; /* tgid */
76 /**
77 * Bitmasks for fuse_setattr_in.valid
79 #define FATTR_MODE (1 << 0)
80 #define FATTR_UID (1 << 1)
81 #define FATTR_GID (1 << 2)
82 #define FATTR_SIZE (1 << 3)
83 #define FATTR_ATIME (1 << 4)
84 #define FATTR_MTIME (1 << 5)
85 #define FATTR_FH (1 << 6)
86 #define FATTR_ATIME_NOW (1 << 7)
87 #define FATTR_MTIME_NOW (1 << 8)
89 /**
90 * Flags returned by the OPEN request
92 * FOPEN_DIRECT_IO: bypass page cache for this open file
93 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
95 #define FOPEN_DIRECT_IO (1 << 0)
96 #define FOPEN_KEEP_CACHE (1 << 1)
98 /**
99 * INIT request/reply flags
101 #define FUSE_ASYNC_READ (1 << 0)
102 #define FUSE_POSIX_LOCKS (1 << 1)
103 #define FUSE_FILE_OPS (1 << 2)
104 #define FUSE_ATOMIC_O_TRUNC (1 << 3)
107 * Release flags
109 #define FUSE_RELEASE_FLUSH (1 << 0)
112 * Getattr flags
114 #define FUSE_GETATTR_FH (1 << 0)
116 enum fuse_opcode {
117 FUSE_LOOKUP = 1,
118 FUSE_FORGET = 2, /* no reply */
119 FUSE_GETATTR = 3,
120 FUSE_SETATTR = 4,
121 FUSE_READLINK = 5,
122 FUSE_SYMLINK = 6,
123 FUSE_MKNOD = 8,
124 FUSE_MKDIR = 9,
125 FUSE_UNLINK = 10,
126 FUSE_RMDIR = 11,
127 FUSE_RENAME = 12,
128 FUSE_LINK = 13,
129 FUSE_OPEN = 14,
130 FUSE_READ = 15,
131 FUSE_WRITE = 16,
132 FUSE_STATFS = 17,
133 FUSE_RELEASE = 18,
134 FUSE_FSYNC = 20,
135 FUSE_SETXATTR = 21,
136 FUSE_GETXATTR = 22,
137 FUSE_LISTXATTR = 23,
138 FUSE_REMOVEXATTR = 24,
139 FUSE_FLUSH = 25,
140 FUSE_INIT = 26,
141 FUSE_OPENDIR = 27,
142 FUSE_READDIR = 28,
143 FUSE_RELEASEDIR = 29,
144 FUSE_FSYNCDIR = 30,
145 FUSE_GETLK = 31,
146 FUSE_SETLK = 32,
147 FUSE_SETLKW = 33,
148 FUSE_ACCESS = 34,
149 FUSE_CREATE = 35,
150 FUSE_INTERRUPT = 36,
151 FUSE_BMAP = 37,
152 FUSE_DESTROY = 38,
155 /* The read buffer is required to be at least 8k, but may be much larger */
156 #define FUSE_MIN_READ_BUFFER 8192
158 struct fuse_entry_out {
159 __u64 nodeid; /* Inode ID */
160 __u64 generation; /* Inode generation: nodeid:gen must
161 be unique for the fs's lifetime */
162 __u64 entry_valid; /* Cache timeout for the name */
163 __u64 attr_valid; /* Cache timeout for the attributes */
164 __u32 entry_valid_nsec;
165 __u32 attr_valid_nsec;
166 struct fuse_attr attr;
169 struct fuse_forget_in {
170 __u64 nlookup;
173 struct fuse_getattr_in {
174 __u32 getattr_flags;
175 __u32 dummy;
176 __u64 fh;
179 struct fuse_attr_out {
180 __u64 attr_valid; /* Cache timeout for the attributes */
181 __u32 attr_valid_nsec;
182 __u32 dummy;
183 struct fuse_attr attr;
186 struct fuse_mknod_in {
187 __u32 mode;
188 __u32 rdev;
191 struct fuse_mkdir_in {
192 __u32 mode;
193 __u32 padding;
196 struct fuse_rename_in {
197 __u64 newdir;
200 struct fuse_link_in {
201 __u64 oldnodeid;
204 struct fuse_setattr_in {
205 __u32 valid;
206 __u32 padding;
207 __u64 fh;
208 __u64 size;
209 __u64 unused1;
210 __u64 atime;
211 __u64 mtime;
212 __u64 unused2;
213 __u32 atimensec;
214 __u32 mtimensec;
215 __u32 unused3;
216 __u32 mode;
217 __u32 unused4;
218 __u32 uid;
219 __u32 gid;
220 __u32 unused5;
223 struct fuse_open_in {
224 __u32 flags;
225 __u32 mode;
228 struct fuse_open_out {
229 __u64 fh;
230 __u32 open_flags;
231 __u32 padding;
234 struct fuse_release_in {
235 __u64 fh;
236 __u32 flags;
237 __u32 release_flags;
238 __u64 lock_owner;
241 struct fuse_flush_in {
242 __u64 fh;
243 __u32 unused;
244 __u32 padding;
245 __u64 lock_owner;
248 struct fuse_read_in {
249 __u64 fh;
250 __u64 offset;
251 __u32 size;
252 __u32 padding;
255 struct fuse_write_in {
256 __u64 fh;
257 __u64 offset;
258 __u32 size;
259 __u32 write_flags;
262 struct fuse_write_out {
263 __u32 size;
264 __u32 padding;
267 #define FUSE_COMPAT_STATFS_SIZE 48
269 struct fuse_statfs_out {
270 struct fuse_kstatfs st;
273 struct fuse_fsync_in {
274 __u64 fh;
275 __u32 fsync_flags;
276 __u32 padding;
279 struct fuse_setxattr_in {
280 __u32 size;
281 __u32 flags;
284 struct fuse_getxattr_in {
285 __u32 size;
286 __u32 padding;
289 struct fuse_getxattr_out {
290 __u32 size;
291 __u32 padding;
294 struct fuse_lk_in {
295 __u64 fh;
296 __u64 owner;
297 struct fuse_file_lock lk;
300 struct fuse_lk_out {
301 struct fuse_file_lock lk;
304 struct fuse_access_in {
305 __u32 mask;
306 __u32 padding;
309 struct fuse_init_in {
310 __u32 major;
311 __u32 minor;
312 __u32 max_readahead;
313 __u32 flags;
316 struct fuse_init_out {
317 __u32 major;
318 __u32 minor;
319 __u32 max_readahead;
320 __u32 flags;
321 __u32 unused;
322 __u32 max_write;
325 struct fuse_interrupt_in {
326 __u64 unique;
329 struct fuse_bmap_in {
330 __u64 block;
331 __u32 blocksize;
332 __u32 padding;
335 struct fuse_bmap_out {
336 __u64 block;
339 struct fuse_in_header {
340 __u32 len;
341 __u32 opcode;
342 __u64 unique;
343 __u64 nodeid;
344 __u32 uid;
345 __u32 gid;
346 __u32 pid;
347 __u32 padding;
350 struct fuse_out_header {
351 __u32 len;
352 __s32 error;
353 __u64 unique;
356 struct fuse_dirent {
357 __u64 ino;
358 __u64 off;
359 __u32 namelen;
360 __u32 type;
361 char name[0];
364 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
365 #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
366 #define FUSE_DIRENT_SIZE(d) \
367 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)