blob: 26fff1306ec2d809b80d85388f62dd2088824647 [file] [log] [blame]
Miklos Szeredi85c74fc2001-10-28 19:44:14 +00001/*
2 FUSE: Filesystem in Userspace
Miklos Szeredi149f6072005-01-10 12:29:28 +00003 Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
Miklos Szeredi85c74fc2001-10-28 19:44:14 +00004
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7*/
8
Miklos Szeredi2b478112005-11-28 13:27:10 +00009/* This file defines the kernel interface of FUSE */
10
11#ifdef __FreeBSD__
Miklos Szeredi41fdcd32005-09-22 09:18:12 +000012/*
13 This -- and only this -- header file may also be distributed under
14 the terms of the BSD Licence as follows:
15
16 Copyright (C) 2005 Miklos Szeredi. All rights reserved.
Miklos Szeredi2bb750e2005-10-03 14:54:24 +000017
Miklos Szeredi41fdcd32005-09-22 09:18:12 +000018 Redistribution and use in source and binary forms, with or without
19 modification, are permitted provided that the following conditions
20 are met:
21 1. Redistributions of source code must retain the above copyright
22 notice, this list of conditions and the following disclaimer.
23 2. Redistributions in binary form must reproduce the above copyright
24 notice, this list of conditions and the following disclaimer in the
25 documentation and/or other materials provided with the distribution.
Miklos Szeredi2bb750e2005-10-03 14:54:24 +000026
Miklos Szeredi41fdcd32005-09-22 09:18:12 +000027 THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
28 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
31 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 SUCH DAMAGE.
38*/
39
Miklos Szeredib3f99722005-11-16 13:00:24 +000040#include <sys/types.h>
41#define __u64 uint64_t
42#define __u32 uint32_t
43#define __s32 int32_t
44#else
Miklos Szeredi0f62d722005-01-04 12:45:54 +000045#include <asm/types.h>
Miklos Szeredib3f99722005-11-16 13:00:24 +000046#endif
Miklos Szeredi0f62d722005-01-04 12:45:54 +000047
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000048/** Version number of this interface */
Miklos Szeredi38009022005-05-08 19:47:22 +000049#define FUSE_KERNEL_VERSION 7
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000050
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000051/** Minor version number of this interface */
Miklos Szeredi044da2e2005-12-06 17:59:55 +000052#define FUSE_KERNEL_MINOR_VERSION 5
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000053
Miklos Szeredia13d9002004-11-02 17:32:03 +000054/** The node ID of the root inode */
55#define FUSE_ROOT_ID 1
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000056
Miklos Szeredia25d4c22004-11-23 22:32:16 +000057/** The major number of the fuse character device */
58#define FUSE_MAJOR 10
59
60/** The minor number of the fuse character device */
61#define FUSE_MINOR 229
62
Miklos Szeredieab72ef2005-03-31 19:59:12 +000063/* Make sure all structures are padded to 64bit boundary, so 32bit
64 userspace works under 64bit kernels */
65
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000066struct fuse_attr {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000067 __u64 ino;
68 __u64 size;
69 __u64 blocks;
70 __u64 atime;
71 __u64 mtime;
72 __u64 ctime;
73 __u32 atimensec;
74 __u32 mtimensec;
75 __u32 ctimensec;
76 __u32 mode;
77 __u32 nlink;
78 __u32 uid;
79 __u32 gid;
80 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000081};
82
Miklos Szeredi24ed9452002-10-07 10:24:26 +000083struct fuse_kstatfs {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000084 __u64 blocks;
85 __u64 bfree;
86 __u64 bavail;
87 __u64 files;
88 __u64 ffree;
89 __u32 bsize;
90 __u32 namelen;
Miklos Szeredi2b478112005-11-28 13:27:10 +000091 __u32 frsize;
92 __u32 padding;
93 __u32 spare[6];
Miklos Szeredi24ed9452002-10-07 10:24:26 +000094};
95
Miklos Szeredi5e183482001-10-31 14:52:35 +000096#define FATTR_MODE (1 << 0)
97#define FATTR_UID (1 << 1)
98#define FATTR_GID (1 << 2)
99#define FATTR_SIZE (1 << 3)
Miklos Szeredib5958612004-02-20 14:10:49 +0000100#define FATTR_ATIME (1 << 4)
101#define FATTR_MTIME (1 << 5)
Miklos Szeredi11509ce2005-10-26 16:04:04 +0000102#define FATTR_FH (1 << 6)
Miklos Szeredi5e183482001-10-31 14:52:35 +0000103
Miklos Szeredi56487812005-09-02 13:05:06 +0000104/**
105 * Flags returned by the OPEN request
106 *
107 * FOPEN_DIRECT_IO: bypass page cache for this open file
108 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
109 */
Miklos Szeredie77cc072005-08-01 11:58:51 +0000110#define FOPEN_DIRECT_IO (1 << 0)
111#define FOPEN_KEEP_CACHE (1 << 1)
112
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000113enum fuse_opcode {
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000114 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,
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000120 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,
Miklos Szeredi72cf5c92004-11-20 16:10:30 +0000130 FUSE_RELEASE = 18,
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000131 FUSE_FSYNC = 20,
132 FUSE_SETXATTR = 21,
133 FUSE_GETXATTR = 22,
134 FUSE_LISTXATTR = 23,
135 FUSE_REMOVEXATTR = 24,
Miklos Szeredie2e4ac22004-05-18 08:45:28 +0000136 FUSE_FLUSH = 25,
Miklos Szeredi3ead28e2005-01-18 21:23:41 +0000137 FUSE_INIT = 26,
138 FUSE_OPENDIR = 27,
139 FUSE_READDIR = 28,
Miklos Szeredi4283ee72005-03-21 12:09:04 +0000140 FUSE_RELEASEDIR = 29,
Miklos Szeredib0b13d12005-10-26 12:53:25 +0000141 FUSE_FSYNCDIR = 30,
Miklos Szeredid9079a72005-10-26 15:29:06 +0000142 FUSE_ACCESS = 34,
143 FUSE_CREATE = 35
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000144};
145
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000146struct fuse_entry_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000147 __u64 nodeid; /* Inode ID */
148 __u64 generation; /* Inode generation: nodeid:gen must
149 be unique for the fs's lifetime */
150 __u64 entry_valid; /* Cache timeout for the name */
151 __u64 attr_valid; /* Cache timeout for the attributes */
152 __u32 entry_valid_nsec;
153 __u32 attr_valid_nsec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000154 struct fuse_attr attr;
155};
156
Miklos Szeredia181e612001-11-06 12:03:23 +0000157struct fuse_forget_in {
Miklos Szeredi38009022005-05-08 19:47:22 +0000158 __u64 nlookup;
Miklos Szeredia181e612001-11-06 12:03:23 +0000159};
160
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000161struct fuse_attr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000162 __u64 attr_valid; /* Cache timeout for the attributes */
163 __u32 attr_valid_nsec;
164 __u32 dummy;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000165 struct fuse_attr attr;
166};
167
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000168struct fuse_mknod_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000169 __u32 mode;
170 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000171};
172
Miklos Szeredib483c932001-10-29 14:57:57 +0000173struct fuse_mkdir_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000174 __u32 mode;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000175 __u32 padding;
Miklos Szeredib483c932001-10-29 14:57:57 +0000176};
177
Miklos Szeredib483c932001-10-29 14:57:57 +0000178struct fuse_rename_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000179 __u64 newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000180};
181
182struct fuse_link_in {
Miklos Szeredied6b5dd2005-01-26 17:07:59 +0000183 __u64 oldnodeid;
Miklos Szeredib483c932001-10-29 14:57:57 +0000184};
185
Miklos Szeredi5e183482001-10-31 14:52:35 +0000186struct fuse_setattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000187 __u32 valid;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000188 __u32 padding;
Miklos Szeredi11509ce2005-10-26 16:04:04 +0000189 __u64 fh;
190 __u64 size;
191 __u64 unused1;
192 __u64 atime;
193 __u64 mtime;
194 __u64 unused2;
195 __u32 atimensec;
196 __u32 mtimensec;
197 __u32 unused3;
198 __u32 mode;
199 __u32 unused4;
200 __u32 uid;
201 __u32 gid;
202 __u32 unused5;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000203};
204
205struct fuse_open_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000206 __u32 flags;
Miklos Szeredid9079a72005-10-26 15:29:06 +0000207 __u32 mode;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000208};
209
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000210struct fuse_open_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000211 __u64 fh;
212 __u32 open_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000213 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000214};
215
216struct fuse_release_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000217 __u64 fh;
218 __u32 flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000219 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000220};
221
222struct fuse_flush_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000223 __u64 fh;
224 __u32 flush_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000225 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000226};
227
Miklos Szeredi5e183482001-10-31 14:52:35 +0000228struct fuse_read_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000229 __u64 fh;
230 __u64 offset;
231 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000232 __u32 padding;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000233};
234
Miklos Szeredia181e612001-11-06 12:03:23 +0000235struct fuse_write_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000236 __u64 fh;
237 __u64 offset;
238 __u32 size;
239 __u32 write_flags;
Miklos Szeredia181e612001-11-06 12:03:23 +0000240};
241
Miklos Szerediad051c32004-07-02 09:22:50 +0000242struct fuse_write_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000243 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000244 __u32 padding;
Miklos Szerediad051c32004-07-02 09:22:50 +0000245};
246
Miklos Szerediead7f102005-11-28 16:02:27 +0000247#define FUSE_COMPAT_STATFS_SIZE 48
Miklos Szeredi2b478112005-11-28 13:27:10 +0000248
Mark Glinesd84b39a2002-01-07 16:32:02 +0000249struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000250 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000251};
252
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000253struct fuse_fsync_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000254 __u64 fh;
255 __u32 fsync_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000256 __u32 padding;
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000257};
258
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000259struct fuse_setxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000260 __u32 size;
261 __u32 flags;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000262};
263
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000264struct fuse_getxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000265 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000266 __u32 padding;
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000267};
268
269struct fuse_getxattr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000270 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000271 __u32 padding;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000272};
273
Miklos Szeredib0b13d12005-10-26 12:53:25 +0000274struct fuse_access_in {
275 __u32 mask;
276 __u32 padding;
277};
278
Miklos Szeredi044da2e2005-12-06 17:59:55 +0000279struct fuse_init_in {
Miklos Szeredi3f0005f2005-01-04 19:24:31 +0000280 __u32 major;
281 __u32 minor;
282};
283
Miklos Szeredi044da2e2005-12-06 17:59:55 +0000284struct fuse_init_out {
285 __u32 major;
286 __u32 minor;
287 __u32 name_max;
288 __u32 symlink_max;
289 __u32 xattr_size_max;
290 __u32 max_write;
291};
292
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000293struct fuse_in_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000294 __u32 len;
295 __u32 opcode;
296 __u64 unique;
297 __u64 nodeid;
298 __u32 uid;
299 __u32 gid;
300 __u32 pid;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000301 __u32 padding;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000302};
303
304struct fuse_out_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000305 __u32 len;
306 __s32 error;
307 __u64 unique;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000308};
309
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000310struct fuse_dirent {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000311 __u64 ino;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000312 __u64 off;
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000313 __u32 namelen;
314 __u32 type;
315 char name[0];
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000316};
317
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000318#define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
319#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000320#define FUSE_DIRENT_SIZE(d) \
321 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)