blob: 1dc9e0633e29ff89fa2aa4d4e74709a8745290c0 [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 Szeredi41fdcd32005-09-22 09:18:12 +00009/*
10 This -- and only this -- header file may also be distributed under
11 the terms of the BSD Licence as follows:
12
13 Copyright (C) 2005 Miklos Szeredi. All rights reserved.
Miklos Szeredi2bb750e2005-10-03 14:54:24 +000014
Miklos Szeredi41fdcd32005-09-22 09:18:12 +000015 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.
Miklos Szeredi2bb750e2005-10-03 14:54:24 +000023
Miklos Szeredi41fdcd32005-09-22 09:18:12 +000024 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.
35*/
36
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000037/* This file defines the kernel interface of FUSE */
38
Miklos Szeredi0f62d722005-01-04 12:45:54 +000039#include <asm/types.h>
40
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000041/** Version number of this interface */
Miklos Szeredi38009022005-05-08 19:47:22 +000042#define FUSE_KERNEL_VERSION 7
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000043
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000044/** Minor version number of this interface */
Miklos Szeredie3b83092005-07-22 17:24:30 +000045#define FUSE_KERNEL_MINOR_VERSION 2
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000046
Miklos Szeredia13d9002004-11-02 17:32:03 +000047/** The node ID of the root inode */
48#define FUSE_ROOT_ID 1
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000049
Miklos Szeredia25d4c22004-11-23 22:32:16 +000050/** The major number of the fuse character device */
51#define FUSE_MAJOR 10
52
53/** The minor number of the fuse character device */
54#define FUSE_MINOR 229
55
Miklos Szeredieab72ef2005-03-31 19:59:12 +000056/* Make sure all structures are padded to 64bit boundary, so 32bit
57 userspace works under 64bit kernels */
58
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000059struct fuse_attr {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000060 __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;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000074};
75
Miklos Szeredi24ed9452002-10-07 10:24:26 +000076struct fuse_kstatfs {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000077 __u64 blocks;
78 __u64 bfree;
79 __u64 bavail;
80 __u64 files;
81 __u64 ffree;
82 __u32 bsize;
83 __u32 namelen;
Miklos Szeredi24ed9452002-10-07 10:24:26 +000084};
85
Miklos Szeredi5e183482001-10-31 14:52:35 +000086#define FATTR_MODE (1 << 0)
87#define FATTR_UID (1 << 1)
88#define FATTR_GID (1 << 2)
89#define FATTR_SIZE (1 << 3)
Miklos Szeredib5958612004-02-20 14:10:49 +000090#define FATTR_ATIME (1 << 4)
91#define FATTR_MTIME (1 << 5)
Miklos Szeredi5e183482001-10-31 14:52:35 +000092
Miklos Szeredi56487812005-09-02 13:05:06 +000093/**
94 * Flags returned by the OPEN request
95 *
96 * FOPEN_DIRECT_IO: bypass page cache for this open file
97 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
98 */
Miklos Szeredie77cc072005-08-01 11:58:51 +000099#define FOPEN_DIRECT_IO (1 << 0)
100#define FOPEN_KEEP_CACHE (1 << 1)
101
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000102enum fuse_opcode {
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000103 FUSE_LOOKUP = 1,
104 FUSE_FORGET = 2, /* no reply */
105 FUSE_GETATTR = 3,
106 FUSE_SETATTR = 4,
107 FUSE_READLINK = 5,
108 FUSE_SYMLINK = 6,
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000109 FUSE_MKNOD = 8,
110 FUSE_MKDIR = 9,
111 FUSE_UNLINK = 10,
112 FUSE_RMDIR = 11,
113 FUSE_RENAME = 12,
114 FUSE_LINK = 13,
115 FUSE_OPEN = 14,
116 FUSE_READ = 15,
117 FUSE_WRITE = 16,
118 FUSE_STATFS = 17,
Miklos Szeredi72cf5c92004-11-20 16:10:30 +0000119 FUSE_RELEASE = 18,
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000120 FUSE_FSYNC = 20,
121 FUSE_SETXATTR = 21,
122 FUSE_GETXATTR = 22,
123 FUSE_LISTXATTR = 23,
124 FUSE_REMOVEXATTR = 24,
Miklos Szeredie2e4ac22004-05-18 08:45:28 +0000125 FUSE_FLUSH = 25,
Miklos Szeredi3ead28e2005-01-18 21:23:41 +0000126 FUSE_INIT = 26,
127 FUSE_OPENDIR = 27,
128 FUSE_READDIR = 28,
Miklos Szeredi4283ee72005-03-21 12:09:04 +0000129 FUSE_RELEASEDIR = 29,
Miklos Szeredifcf9f8d2005-09-08 14:28:54 +0000130 FUSE_FSYNCDIR = 30
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000131};
132
133/* Conservative buffer size for the client */
134#define FUSE_MAX_IN 8192
135
Miklos Szeredic26c14d2004-04-09 17:48:32 +0000136#define FUSE_NAME_MAX 1024
137#define FUSE_SYMLINK_MAX 4096
138#define FUSE_XATTR_SIZE_MAX 4096
139
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000140struct fuse_entry_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000141 __u64 nodeid; /* Inode ID */
142 __u64 generation; /* Inode generation: nodeid:gen must
143 be unique for the fs's lifetime */
144 __u64 entry_valid; /* Cache timeout for the name */
145 __u64 attr_valid; /* Cache timeout for the attributes */
146 __u32 entry_valid_nsec;
147 __u32 attr_valid_nsec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000148 struct fuse_attr attr;
149};
150
Miklos Szeredia181e612001-11-06 12:03:23 +0000151struct fuse_forget_in {
Miklos Szeredi38009022005-05-08 19:47:22 +0000152 __u64 nlookup;
Miklos Szeredia181e612001-11-06 12:03:23 +0000153};
154
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000155struct fuse_attr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000156 __u64 attr_valid; /* Cache timeout for the attributes */
157 __u32 attr_valid_nsec;
158 __u32 dummy;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000159 struct fuse_attr attr;
160};
161
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000162struct fuse_mknod_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000163 __u32 mode;
164 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000165};
166
Miklos Szeredib483c932001-10-29 14:57:57 +0000167struct fuse_mkdir_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000168 __u32 mode;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000169 __u32 padding;
Miklos Szeredib483c932001-10-29 14:57:57 +0000170};
171
Miklos Szeredib483c932001-10-29 14:57:57 +0000172struct fuse_rename_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000173 __u64 newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000174};
175
176struct fuse_link_in {
Miklos Szeredied6b5dd2005-01-26 17:07:59 +0000177 __u64 oldnodeid;
Miklos Szeredib483c932001-10-29 14:57:57 +0000178};
179
Miklos Szeredi5e183482001-10-31 14:52:35 +0000180struct fuse_setattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000181 __u32 valid;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000182 __u32 padding;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000183 struct fuse_attr attr;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000184};
185
186struct fuse_open_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000187 __u32 flags;
Miklos Szeredifcf9f8d2005-09-08 14:28:54 +0000188 __u32 padding;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000189};
190
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000191struct fuse_open_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000192 __u64 fh;
193 __u32 open_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000194 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000195};
196
197struct fuse_release_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000198 __u64 fh;
199 __u32 flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000200 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000201};
202
203struct fuse_flush_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000204 __u64 fh;
205 __u32 flush_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000206 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000207};
208
Miklos Szeredi5e183482001-10-31 14:52:35 +0000209struct fuse_read_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000210 __u64 fh;
211 __u64 offset;
212 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000213 __u32 padding;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000214};
215
Miklos Szeredia181e612001-11-06 12:03:23 +0000216struct fuse_write_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000217 __u64 fh;
218 __u64 offset;
219 __u32 size;
220 __u32 write_flags;
Miklos Szeredia181e612001-11-06 12:03:23 +0000221};
222
Miklos Szerediad051c32004-07-02 09:22:50 +0000223struct fuse_write_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000224 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000225 __u32 padding;
Miklos Szerediad051c32004-07-02 09:22:50 +0000226};
227
Mark Glinesd84b39a2002-01-07 16:32:02 +0000228struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000229 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000230};
231
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000232struct fuse_fsync_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000233 __u64 fh;
234 __u32 fsync_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000235 __u32 padding;
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000236};
237
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000238struct fuse_setxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000239 __u32 size;
240 __u32 flags;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000241};
242
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000243struct fuse_getxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000244 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000245 __u32 padding;
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000246};
247
248struct fuse_getxattr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000249 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000250 __u32 padding;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000251};
252
Miklos Szeredi3f0005f2005-01-04 19:24:31 +0000253struct fuse_init_in_out {
254 __u32 major;
255 __u32 minor;
256};
257
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000258struct fuse_in_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000259 __u32 len;
260 __u32 opcode;
261 __u64 unique;
262 __u64 nodeid;
263 __u32 uid;
264 __u32 gid;
265 __u32 pid;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000266 __u32 padding;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000267};
268
269struct fuse_out_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000270 __u32 len;
271 __s32 error;
272 __u64 unique;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000273};
274
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000275struct fuse_dirent {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000276 __u64 ino;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000277 __u64 off;
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000278 __u32 namelen;
279 __u32 type;
280 char name[0];
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000281};
282
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000283#define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
284#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000285#define FUSE_DIRENT_SIZE(d) \
286 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)