summaryrefslogtreecommitdiff
path: root/include/fuse-lite/fuse_kernel.h (plain)
blob: 696de77fbbc834a3986a1ed03b7f18d7eab40edd
1/*
2 This file defines the kernel interface of FUSE
3 Copyright (C) 2001-2007 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 This -- and only this -- header file may also be distributed under
9 the terms of the BSD Licence as follows:
10
11 Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
15 are met:
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18 2. Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21
22 THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 SUCH DAMAGE.
33 *
34 * 7.12
35 * - add umask flag to input argument of open, mknod and mkdir
36*/
37
38#ifndef linux
39#ifdef HAVE_SYS_TYPES_H
40#include <sys/types.h>
41#endif
42
43#define __u64 uint64_t
44#define __u32 uint32_t
45#define __s32 int32_t
46#else
47#include <asm/types.h>
48#include <linux/major.h>
49#endif
50
51/** Version number of this interface */
52#define FUSE_KERNEL_VERSION 7
53
54/** Minor version number of this interface */
55#ifdef POSIXACLS
56#define FUSE_KERNEL_MINOR_VERSION 12
57#define FUSE_KERNEL_MINOR_FALLBACK 8
58#else
59#define FUSE_KERNEL_MINOR_VERSION 8
60#endif
61
62/** The node ID of the root inode */
63#define FUSE_ROOT_ID 1
64
65/** The major number of the fuse character device */
66#define FUSE_MAJOR MISC_MAJOR
67
68/** The minor number of the fuse character device */
69#define FUSE_MINOR 229
70
71/* Make sure all structures are padded to 64bit boundary, so 32bit
72 userspace works under 64bit kernels */
73
74struct fuse_attr {
75 __u64 ino;
76 __u64 size;
77 __u64 blocks;
78 __u64 atime;
79 __u64 mtime;
80 __u64 ctime;
81 __u32 atimensec;
82 __u32 mtimensec;
83 __u32 ctimensec;
84 __u32 mode;
85 __u32 nlink;
86 __u32 uid;
87 __u32 gid;
88 __u32 rdev;
89#ifdef POSIXACLS
90 __u64 filling; /* JPA needed for minor >= 12, but meaning unknown */
91#endif
92};
93
94struct fuse_kstatfs {
95 __u64 blocks;
96 __u64 bfree;
97 __u64 bavail;
98 __u64 files;
99 __u64 ffree;
100 __u32 bsize;
101 __u32 namelen;
102 __u32 frsize;
103 __u32 padding;
104 __u32 spare[6];
105};
106
107struct fuse_file_lock {
108 __u64 start;
109 __u64 end;
110 __u32 type;
111 __u32 pid; /* tgid */
112};
113
114/**
115 * Bitmasks for fuse_setattr_in.valid
116 */
117#define FATTR_MODE (1 << 0)
118#define FATTR_UID (1 << 1)
119#define FATTR_GID (1 << 2)
120#define FATTR_SIZE (1 << 3)
121#define FATTR_ATIME (1 << 4)
122#define FATTR_MTIME (1 << 5)
123#define FATTR_FH (1 << 6)
124
125/**
126 * Flags returned by the OPEN request
127 *
128 * FOPEN_DIRECT_IO: bypass page cache for this open file
129 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
130 */
131#define FOPEN_DIRECT_IO (1 << 0)
132#define FOPEN_KEEP_CACHE (1 << 1)
133
134/**
135 * INIT request/reply flags
136 * FUSE_DONT_MASK: don't apply umask to file mode on create operations
137 */
138#define FUSE_ASYNC_READ (1 << 0)
139#define FUSE_POSIX_LOCKS (1 << 1)
140#define FUSE_DONT_MASK (1 << 6)
141#define FUSE_BIG_WRITES (1 << 5)
142
143/**
144 * Release flags
145 */
146#define FUSE_RELEASE_FLUSH (1 << 0)
147
148enum fuse_opcode {
149 FUSE_LOOKUP = 1,
150 FUSE_FORGET = 2, /* no reply */
151 FUSE_GETATTR = 3,
152 FUSE_SETATTR = 4,
153 FUSE_READLINK = 5,
154 FUSE_SYMLINK = 6,
155 FUSE_MKNOD = 8,
156 FUSE_MKDIR = 9,
157 FUSE_UNLINK = 10,
158 FUSE_RMDIR = 11,
159 FUSE_RENAME = 12,
160 FUSE_LINK = 13,
161 FUSE_OPEN = 14,
162 FUSE_READ = 15,
163 FUSE_WRITE = 16,
164 FUSE_STATFS = 17,
165 FUSE_RELEASE = 18,
166 FUSE_FSYNC = 20,
167 FUSE_SETXATTR = 21,
168 FUSE_GETXATTR = 22,
169 FUSE_LISTXATTR = 23,
170 FUSE_REMOVEXATTR = 24,
171 FUSE_FLUSH = 25,
172 FUSE_INIT = 26,
173 FUSE_OPENDIR = 27,
174 FUSE_READDIR = 28,
175 FUSE_RELEASEDIR = 29,
176 FUSE_FSYNCDIR = 30,
177 FUSE_GETLK = 31,
178 FUSE_SETLK = 32,
179 FUSE_SETLKW = 33,
180 FUSE_ACCESS = 34,
181 FUSE_CREATE = 35,
182 FUSE_INTERRUPT = 36,
183 FUSE_BMAP = 37,
184 FUSE_DESTROY = 38,
185};
186
187/* The read buffer is required to be at least 8k, but may be much larger */
188#define FUSE_MIN_READ_BUFFER 8192
189#define FUSE_COMPAT_ENTRY_OUT_SIZE 120 /* JPA */
190
191struct fuse_entry_out {
192 __u64 nodeid; /* Inode ID */
193 __u64 generation; /* Inode generation: nodeid:gen must
194 be unique for the fs's lifetime */
195 __u64 entry_valid; /* Cache timeout for the name */
196 __u64 attr_valid; /* Cache timeout for the attributes */
197 __u32 entry_valid_nsec;
198 __u32 attr_valid_nsec;
199 struct fuse_attr attr;
200};
201
202struct fuse_forget_in {
203 __u64 nlookup;
204};
205
206#define FUSE_COMPAT_FUSE_ATTR_OUT_SIZE 96 /* JPA */
207
208struct fuse_attr_out {
209 __u64 attr_valid; /* Cache timeout for the attributes */
210 __u32 attr_valid_nsec;
211 __u32 dummy;
212 struct fuse_attr attr;
213};
214
215#define FUSE_COMPAT_MKNOD_IN_SIZE 8
216
217struct fuse_mknod_in {
218 __u32 mode;
219 __u32 rdev;
220#ifdef POSIXACLS
221 __u32 umask;
222 __u32 padding;
223#endif
224};
225
226struct fuse_mkdir_in {
227 __u32 mode;
228 __u32 umask;
229};
230
231struct fuse_rename_in {
232 __u64 newdir;
233};
234
235struct fuse_link_in {
236 __u64 oldnodeid;
237};
238
239struct fuse_setattr_in {
240 __u32 valid;
241 __u32 padding;
242 __u64 fh;
243 __u64 size;
244 __u64 unused1;
245 __u64 atime;
246 __u64 mtime;
247 __u64 unused2;
248 __u32 atimensec;
249 __u32 mtimensec;
250 __u32 unused3;
251 __u32 mode;
252 __u32 unused4;
253 __u32 uid;
254 __u32 gid;
255 __u32 unused5;
256};
257
258struct fuse_open_in {
259 __u32 flags;
260#ifdef POSIXACLS
261 __u32 unused;
262#else
263 __u32 mode;
264#endif
265};
266
267struct fuse_create_in {
268 __u32 flags;
269 __u32 mode;
270#ifdef POSIXACLS
271 __u32 umask;
272 __u32 padding;
273#endif
274};
275
276struct fuse_open_out {
277 __u64 fh;
278 __u32 open_flags;
279 __u32 padding;
280};
281
282struct fuse_release_in {
283 __u64 fh;
284 __u32 flags;
285 __u32 release_flags;
286 __u64 lock_owner;
287};
288
289struct fuse_flush_in {
290 __u64 fh;
291 __u32 unused;
292 __u32 padding;
293 __u64 lock_owner;
294};
295
296struct fuse_read_in {
297 __u64 fh;
298 __u64 offset;
299 __u32 size;
300 __u32 padding;
301};
302
303#define FUSE_COMPAT_WRITE_IN_SIZE 24 /* JPA */
304
305struct fuse_write_in {
306 __u64 fh;
307 __u64 offset;
308 __u32 size;
309 __u32 write_flags;
310#ifdef POSIXACLS
311 __u64 lock_owner; /* JPA */
312 __u32 flags; /* JPA */
313 __u32 padding; /* JPA */
314#endif
315};
316
317struct fuse_write_out {
318 __u32 size;
319 __u32 padding;
320};
321
322#define FUSE_COMPAT_STATFS_SIZE 48
323
324struct fuse_statfs_out {
325 struct fuse_kstatfs st;
326};
327
328struct fuse_fsync_in {
329 __u64 fh;
330 __u32 fsync_flags;
331 __u32 padding;
332};
333
334struct fuse_setxattr_in {
335 __u32 size;
336 __u32 flags;
337};
338
339struct fuse_getxattr_in {
340 __u32 size;
341 __u32 padding;
342};
343
344struct fuse_getxattr_out {
345 __u32 size;
346 __u32 padding;
347};
348
349struct fuse_lk_in {
350 __u64 fh;
351 __u64 owner;
352 struct fuse_file_lock lk;
353};
354
355struct fuse_lk_out {
356 struct fuse_file_lock lk;
357};
358
359struct fuse_access_in {
360 __u32 mask;
361 __u32 padding;
362};
363
364struct fuse_init_in {
365 __u32 major;
366 __u32 minor;
367 __u32 max_readahead;
368 __u32 flags;
369};
370
371struct fuse_init_out {
372 __u32 major;
373 __u32 minor;
374 __u32 max_readahead;
375 __u32 flags;
376 __u32 unused;
377 __u32 max_write;
378};
379
380struct fuse_interrupt_in {
381 __u64 unique;
382};
383
384struct fuse_bmap_in {
385 __u64 block;
386 __u32 blocksize;
387 __u32 padding;
388};
389
390struct fuse_bmap_out {
391 __u64 block;
392};
393
394struct fuse_in_header {
395 __u32 len;
396 __u32 opcode;
397 __u64 unique;
398 __u64 nodeid;
399 __u32 uid;
400 __u32 gid;
401 __u32 pid;
402 __u32 padding;
403};
404
405struct fuse_out_header {
406 __u32 len;
407 __s32 error;
408 __u64 unique;
409};
410
411struct fuse_dirent {
412 __u64 ino;
413 __u64 off;
414 __u32 namelen;
415 __u32 type;
416 char name[0];
417};
418
419#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
420#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
421#define FUSE_DIRENT_SIZE(d) \
422 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
423