[PATCH] fuse: use MISC_MAJOR
[safe/jmp/linux-2.6] / include / linux / fuse.h
1 /*
2     FUSE: Filesystem in Userspace
3     Copyright (C) 2001-2005  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 /* This file defines the kernel interface of FUSE */
10
11 #include <asm/types.h>
12 #include <linux/major.h>
13
14 /** Version number of this interface */
15 #define FUSE_KERNEL_VERSION 7
16
17 /** Minor version number of this interface */
18 #define FUSE_KERNEL_MINOR_VERSION 6
19
20 /** The node ID of the root inode */
21 #define FUSE_ROOT_ID 1
22
23 /** The major number of the fuse character device */
24 #define FUSE_MAJOR MISC_MAJOR
25
26 /** The minor number of the fuse character device */
27 #define FUSE_MINOR 229
28
29 /* Make sure all structures are padded to 64bit boundary, so 32bit
30    userspace works under 64bit kernels */
31
32 struct fuse_attr {
33         __u64   ino;
34         __u64   size;
35         __u64   blocks;
36         __u64   atime;
37         __u64   mtime;
38         __u64   ctime;
39         __u32   atimensec;
40         __u32   mtimensec;
41         __u32   ctimensec;
42         __u32   mode;
43         __u32   nlink;
44         __u32   uid;
45         __u32   gid;
46         __u32   rdev;
47 };
48
49 struct fuse_kstatfs {
50         __u64   blocks;
51         __u64   bfree;
52         __u64   bavail;
53         __u64   files;
54         __u64   ffree;
55         __u32   bsize;
56         __u32   namelen;
57         __u32   frsize;
58         __u32   padding;
59         __u32   spare[6];
60 };
61
62 /**
63  * Bitmasks for fuse_setattr_in.valid
64  */
65 #define FATTR_MODE      (1 << 0)
66 #define FATTR_UID       (1 << 1)
67 #define FATTR_GID       (1 << 2)
68 #define FATTR_SIZE      (1 << 3)
69 #define FATTR_ATIME     (1 << 4)
70 #define FATTR_MTIME     (1 << 5)
71 #define FATTR_FH        (1 << 6)
72
73 /**
74  * Flags returned by the OPEN request
75  *
76  * FOPEN_DIRECT_IO: bypass page cache for this open file
77  * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
78  */
79 #define FOPEN_DIRECT_IO         (1 << 0)
80 #define FOPEN_KEEP_CACHE        (1 << 1)
81
82 /**
83  * INIT request/reply flags
84  */
85 #define FUSE_ASYNC_READ         (1 << 0)
86
87 enum fuse_opcode {
88         FUSE_LOOKUP        = 1,
89         FUSE_FORGET        = 2,  /* no reply */
90         FUSE_GETATTR       = 3,
91         FUSE_SETATTR       = 4,
92         FUSE_READLINK      = 5,
93         FUSE_SYMLINK       = 6,
94         FUSE_MKNOD         = 8,
95         FUSE_MKDIR         = 9,
96         FUSE_UNLINK        = 10,
97         FUSE_RMDIR         = 11,
98         FUSE_RENAME        = 12,
99         FUSE_LINK          = 13,
100         FUSE_OPEN          = 14,
101         FUSE_READ          = 15,
102         FUSE_WRITE         = 16,
103         FUSE_STATFS        = 17,
104         FUSE_RELEASE       = 18,
105         FUSE_FSYNC         = 20,
106         FUSE_SETXATTR      = 21,
107         FUSE_GETXATTR      = 22,
108         FUSE_LISTXATTR     = 23,
109         FUSE_REMOVEXATTR   = 24,
110         FUSE_FLUSH         = 25,
111         FUSE_INIT          = 26,
112         FUSE_OPENDIR       = 27,
113         FUSE_READDIR       = 28,
114         FUSE_RELEASEDIR    = 29,
115         FUSE_FSYNCDIR      = 30,
116         FUSE_ACCESS        = 34,
117         FUSE_CREATE        = 35
118 };
119
120 /* The read buffer is required to be at least 8k, but may be much larger */
121 #define FUSE_MIN_READ_BUFFER 8192
122
123 struct fuse_entry_out {
124         __u64   nodeid;         /* Inode ID */
125         __u64   generation;     /* Inode generation: nodeid:gen must
126                                    be unique for the fs's lifetime */
127         __u64   entry_valid;    /* Cache timeout for the name */
128         __u64   attr_valid;     /* Cache timeout for the attributes */
129         __u32   entry_valid_nsec;
130         __u32   attr_valid_nsec;
131         struct fuse_attr attr;
132 };
133
134 struct fuse_forget_in {
135         __u64   nlookup;
136 };
137
138 struct fuse_attr_out {
139         __u64   attr_valid;     /* Cache timeout for the attributes */
140         __u32   attr_valid_nsec;
141         __u32   dummy;
142         struct fuse_attr attr;
143 };
144
145 struct fuse_mknod_in {
146         __u32   mode;
147         __u32   rdev;
148 };
149
150 struct fuse_mkdir_in {
151         __u32   mode;
152         __u32   padding;
153 };
154
155 struct fuse_rename_in {
156         __u64   newdir;
157 };
158
159 struct fuse_link_in {
160         __u64   oldnodeid;
161 };
162
163 struct fuse_setattr_in {
164         __u32   valid;
165         __u32   padding;
166         __u64   fh;
167         __u64   size;
168         __u64   unused1;
169         __u64   atime;
170         __u64   mtime;
171         __u64   unused2;
172         __u32   atimensec;
173         __u32   mtimensec;
174         __u32   unused3;
175         __u32   mode;
176         __u32   unused4;
177         __u32   uid;
178         __u32   gid;
179         __u32   unused5;
180 };
181
182 struct fuse_open_in {
183         __u32   flags;
184         __u32   mode;
185 };
186
187 struct fuse_open_out {
188         __u64   fh;
189         __u32   open_flags;
190         __u32   padding;
191 };
192
193 struct fuse_release_in {
194         __u64   fh;
195         __u32   flags;
196         __u32   padding;
197 };
198
199 struct fuse_flush_in {
200         __u64   fh;
201         __u32   flush_flags;
202         __u32   padding;
203 };
204
205 struct fuse_read_in {
206         __u64   fh;
207         __u64   offset;
208         __u32   size;
209         __u32   padding;
210 };
211
212 struct fuse_write_in {
213         __u64   fh;
214         __u64   offset;
215         __u32   size;
216         __u32   write_flags;
217 };
218
219 struct fuse_write_out {
220         __u32   size;
221         __u32   padding;
222 };
223
224 #define FUSE_COMPAT_STATFS_SIZE 48
225
226 struct fuse_statfs_out {
227         struct fuse_kstatfs st;
228 };
229
230 struct fuse_fsync_in {
231         __u64   fh;
232         __u32   fsync_flags;
233         __u32   padding;
234 };
235
236 struct fuse_setxattr_in {
237         __u32   size;
238         __u32   flags;
239 };
240
241 struct fuse_getxattr_in {
242         __u32   size;
243         __u32   padding;
244 };
245
246 struct fuse_getxattr_out {
247         __u32   size;
248         __u32   padding;
249 };
250
251 struct fuse_access_in {
252         __u32   mask;
253         __u32   padding;
254 };
255
256 struct fuse_init_in {
257         __u32   major;
258         __u32   minor;
259         __u32   max_readahead;
260         __u32   flags;
261 };
262
263 struct fuse_init_out {
264         __u32   major;
265         __u32   minor;
266         __u32   max_readahead;
267         __u32   flags;
268         __u32   unused;
269         __u32   max_write;
270 };
271
272 struct fuse_in_header {
273         __u32   len;
274         __u32   opcode;
275         __u64   unique;
276         __u64   nodeid;
277         __u32   uid;
278         __u32   gid;
279         __u32   pid;
280         __u32   padding;
281 };
282
283 struct fuse_out_header {
284         __u32   len;
285         __s32   error;
286         __u64   unique;
287 };
288
289 struct fuse_dirent {
290         __u64   ino;
291         __u64   off;
292         __u32   namelen;
293         __u32   type;
294         char name[0];
295 };
296
297 #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
298 #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
299 #define FUSE_DIRENT_SIZE(d) \
300         FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)