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