fuse: improve utimes support
[linux-2.6/libata-dev.git] / include / linux / fuse.h
blob43a77d73349cc6e45da9946c597bb81ea1a8adaf
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)
106 * Release flags
108 #define FUSE_RELEASE_FLUSH (1 << 0)
111 * Getattr flags
113 #define FUSE_GETATTR_FH (1 << 0)
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,
154 /* The read buffer is required to be at least 8k, but may be much larger */
155 #define FUSE_MIN_READ_BUFFER 8192
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;
168 struct fuse_forget_in {
169 __u64 nlookup;
172 struct fuse_getattr_in {
173 __u32 getattr_flags;
174 __u32 dummy;
175 __u64 fh;
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;
185 struct fuse_mknod_in {
186 __u32 mode;
187 __u32 rdev;
190 struct fuse_mkdir_in {
191 __u32 mode;
192 __u32 padding;
195 struct fuse_rename_in {
196 __u64 newdir;
199 struct fuse_link_in {
200 __u64 oldnodeid;
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;
222 struct fuse_open_in {
223 __u32 flags;
224 __u32 mode;
227 struct fuse_open_out {
228 __u64 fh;
229 __u32 open_flags;
230 __u32 padding;
233 struct fuse_release_in {
234 __u64 fh;
235 __u32 flags;
236 __u32 release_flags;
237 __u64 lock_owner;
240 struct fuse_flush_in {
241 __u64 fh;
242 __u32 unused;
243 __u32 padding;
244 __u64 lock_owner;
247 struct fuse_read_in {
248 __u64 fh;
249 __u64 offset;
250 __u32 size;
251 __u32 padding;
254 struct fuse_write_in {
255 __u64 fh;
256 __u64 offset;
257 __u32 size;
258 __u32 write_flags;
261 struct fuse_write_out {
262 __u32 size;
263 __u32 padding;
266 #define FUSE_COMPAT_STATFS_SIZE 48
268 struct fuse_statfs_out {
269 struct fuse_kstatfs st;
272 struct fuse_fsync_in {
273 __u64 fh;
274 __u32 fsync_flags;
275 __u32 padding;
278 struct fuse_setxattr_in {
279 __u32 size;
280 __u32 flags;
283 struct fuse_getxattr_in {
284 __u32 size;
285 __u32 padding;
288 struct fuse_getxattr_out {
289 __u32 size;
290 __u32 padding;
293 struct fuse_lk_in {
294 __u64 fh;
295 __u64 owner;
296 struct fuse_file_lock lk;
299 struct fuse_lk_out {
300 struct fuse_file_lock lk;
303 struct fuse_access_in {
304 __u32 mask;
305 __u32 padding;
308 struct fuse_init_in {
309 __u32 major;
310 __u32 minor;
311 __u32 max_readahead;
312 __u32 flags;
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;
324 struct fuse_interrupt_in {
325 __u64 unique;
328 struct fuse_bmap_in {
329 __u64 block;
330 __u32 blocksize;
331 __u32 padding;
334 struct fuse_bmap_out {
335 __u64 block;
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;
349 struct fuse_out_header {
350 __u32 len;
351 __s32 error;
352 __u64 unique;
355 struct fuse_dirent {
356 __u64 ino;
357 __u64 off;
358 __u32 namelen;
359 __u32 type;
360 char name[0];
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)