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