fuse: improve utimes support
[safe/jmp/linux-2.6] / include / linux / fuse.h
1 /*
2     FUSE: Filesystem in Userspace
3     Copyright (C) 2001-2006  Miklos Szeredi <miklos@szeredi.hu>
4
5     This program can be distributed under the terms of the GNU GPL.
6     See the file COPYING.
7 */
8
9 /*
10  * This file defines the kernel interface of FUSE
11  *
12  * Protocol changelog:
13  *
14  * 7.9:
15  *  - new fuse_getattr_in input argument of GETATTR
16  */
17
18 #include <asm/types.h>
19 #include <linux/major.h>
20
21 /** Version number of this interface */
22 #define FUSE_KERNEL_VERSION 7
23
24 /** Minor version number of this interface */
25 #define FUSE_KERNEL_MINOR_VERSION 9
26
27 /** The node ID of the root inode */
28 #define FUSE_ROOT_ID 1
29
30 /** The major number of the fuse character device */
31 #define FUSE_MAJOR MISC_MAJOR
32
33 /** The minor number of the fuse character device */
34 #define FUSE_MINOR 229
35
36 /* Make sure all structures are padded to 64bit boundary, so 32bit
37    userspace works under 64bit kernels */
38
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;
54 };
55
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];
67 };
68
69 struct fuse_file_lock {
70         __u64   start;
71         __u64   end;
72         __u32   type;
73         __u32   pid; /* tgid */
74 };
75
76 /**
77  * Bitmasks for fuse_setattr_in.valid
78  */
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)
88
89 /**
90  * Flags returned by the OPEN request
91  *
92  * FOPEN_DIRECT_IO: bypass page cache for this open file
93  * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
94  */
95 #define FOPEN_DIRECT_IO         (1 << 0)
96 #define FOPEN_KEEP_CACHE        (1 << 1)
97
98 /**
99  * INIT request/reply flags
100  */
101 #define FUSE_ASYNC_READ         (1 << 0)
102 #define FUSE_POSIX_LOCKS        (1 << 1)
103 #define FUSE_FILE_OPS           (1 << 2)
104
105 /**
106  * Release flags
107  */
108 #define FUSE_RELEASE_FLUSH      (1 << 0)
109
110 /**
111  * Getattr flags
112  */
113 #define FUSE_GETATTR_FH         (1 << 0)
114
115 enum fuse_opcode {
116         FUSE_LOOKUP        = 1,
117         FUSE_FORGET        = 2,  /* no reply */
118         FUSE_GETATTR       = 3,
119         FUSE_SETATTR       = 4,
120         FUSE_READLINK      = 5,
121         FUSE_SYMLINK       = 6,
122         FUSE_MKNOD         = 8,
123         FUSE_MKDIR         = 9,
124         FUSE_UNLINK        = 10,
125         FUSE_RMDIR         = 11,
126         FUSE_RENAME        = 12,
127         FUSE_LINK          = 13,
128         FUSE_OPEN          = 14,
129         FUSE_READ          = 15,
130         FUSE_WRITE         = 16,
131         FUSE_STATFS        = 17,
132         FUSE_RELEASE       = 18,
133         FUSE_FSYNC         = 20,
134         FUSE_SETXATTR      = 21,
135         FUSE_GETXATTR      = 22,
136         FUSE_LISTXATTR     = 23,
137         FUSE_REMOVEXATTR   = 24,
138         FUSE_FLUSH         = 25,
139         FUSE_INIT          = 26,
140         FUSE_OPENDIR       = 27,
141         FUSE_READDIR       = 28,
142         FUSE_RELEASEDIR    = 29,
143         FUSE_FSYNCDIR      = 30,
144         FUSE_GETLK         = 31,
145         FUSE_SETLK         = 32,
146         FUSE_SETLKW        = 33,
147         FUSE_ACCESS        = 34,
148         FUSE_CREATE        = 35,
149         FUSE_INTERRUPT     = 36,
150         FUSE_BMAP          = 37,
151         FUSE_DESTROY       = 38,
152 };
153
154 /* The read buffer is required to be at least 8k, but may be much larger */
155 #define FUSE_MIN_READ_BUFFER 8192
156
157 struct fuse_entry_out {
158         __u64   nodeid;         /* Inode ID */
159         __u64   generation;     /* Inode generation: nodeid:gen must
160                                    be unique for the fs's lifetime */
161         __u64   entry_valid;    /* Cache timeout for the name */
162         __u64   attr_valid;     /* Cache timeout for the attributes */
163         __u32   entry_valid_nsec;
164         __u32   attr_valid_nsec;
165         struct fuse_attr attr;
166 };
167
168 struct fuse_forget_in {
169         __u64   nlookup;
170 };
171
172 struct fuse_getattr_in {
173         __u32   getattr_flags;
174         __u32   dummy;
175         __u64   fh;
176 };
177
178 struct fuse_attr_out {
179         __u64   attr_valid;     /* Cache timeout for the attributes */
180         __u32   attr_valid_nsec;
181         __u32   dummy;
182         struct fuse_attr attr;
183 };
184
185 struct fuse_mknod_in {
186         __u32   mode;
187         __u32   rdev;
188 };
189
190 struct fuse_mkdir_in {
191         __u32   mode;
192         __u32   padding;
193 };
194
195 struct fuse_rename_in {
196         __u64   newdir;
197 };
198
199 struct fuse_link_in {
200         __u64   oldnodeid;
201 };
202
203 struct fuse_setattr_in {
204         __u32   valid;
205         __u32   padding;
206         __u64   fh;
207         __u64   size;
208         __u64   unused1;
209         __u64   atime;
210         __u64   mtime;
211         __u64   unused2;
212         __u32   atimensec;
213         __u32   mtimensec;
214         __u32   unused3;
215         __u32   mode;
216         __u32   unused4;
217         __u32   uid;
218         __u32   gid;
219         __u32   unused5;
220 };
221
222 struct fuse_open_in {
223         __u32   flags;
224         __u32   mode;
225 };
226
227 struct fuse_open_out {
228         __u64   fh;
229         __u32   open_flags;
230         __u32   padding;
231 };
232
233 struct fuse_release_in {
234         __u64   fh;
235         __u32   flags;
236         __u32   release_flags;
237         __u64   lock_owner;
238 };
239
240 struct fuse_flush_in {
241         __u64   fh;
242         __u32   unused;
243         __u32   padding;
244         __u64   lock_owner;
245 };
246
247 struct fuse_read_in {
248         __u64   fh;
249         __u64   offset;
250         __u32   size;
251         __u32   padding;
252 };
253
254 struct fuse_write_in {
255         __u64   fh;
256         __u64   offset;
257         __u32   size;
258         __u32   write_flags;
259 };
260
261 struct fuse_write_out {
262         __u32   size;
263         __u32   padding;
264 };
265
266 #define FUSE_COMPAT_STATFS_SIZE 48
267
268 struct fuse_statfs_out {
269         struct fuse_kstatfs st;
270 };
271
272 struct fuse_fsync_in {
273         __u64   fh;
274         __u32   fsync_flags;
275         __u32   padding;
276 };
277
278 struct fuse_setxattr_in {
279         __u32   size;
280         __u32   flags;
281 };
282
283 struct fuse_getxattr_in {
284         __u32   size;
285         __u32   padding;
286 };
287
288 struct fuse_getxattr_out {
289         __u32   size;
290         __u32   padding;
291 };
292
293 struct fuse_lk_in {
294         __u64   fh;
295         __u64   owner;
296         struct fuse_file_lock lk;
297 };
298
299 struct fuse_lk_out {
300         struct fuse_file_lock lk;
301 };
302
303 struct fuse_access_in {
304         __u32   mask;
305         __u32   padding;
306 };
307
308 struct fuse_init_in {
309         __u32   major;
310         __u32   minor;
311         __u32   max_readahead;
312         __u32   flags;
313 };
314
315 struct fuse_init_out {
316         __u32   major;
317         __u32   minor;
318         __u32   max_readahead;
319         __u32   flags;
320         __u32   unused;
321         __u32   max_write;
322 };
323
324 struct fuse_interrupt_in {
325         __u64   unique;
326 };
327
328 struct fuse_bmap_in {
329         __u64   block;
330         __u32   blocksize;
331         __u32   padding;
332 };
333
334 struct fuse_bmap_out {
335         __u64   block;
336 };
337
338 struct fuse_in_header {
339         __u32   len;
340         __u32   opcode;
341         __u64   unique;
342         __u64   nodeid;
343         __u32   uid;
344         __u32   gid;
345         __u32   pid;
346         __u32   padding;
347 };
348
349 struct fuse_out_header {
350         __u32   len;
351         __s32   error;
352         __u64   unique;
353 };
354
355 struct fuse_dirent {
356         __u64   ino;
357         __u64   off;
358         __u32   namelen;
359         __u32   type;
360         char name[0];
361 };
362
363 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
364 #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
365 #define FUSE_DIRENT_SIZE(d) \
366         FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)