fix
[fuse.git] / kernel / fuse_kernel.h
blob957877dc22a0d578deff27c1565481a8144cc44c
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2005 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 -- and only this -- header file may also be distributed under
11 the terms of the BSD Licence as follows:
13 Copyright (C) 2005 Miklos Szeredi. All rights reserved.
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions
17 are met:
18 1. Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
24 THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
28 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 SUCH DAMAGE.
37 /* This file defines the kernel interface of FUSE */
39 #include <asm/types.h>
41 /** Version number of this interface */
42 #define FUSE_KERNEL_VERSION 7
44 /** Minor version number of this interface */
45 #define FUSE_KERNEL_MINOR_VERSION 2
47 /** The node ID of the root inode */
48 #define FUSE_ROOT_ID 1
50 /** The major number of the fuse character device */
51 #define FUSE_MAJOR 10
53 /** The minor number of the fuse character device */
54 #define FUSE_MINOR 229
56 /* Make sure all structures are padded to 64bit boundary, so 32bit
57 userspace works under 64bit kernels */
59 struct fuse_attr {
60 __u64 ino;
61 __u64 size;
62 __u64 blocks;
63 __u64 atime;
64 __u64 mtime;
65 __u64 ctime;
66 __u32 atimensec;
67 __u32 mtimensec;
68 __u32 ctimensec;
69 __u32 mode;
70 __u32 nlink;
71 __u32 uid;
72 __u32 gid;
73 __u32 rdev;
76 struct fuse_kstatfs {
77 __u64 blocks;
78 __u64 bfree;
79 __u64 bavail;
80 __u64 files;
81 __u64 ffree;
82 __u32 bsize;
83 __u32 namelen;
86 #define FATTR_MODE (1 << 0)
87 #define FATTR_UID (1 << 1)
88 #define FATTR_GID (1 << 2)
89 #define FATTR_SIZE (1 << 3)
90 #define FATTR_ATIME (1 << 4)
91 #define FATTR_MTIME (1 << 5)
92 #define FATTR_CTIME (1 << 6)
94 /**
95 * Flags returned by the OPEN request
97 * FOPEN_DIRECT_IO: bypass page cache for this open file
98 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
100 #define FOPEN_DIRECT_IO (1 << 0)
101 #define FOPEN_KEEP_CACHE (1 << 1)
103 enum fuse_opcode {
104 FUSE_LOOKUP = 1,
105 FUSE_FORGET = 2, /* no reply */
106 FUSE_GETATTR = 3,
107 FUSE_SETATTR = 4,
108 FUSE_READLINK = 5,
109 FUSE_SYMLINK = 6,
110 FUSE_MKNOD = 8,
111 FUSE_MKDIR = 9,
112 FUSE_UNLINK = 10,
113 FUSE_RMDIR = 11,
114 FUSE_RENAME = 12,
115 FUSE_LINK = 13,
116 FUSE_OPEN = 14,
117 FUSE_READ = 15,
118 FUSE_WRITE = 16,
119 FUSE_STATFS = 17,
120 FUSE_RELEASE = 18,
121 FUSE_FSYNC = 20,
122 FUSE_SETXATTR = 21,
123 FUSE_GETXATTR = 22,
124 FUSE_LISTXATTR = 23,
125 FUSE_REMOVEXATTR = 24,
126 FUSE_FLUSH = 25,
127 FUSE_INIT = 26,
128 FUSE_OPENDIR = 27,
129 FUSE_READDIR = 28,
130 FUSE_RELEASEDIR = 29,
131 FUSE_FSYNCDIR = 30
134 /* Conservative buffer size for the client */
135 #define FUSE_MAX_IN 8192
137 #define FUSE_NAME_MAX 1024
138 #define FUSE_SYMLINK_MAX 4096
139 #define FUSE_XATTR_SIZE_MAX 4096
141 struct fuse_entry_out {
142 __u64 nodeid; /* Inode ID */
143 __u64 generation; /* Inode generation: nodeid:gen must
144 be unique for the fs's lifetime */
145 __u64 entry_valid; /* Cache timeout for the name */
146 __u64 attr_valid; /* Cache timeout for the attributes */
147 __u32 entry_valid_nsec;
148 __u32 attr_valid_nsec;
149 struct fuse_attr attr;
152 struct fuse_forget_in {
153 __u64 nlookup;
156 struct fuse_attr_out {
157 __u64 attr_valid; /* Cache timeout for the attributes */
158 __u32 attr_valid_nsec;
159 __u32 dummy;
160 struct fuse_attr attr;
163 struct fuse_mknod_in {
164 __u32 mode;
165 __u32 rdev;
168 struct fuse_mkdir_in {
169 __u32 mode;
170 __u32 padding;
173 struct fuse_rename_in {
174 __u64 newdir;
177 struct fuse_link_in {
178 __u64 oldnodeid;
181 struct fuse_setattr_in {
182 __u32 valid;
183 __u32 padding;
184 struct fuse_attr attr;
187 struct fuse_open_in {
188 __u32 flags;
189 __u32 padding;
192 struct fuse_open_out {
193 __u64 fh;
194 __u32 open_flags;
195 __u32 padding;
198 struct fuse_release_in {
199 __u64 fh;
200 __u32 flags;
201 __u32 padding;
204 struct fuse_flush_in {
205 __u64 fh;
206 __u32 flush_flags;
207 __u32 padding;
210 struct fuse_read_in {
211 __u64 fh;
212 __u64 offset;
213 __u32 size;
214 __u32 padding;
217 struct fuse_write_in {
218 __u64 fh;
219 __u64 offset;
220 __u32 size;
221 __u32 write_flags;
224 struct fuse_write_out {
225 __u32 size;
226 __u32 padding;
229 struct fuse_statfs_out {
230 struct fuse_kstatfs st;
233 struct fuse_fsync_in {
234 __u64 fh;
235 __u32 fsync_flags;
236 __u32 padding;
239 struct fuse_setxattr_in {
240 __u32 size;
241 __u32 flags;
244 struct fuse_getxattr_in {
245 __u32 size;
246 __u32 padding;
249 struct fuse_getxattr_out {
250 __u32 size;
251 __u32 padding;
254 struct fuse_init_in_out {
255 __u32 major;
256 __u32 minor;
259 struct fuse_in_header {
260 __u32 len;
261 __u32 opcode;
262 __u64 unique;
263 __u64 nodeid;
264 __u32 uid;
265 __u32 gid;
266 __u32 pid;
267 __u32 padding;
270 struct fuse_out_header {
271 __u32 len;
272 __s32 error;
273 __u64 unique;
276 struct fuse_dirent {
277 __u64 ino;
278 __u64 off;
279 __u32 namelen;
280 __u32 type;
281 char name[0];
284 #define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
285 #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
286 #define FUSE_DIRENT_SIZE(d) \
287 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)