blob: c668c6833a1357259fffd155e64ca522ba8fe620 [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
9/* This file defines the kernel interface of FUSE */
10
Miklos Szeredi0f62d722005-01-04 12:45:54 +000011#include <asm/types.h>
12
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000013/** Version number of this interface */
Miklos Szeredi38009022005-05-08 19:47:22 +000014#define FUSE_KERNEL_VERSION 7
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000015
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000016/** Minor version number of this interface */
Miklos Szeredie3b83092005-07-22 17:24:30 +000017#define FUSE_KERNEL_MINOR_VERSION 2
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000018
Miklos Szeredia13d9002004-11-02 17:32:03 +000019/** The node ID of the root inode */
20#define FUSE_ROOT_ID 1
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000021
Miklos Szeredia25d4c22004-11-23 22:32:16 +000022/** The major number of the fuse character device */
23#define FUSE_MAJOR 10
24
25/** The minor number of the fuse character device */
26#define FUSE_MINOR 229
27
Miklos Szeredieab72ef2005-03-31 19:59:12 +000028/* Make sure all structures are padded to 64bit boundary, so 32bit
29 userspace works under 64bit kernels */
30
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000031struct fuse_attr {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000032 __u64 ino;
33 __u64 size;
34 __u64 blocks;
35 __u64 atime;
36 __u64 mtime;
37 __u64 ctime;
38 __u32 atimensec;
39 __u32 mtimensec;
40 __u32 ctimensec;
41 __u32 mode;
42 __u32 nlink;
43 __u32 uid;
44 __u32 gid;
45 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000046};
47
Miklos Szeredi24ed9452002-10-07 10:24:26 +000048struct fuse_kstatfs {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000049 __u64 blocks;
50 __u64 bfree;
51 __u64 bavail;
52 __u64 files;
53 __u64 ffree;
54 __u32 bsize;
55 __u32 namelen;
Miklos Szeredi24ed9452002-10-07 10:24:26 +000056};
57
Miklos Szeredie3b83092005-07-22 17:24:30 +000058struct fuse_file_lock {
59 __u64 start;
60 __u64 end;
61 __u64 owner;
62 __u32 pid;
63 __u32 type;
64};
65
Miklos Szeredi56487812005-09-02 13:05:06 +000066/** Valid attribute mask used in the SETATTR request */
Miklos Szeredi5e183482001-10-31 14:52:35 +000067#define FATTR_MODE (1 << 0)
68#define FATTR_UID (1 << 1)
69#define FATTR_GID (1 << 2)
70#define FATTR_SIZE (1 << 3)
Miklos Szeredib5958612004-02-20 14:10:49 +000071#define FATTR_ATIME (1 << 4)
72#define FATTR_MTIME (1 << 5)
73#define FATTR_CTIME (1 << 6)
Miklos Szeredi5e183482001-10-31 14:52:35 +000074
Miklos Szeredi56487812005-09-02 13:05:06 +000075/**
76 * Flags returned by the OPEN request
77 *
78 * FOPEN_DIRECT_IO: bypass page cache for this open file
79 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
80 */
Miklos Szeredie77cc072005-08-01 11:58:51 +000081#define FOPEN_DIRECT_IO (1 << 0)
82#define FOPEN_KEEP_CACHE (1 << 1)
83
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000084enum fuse_opcode {
Miklos Szeredi3ed84232004-03-30 15:17:26 +000085 FUSE_LOOKUP = 1,
86 FUSE_FORGET = 2, /* no reply */
87 FUSE_GETATTR = 3,
88 FUSE_SETATTR = 4,
89 FUSE_READLINK = 5,
90 FUSE_SYMLINK = 6,
Miklos Szeredi3ed84232004-03-30 15:17:26 +000091 FUSE_MKNOD = 8,
92 FUSE_MKDIR = 9,
93 FUSE_UNLINK = 10,
94 FUSE_RMDIR = 11,
95 FUSE_RENAME = 12,
96 FUSE_LINK = 13,
97 FUSE_OPEN = 14,
98 FUSE_READ = 15,
99 FUSE_WRITE = 16,
100 FUSE_STATFS = 17,
Miklos Szeredi72cf5c92004-11-20 16:10:30 +0000101 FUSE_RELEASE = 18,
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000102 FUSE_FSYNC = 20,
103 FUSE_SETXATTR = 21,
104 FUSE_GETXATTR = 22,
105 FUSE_LISTXATTR = 23,
106 FUSE_REMOVEXATTR = 24,
Miklos Szeredie2e4ac22004-05-18 08:45:28 +0000107 FUSE_FLUSH = 25,
Miklos Szeredi3ead28e2005-01-18 21:23:41 +0000108 FUSE_INIT = 26,
109 FUSE_OPENDIR = 27,
110 FUSE_READDIR = 28,
Miklos Szeredi4283ee72005-03-21 12:09:04 +0000111 FUSE_RELEASEDIR = 29,
Miklos Szeredie3b83092005-07-22 17:24:30 +0000112 FUSE_FSYNCDIR = 30,
113 FUSE_GETLK = 31,
114 FUSE_SETLK = 32,
Miklos Szeredi7b28eae2005-08-01 12:48:30 +0000115 FUSE_SETLKW = 33,
Miklos Szeredib0c52c52005-08-23 15:39:43 +0000116 FUSE_ACCESS = 34,
Miklos Szerediecce1bf2005-08-25 15:19:06 +0000117 FUSE_CREATE = 35,
118 FUSE_FSETATTR = 36
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000119};
120
121/* Conservative buffer size for the client */
122#define FUSE_MAX_IN 8192
123
Miklos Szeredic26c14d2004-04-09 17:48:32 +0000124#define FUSE_NAME_MAX 1024
125#define FUSE_SYMLINK_MAX 4096
126#define FUSE_XATTR_SIZE_MAX 4096
127
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000128struct fuse_entry_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000129 __u64 nodeid; /* Inode ID */
130 __u64 generation; /* Inode generation: nodeid:gen must
131 be unique for the fs's lifetime */
132 __u64 entry_valid; /* Cache timeout for the name */
133 __u64 attr_valid; /* Cache timeout for the attributes */
134 __u32 entry_valid_nsec;
135 __u32 attr_valid_nsec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000136 struct fuse_attr attr;
137};
138
Miklos Szeredia181e612001-11-06 12:03:23 +0000139struct fuse_forget_in {
Miklos Szeredi38009022005-05-08 19:47:22 +0000140 __u64 nlookup;
Miklos Szeredia181e612001-11-06 12:03:23 +0000141};
142
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000143struct fuse_attr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000144 __u64 attr_valid; /* Cache timeout for the attributes */
145 __u32 attr_valid_nsec;
146 __u32 dummy;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000147 struct fuse_attr attr;
148};
149
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000150struct fuse_mknod_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000151 __u32 mode;
152 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000153};
154
Miklos Szeredib483c932001-10-29 14:57:57 +0000155struct fuse_mkdir_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000156 __u32 mode;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000157 __u32 padding;
Miklos Szeredib483c932001-10-29 14:57:57 +0000158};
159
Miklos Szeredib483c932001-10-29 14:57:57 +0000160struct fuse_rename_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000161 __u64 newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000162};
163
164struct fuse_link_in {
Miklos Szeredied6b5dd2005-01-26 17:07:59 +0000165 __u64 oldnodeid;
Miklos Szeredib483c932001-10-29 14:57:57 +0000166};
167
Miklos Szeredi5e183482001-10-31 14:52:35 +0000168struct fuse_setattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000169 __u32 valid;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000170 __u32 padding;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000171 struct fuse_attr attr;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000172};
173
Miklos Szerediecce1bf2005-08-25 15:19:06 +0000174struct fuse_fsetattr_in {
175 __u64 fh;
176 struct fuse_setattr_in setattr;
177};
178
Miklos Szeredi5e183482001-10-31 14:52:35 +0000179struct fuse_open_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000180 __u32 flags;
Miklos Szeredib0c52c52005-08-23 15:39:43 +0000181 __u32 mode;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000182};
183
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000184struct fuse_open_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000185 __u64 fh;
186 __u32 open_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000187 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000188};
189
190struct fuse_release_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000191 __u64 fh;
192 __u32 flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000193 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000194};
195
196struct fuse_flush_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000197 __u64 fh;
198 __u32 flush_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000199 __u32 padding;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000200};
201
Miklos Szeredi5e183482001-10-31 14:52:35 +0000202struct fuse_read_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000203 __u64 fh;
204 __u64 offset;
205 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000206 __u32 padding;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000207};
208
Miklos Szeredia181e612001-11-06 12:03:23 +0000209struct fuse_write_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000210 __u64 fh;
211 __u64 offset;
212 __u32 size;
213 __u32 write_flags;
Miklos Szeredia181e612001-11-06 12:03:23 +0000214};
215
Miklos Szerediad051c32004-07-02 09:22:50 +0000216struct fuse_write_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000217 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000218 __u32 padding;
Miklos Szerediad051c32004-07-02 09:22:50 +0000219};
220
Mark Glinesd84b39a2002-01-07 16:32:02 +0000221struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000222 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000223};
224
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000225struct fuse_fsync_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000226 __u64 fh;
227 __u32 fsync_flags;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000228 __u32 padding;
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000229};
230
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000231struct fuse_setxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000232 __u32 size;
233 __u32 flags;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000234};
235
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000236struct fuse_getxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000237 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000238 __u32 padding;
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000239};
240
241struct fuse_getxattr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000242 __u32 size;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000243 __u32 padding;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000244};
245
Miklos Szeredie3b83092005-07-22 17:24:30 +0000246struct fuse_lk_in_out {
247 struct fuse_file_lock lk;
248};
249
Miklos Szeredi7b28eae2005-08-01 12:48:30 +0000250struct fuse_access_in {
251 __u32 mask;
252 __u32 padding;
253};
254
Miklos Szeredi3f0005f2005-01-04 19:24:31 +0000255struct fuse_init_in_out {
256 __u32 major;
257 __u32 minor;
258};
259
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000260struct fuse_in_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000261 __u32 len;
262 __u32 opcode;
263 __u64 unique;
264 __u64 nodeid;
265 __u32 uid;
266 __u32 gid;
267 __u32 pid;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000268 __u32 padding;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000269};
270
271struct fuse_out_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000272 __u32 len;
273 __s32 error;
274 __u64 unique;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000275};
276
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000277struct fuse_dirent {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000278 __u64 ino;
Miklos Szeredieab72ef2005-03-31 19:59:12 +0000279 __u64 off;
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000280 __u32 namelen;
281 __u32 type;
282 char name[0];
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000283};
284
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000285#define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
286#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000287#define FUSE_DIRENT_SIZE(d) \
288 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)