blob: cd8f46f2f7ffa4ec4fc2c042982d4af444ec28ee [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 Szeredie56818b2004-12-12 11:45:24 +000014#define FUSE_KERNEL_VERSION 5
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000015
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000016/** Minor version number of this interface */
Miklos Szeredie56818b2004-12-12 11:45:24 +000017#define FUSE_KERNEL_MINOR_VERSION 1
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 Szeredi85c74fc2001-10-28 19:44:14 +000028struct fuse_attr {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000029 __u64 ino;
30 __u64 size;
31 __u64 blocks;
32 __u64 atime;
33 __u64 mtime;
34 __u64 ctime;
35 __u32 atimensec;
36 __u32 mtimensec;
37 __u32 ctimensec;
38 __u32 mode;
39 __u32 nlink;
40 __u32 uid;
41 __u32 gid;
42 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000043};
44
Miklos Szeredi24ed9452002-10-07 10:24:26 +000045struct fuse_kstatfs {
Miklos Szeredi0f62d722005-01-04 12:45:54 +000046 __u64 blocks;
47 __u64 bfree;
48 __u64 bavail;
49 __u64 files;
50 __u64 ffree;
51 __u32 bsize;
52 __u32 namelen;
Miklos Szeredi24ed9452002-10-07 10:24:26 +000053};
54
Miklos Szeredi5e183482001-10-31 14:52:35 +000055#define FATTR_MODE (1 << 0)
56#define FATTR_UID (1 << 1)
57#define FATTR_GID (1 << 2)
58#define FATTR_SIZE (1 << 3)
Miklos Szeredib5958612004-02-20 14:10:49 +000059#define FATTR_ATIME (1 << 4)
60#define FATTR_MTIME (1 << 5)
61#define FATTR_CTIME (1 << 6)
Miklos Szeredi5e183482001-10-31 14:52:35 +000062
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000063enum fuse_opcode {
Miklos Szeredi3ed84232004-03-30 15:17:26 +000064 FUSE_LOOKUP = 1,
65 FUSE_FORGET = 2, /* no reply */
66 FUSE_GETATTR = 3,
67 FUSE_SETATTR = 4,
68 FUSE_READLINK = 5,
69 FUSE_SYMLINK = 6,
Miklos Szeredi3ed84232004-03-30 15:17:26 +000070 FUSE_MKNOD = 8,
71 FUSE_MKDIR = 9,
72 FUSE_UNLINK = 10,
73 FUSE_RMDIR = 11,
74 FUSE_RENAME = 12,
75 FUSE_LINK = 13,
76 FUSE_OPEN = 14,
77 FUSE_READ = 15,
78 FUSE_WRITE = 16,
79 FUSE_STATFS = 17,
Miklos Szeredi72cf5c92004-11-20 16:10:30 +000080 FUSE_RELEASE = 18,
Miklos Szeredi3ed84232004-03-30 15:17:26 +000081 FUSE_FSYNC = 20,
82 FUSE_SETXATTR = 21,
83 FUSE_GETXATTR = 22,
84 FUSE_LISTXATTR = 23,
85 FUSE_REMOVEXATTR = 24,
Miklos Szeredie2e4ac22004-05-18 08:45:28 +000086 FUSE_FLUSH = 25,
Miklos Szeredi3ead28e2005-01-18 21:23:41 +000087 FUSE_INIT = 26,
88 FUSE_OPENDIR = 27,
89 FUSE_READDIR = 28,
90 FUSE_RELEASEDIR = 29
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000091};
92
93/* Conservative buffer size for the client */
94#define FUSE_MAX_IN 8192
95
Miklos Szeredic26c14d2004-04-09 17:48:32 +000096#define FUSE_NAME_MAX 1024
97#define FUSE_SYMLINK_MAX 4096
98#define FUSE_XATTR_SIZE_MAX 4096
99
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000100struct fuse_entry_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000101 __u64 nodeid; /* Inode ID */
102 __u64 generation; /* Inode generation: nodeid:gen must
103 be unique for the fs's lifetime */
104 __u64 entry_valid; /* Cache timeout for the name */
105 __u64 attr_valid; /* Cache timeout for the attributes */
106 __u32 entry_valid_nsec;
107 __u32 attr_valid_nsec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000108 struct fuse_attr attr;
109};
110
Miklos Szeredia181e612001-11-06 12:03:23 +0000111struct fuse_forget_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000112 __u64 version;
Miklos Szeredia181e612001-11-06 12:03:23 +0000113};
114
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000115struct fuse_attr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000116 __u64 attr_valid; /* Cache timeout for the attributes */
117 __u32 attr_valid_nsec;
118 __u32 dummy;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000119 struct fuse_attr attr;
120};
121
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000122struct fuse_mknod_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000123 __u32 mode;
124 __u32 rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000125};
126
Miklos Szeredib483c932001-10-29 14:57:57 +0000127struct fuse_mkdir_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000128 __u32 mode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000129};
130
Miklos Szeredib483c932001-10-29 14:57:57 +0000131struct fuse_rename_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000132 __u64 newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000133};
134
135struct fuse_link_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000136 __u64 newdir;
Miklos Szeredib483c932001-10-29 14:57:57 +0000137};
138
Miklos Szeredi5e183482001-10-31 14:52:35 +0000139struct fuse_setattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000140 __u32 valid;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000141 struct fuse_attr attr;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000142};
143
144struct fuse_open_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000145 __u32 flags;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000146};
147
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000148struct fuse_open_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000149 __u64 fh;
150 __u32 open_flags;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000151};
152
153struct fuse_release_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000154 __u64 fh;
155 __u32 flags;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000156};
157
158struct fuse_flush_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000159 __u64 fh;
160 __u32 flush_flags;
Miklos Szeredi209f5d02004-07-24 19:56:16 +0000161};
162
Miklos Szeredi5e183482001-10-31 14:52:35 +0000163struct fuse_read_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000164 __u64 fh;
165 __u64 offset;
166 __u32 size;
Miklos Szeredi5e183482001-10-31 14:52:35 +0000167};
168
Miklos Szeredia181e612001-11-06 12:03:23 +0000169struct fuse_write_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000170 __u64 fh;
171 __u64 offset;
172 __u32 size;
173 __u32 write_flags;
Miklos Szeredia181e612001-11-06 12:03:23 +0000174};
175
Miklos Szerediad051c32004-07-02 09:22:50 +0000176struct fuse_write_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000177 __u32 size;
Miklos Szerediad051c32004-07-02 09:22:50 +0000178};
179
Mark Glinesd84b39a2002-01-07 16:32:02 +0000180struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000181 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000182};
183
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000184struct fuse_fsync_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000185 __u64 fh;
186 __u32 fsync_flags;
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000187};
188
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000189struct fuse_setxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000190 __u32 size;
191 __u32 flags;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000192};
193
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000194struct fuse_getxattr_in {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000195 __u32 size;
Miklos Szeredi03cebae2004-03-31 10:19:18 +0000196};
197
198struct fuse_getxattr_out {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000199 __u32 size;
Miklos Szeredi3ed84232004-03-30 15:17:26 +0000200};
201
Miklos Szeredi3f0005f2005-01-04 19:24:31 +0000202struct fuse_init_in_out {
203 __u32 major;
204 __u32 minor;
205};
206
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000207struct fuse_in_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000208 __u32 len;
209 __u32 opcode;
210 __u64 unique;
211 __u64 nodeid;
212 __u32 uid;
213 __u32 gid;
214 __u32 pid;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000215};
216
217struct fuse_out_header {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000218 __u32 len;
219 __s32 error;
220 __u64 unique;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000221};
222
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000223struct fuse_dirent {
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000224 __u64 ino;
225 __u32 namelen;
226 __u32 type;
227 char name[0];
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000228};
229
Miklos Szeredi0f62d722005-01-04 12:45:54 +0000230#define FUSE_NAME_OFFSET ((unsigned) ((struct fuse_dirent *) 0)->name)
231#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000232#define FUSE_DIRENT_SIZE(d) \
233 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)