blob: 10ef1864f3f91c34bd3dbf9257cf8f7467752b80 [file] [log] [blame]
Miklos Szeredi85c74fc2001-10-28 19:44:14 +00001/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001 Miklos Szeredi (mszeredi@inf.bme.hu)
4
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 Szeredi8cffdb92001-11-09 14:49:18 +000011/** Version number of this interface */
Miklos Szeredi18e75e42004-02-19 14:23:27 +000012#define FUSE_KERNEL_VERSION 3
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000013
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000014/** Minor version number of this interface */
Miklos Szeredi18e75e42004-02-19 14:23:27 +000015#define FUSE_KERNEL_MINOR_VERSION 1
Miklos Szeredi2f3d9402003-12-15 12:11:33 +000016
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000017/** The inode number of the root indode */
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000018#define FUSE_ROOT_INO 1
19
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000020/** Opening this will yield a new control file */
21#define FUSE_DEV "/proc/fs/fuse/dev"
22
23/** Data passed to mount */
24struct fuse_mount_data {
25 /** Must be set to FUSE_KERNEL_VERSION */
26 int version;
27
28 /** The control file descriptor */
29 int fd;
30
31 /** The file type of the root inode */
32 unsigned int rootmode;
33
34 /** The user ID of the user initiating this mount */
35 unsigned int uid;
36
37 /** FUSE specific mount flags */
38 unsigned int flags;
39};
40
Miklos Szeredife25def2001-12-20 15:38:05 +000041/* FUSE mount flags: */
42
43/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
44module will check permissions based on the file mode. Otherwise no
45permission checking is done in the kernel */
46#define FUSE_DEFAULT_PERMISSIONS (1 << 0)
47
48/** If the FUSE_ALLOW_OTHER flag is given, then not only the user
49 doing the mount will be allowed to access the filesystem */
50#define FUSE_ALLOW_OTHER (1 << 1)
51
Miklos Szeredida4e4862003-09-08 11:14:11 +000052/** If the FUSE_KERNEL_CACHE flag is given, then files will be cached
53 until the INVALIDATE operation is invoked */
54#define FUSE_KERNEL_CACHE (1 << 2)
55
Miklos Szeredi307242f2004-01-26 11:28:44 +000056/** Allow FUSE to combine reads into 64k chunks. This is useful if
57 the filesystem is better at handling large chunks. NOTE: in
58 current implementation the raw throughput is worse for large reads
59 than for small. */
60#define FUSE_LARGE_READ (1 << 3)
61
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000062struct fuse_attr {
Miklos Szeredi5e183482001-10-31 14:52:35 +000063 unsigned int mode;
64 unsigned int nlink;
65 unsigned int uid;
66 unsigned int gid;
67 unsigned int rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000068 unsigned long long size;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000069 unsigned long blocks;
70 unsigned long atime;
Miklos Szeredib5958612004-02-20 14:10:49 +000071 unsigned long atimensec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000072 unsigned long mtime;
Miklos Szeredib5958612004-02-20 14:10:49 +000073 unsigned long mtimensec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000074 unsigned long ctime;
Miklos Szeredib5958612004-02-20 14:10:49 +000075 unsigned long ctimensec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000076};
77
Miklos Szeredi24ed9452002-10-07 10:24:26 +000078struct fuse_kstatfs {
Miklos Szeredi18e75e42004-02-19 14:23:27 +000079 unsigned int bsize;
80 unsigned long long blocks;
81 unsigned long long bfree;
82 unsigned long long bavail;
83 unsigned long long files;
84 unsigned long long ffree;
85 unsigned int namelen;
Miklos Szeredi24ed9452002-10-07 10:24:26 +000086};
87
Miklos Szeredi5e183482001-10-31 14:52:35 +000088#define FATTR_MODE (1 << 0)
89#define FATTR_UID (1 << 1)
90#define FATTR_GID (1 << 2)
91#define FATTR_SIZE (1 << 3)
Miklos Szeredib5958612004-02-20 14:10:49 +000092#define FATTR_ATIME (1 << 4)
93#define FATTR_MTIME (1 << 5)
94#define FATTR_CTIME (1 << 6)
Miklos Szeredi5e183482001-10-31 14:52:35 +000095
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000096enum fuse_opcode {
Miklos Szeredi43696432001-11-18 19:15:05 +000097 FUSE_LOOKUP = 1,
Miklos Szeredida4e4862003-09-08 11:14:11 +000098 FUSE_FORGET = 2, /* no reply */
Miklos Szeredi43696432001-11-18 19:15:05 +000099 FUSE_GETATTR = 3,
100 FUSE_SETATTR = 4,
101 FUSE_READLINK = 5,
102 FUSE_SYMLINK = 6,
103 FUSE_GETDIR = 7,
104 FUSE_MKNOD = 8,
105 FUSE_MKDIR = 9,
106 FUSE_UNLINK = 10,
107 FUSE_RMDIR = 11,
108 FUSE_RENAME = 12,
109 FUSE_LINK = 13,
110 FUSE_OPEN = 14,
111 FUSE_READ = 15,
112 FUSE_WRITE = 16,
Mark Glinesd84b39a2002-01-07 16:32:02 +0000113 FUSE_STATFS = 17,
Miklos Szeredida4e4862003-09-08 11:14:11 +0000114 FUSE_RELEASE = 18, /* no reply */
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000115 FUSE_INVALIDATE = 19, /* user initiated */
116 FUSE_FSYNC = 20
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000117};
118
119/* Conservative buffer size for the client */
120#define FUSE_MAX_IN 8192
121
122struct fuse_lookup_out {
123 unsigned long ino;
Miklos Szeredi76f65782004-02-19 16:55:40 +0000124 unsigned long generation;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000125 struct fuse_attr attr;
126};
127
Miklos Szeredia181e612001-11-06 12:03:23 +0000128struct fuse_forget_in {
129 int version;
130};
131
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000132struct fuse_getattr_out {
133 struct fuse_attr attr;
134};
135
136struct fuse_getdir_out {
137 int fd;
138 void *file; /* Used by kernel only */
139};
140
141struct fuse_mknod_in {
Miklos Szeredi76f65782004-02-19 16:55:40 +0000142 unsigned int mode;
143 unsigned int rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000144};
145
Miklos Szeredib483c932001-10-29 14:57:57 +0000146struct fuse_mkdir_in {
Miklos Szeredi76f65782004-02-19 16:55:40 +0000147 unsigned int mode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000148};
149
Miklos Szeredib483c932001-10-29 14:57:57 +0000150struct fuse_rename_in {
151 unsigned long newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000152};
153
154struct fuse_link_in {
155 unsigned long newdir;
Miklos Szeredib483c932001-10-29 14:57:57 +0000156};
157
Miklos Szeredi5e183482001-10-31 14:52:35 +0000158struct fuse_setattr_in {
159 struct fuse_attr attr;
160 unsigned int valid;
161};
162
Miklos Szeredia181e612001-11-06 12:03:23 +0000163struct fuse_setattr_out {
Miklos Szeredif3ea83b2001-11-07 14:55:16 +0000164 struct fuse_attr attr;
Miklos Szeredia181e612001-11-06 12:03:23 +0000165};
166
Miklos Szeredi5e183482001-10-31 14:52:35 +0000167struct fuse_open_in {
168 unsigned int flags;
169};
170
171struct fuse_read_in {
172 unsigned long long offset;
173 unsigned int size;
174};
175
Miklos Szeredia181e612001-11-06 12:03:23 +0000176struct fuse_write_in {
177 unsigned long long offset;
178 unsigned int size;
Miklos Szeredia181e612001-11-06 12:03:23 +0000179};
180
Mark Glinesd84b39a2002-01-07 16:32:02 +0000181struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000182 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000183};
184
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000185struct fuse_fsync_in {
186 int datasync;
187};
188
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000189struct fuse_in_header {
190 int unique;
191 enum fuse_opcode opcode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000192 unsigned long ino;
Miklos Szeredife25def2001-12-20 15:38:05 +0000193 unsigned int uid;
194 unsigned int gid;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000195};
196
197struct fuse_out_header {
198 int unique;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000199 int error;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000200};
201
Miklos Szeredida4e4862003-09-08 11:14:11 +0000202struct fuse_user_header {
203 int unique; /* zero */
204 enum fuse_opcode opcode;
205 unsigned long ino;
206};
207
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000208struct fuse_dirent {
209 unsigned long ino;
210 unsigned short namelen;
211 unsigned char type;
212 char name[256];
213};
214
215#define FUSE_NAME_OFFSET ((unsigned int) ((struct fuse_dirent *) 0)->name)
216#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(long) - 1) & ~(sizeof(long) - 1))
217#define FUSE_DIRENT_SIZE(d) \
218 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
219
220/*
221 * Local Variables:
222 * indent-tabs-mode: t
223 * c-basic-offset: 8
224 * End:
225 */