blob: 08ad214d4005fe58fc20d9c431a5e91cf96c4fe9 [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 Szeredife25def2001-12-20 15:38:05 +000012#define FUSE_KERNEL_VERSION 2
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000013
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000014/** The inode number of the root indode */
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000015#define FUSE_ROOT_INO 1
16
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000017/** Opening this will yield a new control file */
18#define FUSE_DEV "/proc/fs/fuse/dev"
19
Miklos Szeredi36ca5562003-11-03 19:32:14 +000020/** Read combining parameters */
21#define FUSE_BLOCK_SHIFT 16
22#define FUSE_BLOCK_SIZE 65536
23#define FUSE_BLOCK_MASK 0xffff0000
24
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000025/** Data passed to mount */
26struct fuse_mount_data {
27 /** Must be set to FUSE_KERNEL_VERSION */
28 int version;
29
30 /** The control file descriptor */
31 int fd;
32
33 /** The file type of the root inode */
34 unsigned int rootmode;
35
36 /** The user ID of the user initiating this mount */
37 unsigned int uid;
38
39 /** FUSE specific mount flags */
40 unsigned int flags;
41};
42
Miklos Szeredife25def2001-12-20 15:38:05 +000043/* FUSE mount flags: */
44
45/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
46module will check permissions based on the file mode. Otherwise no
47permission checking is done in the kernel */
48#define FUSE_DEFAULT_PERMISSIONS (1 << 0)
49
50/** If the FUSE_ALLOW_OTHER flag is given, then not only the user
51 doing the mount will be allowed to access the filesystem */
52#define FUSE_ALLOW_OTHER (1 << 1)
53
Miklos Szeredida4e4862003-09-08 11:14:11 +000054/** If the FUSE_KERNEL_CACHE flag is given, then files will be cached
55 until the INVALIDATE operation is invoked */
56#define FUSE_KERNEL_CACHE (1 << 2)
57
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000058struct fuse_attr {
Miklos Szeredi5e183482001-10-31 14:52:35 +000059 unsigned int mode;
60 unsigned int nlink;
61 unsigned int uid;
62 unsigned int gid;
63 unsigned int rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000064 unsigned long long size;
Miklos Szeredi05033042001-11-13 16:11:35 +000065 unsigned long _dummy;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000066 unsigned long blocks;
67 unsigned long atime;
68 unsigned long mtime;
69 unsigned long ctime;
70};
71
Miklos Szeredi24ed9452002-10-07 10:24:26 +000072struct fuse_kstatfs {
73 long block_size;
74 long blocks;
75 long blocks_free;
76 long files;
77 long files_free;
78 long namelen;
79};
80
Miklos Szeredi5e183482001-10-31 14:52:35 +000081#define FATTR_MODE (1 << 0)
82#define FATTR_UID (1 << 1)
83#define FATTR_GID (1 << 2)
84#define FATTR_SIZE (1 << 3)
85#define FATTR_UTIME (1 << 4)
86
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000087enum fuse_opcode {
Miklos Szeredi43696432001-11-18 19:15:05 +000088 FUSE_LOOKUP = 1,
Miklos Szeredida4e4862003-09-08 11:14:11 +000089 FUSE_FORGET = 2, /* no reply */
Miklos Szeredi43696432001-11-18 19:15:05 +000090 FUSE_GETATTR = 3,
91 FUSE_SETATTR = 4,
92 FUSE_READLINK = 5,
93 FUSE_SYMLINK = 6,
94 FUSE_GETDIR = 7,
95 FUSE_MKNOD = 8,
96 FUSE_MKDIR = 9,
97 FUSE_UNLINK = 10,
98 FUSE_RMDIR = 11,
99 FUSE_RENAME = 12,
100 FUSE_LINK = 13,
101 FUSE_OPEN = 14,
102 FUSE_READ = 15,
103 FUSE_WRITE = 16,
Mark Glinesd84b39a2002-01-07 16:32:02 +0000104 FUSE_STATFS = 17,
Miklos Szeredida4e4862003-09-08 11:14:11 +0000105 FUSE_RELEASE = 18, /* no reply */
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000106 FUSE_INVALIDATE = 19, /* user initiated */
107 FUSE_FSYNC = 20
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000108};
109
110/* Conservative buffer size for the client */
111#define FUSE_MAX_IN 8192
112
113struct fuse_lookup_out {
114 unsigned long ino;
115 struct fuse_attr attr;
116};
117
Miklos Szeredia181e612001-11-06 12:03:23 +0000118struct fuse_forget_in {
119 int version;
120};
121
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000122struct fuse_getattr_out {
123 struct fuse_attr attr;
124};
125
126struct fuse_getdir_out {
127 int fd;
128 void *file; /* Used by kernel only */
129};
130
131struct fuse_mknod_in {
132 unsigned short mode;
133 unsigned short rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000134};
135
136struct fuse_mknod_out {
137 unsigned long ino;
138 struct fuse_attr attr;
139};
140
Miklos Szeredib483c932001-10-29 14:57:57 +0000141struct fuse_mkdir_in {
142 unsigned short mode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000143};
144
Miklos Szeredib483c932001-10-29 14:57:57 +0000145struct fuse_rename_in {
146 unsigned long newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000147};
148
149struct fuse_link_in {
150 unsigned long newdir;
Miklos Szeredib483c932001-10-29 14:57:57 +0000151};
152
Miklos Szeredi5e183482001-10-31 14:52:35 +0000153struct fuse_setattr_in {
154 struct fuse_attr attr;
155 unsigned int valid;
156};
157
Miklos Szeredia181e612001-11-06 12:03:23 +0000158struct fuse_setattr_out {
Miklos Szeredif3ea83b2001-11-07 14:55:16 +0000159 struct fuse_attr attr;
Miklos Szeredia181e612001-11-06 12:03:23 +0000160};
161
Miklos Szeredi5e183482001-10-31 14:52:35 +0000162struct fuse_open_in {
163 unsigned int flags;
164};
165
166struct fuse_read_in {
167 unsigned long long offset;
168 unsigned int size;
169};
170
Miklos Szeredia181e612001-11-06 12:03:23 +0000171struct fuse_write_in {
172 unsigned long long offset;
173 unsigned int size;
Miklos Szeredia181e612001-11-06 12:03:23 +0000174};
175
Mark Glinesd84b39a2002-01-07 16:32:02 +0000176struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000177 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000178};
179
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000180struct fuse_fsync_in {
181 int datasync;
182};
183
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000184struct fuse_in_header {
185 int unique;
186 enum fuse_opcode opcode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000187 unsigned long ino;
Miklos Szeredife25def2001-12-20 15:38:05 +0000188 unsigned int uid;
189 unsigned int gid;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000190};
191
192struct fuse_out_header {
193 int unique;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000194 int error;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000195};
196
Miklos Szeredida4e4862003-09-08 11:14:11 +0000197struct fuse_user_header {
198 int unique; /* zero */
199 enum fuse_opcode opcode;
200 unsigned long ino;
201};
202
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000203struct fuse_dirent {
204 unsigned long ino;
205 unsigned short namelen;
206 unsigned char type;
207 char name[256];
208};
209
210#define FUSE_NAME_OFFSET ((unsigned int) ((struct fuse_dirent *) 0)->name)
211#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(long) - 1) & ~(sizeof(long) - 1))
212#define FUSE_DIRENT_SIZE(d) \
213 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
214
215/*
216 * Local Variables:
217 * indent-tabs-mode: t
218 * c-basic-offset: 8
219 * End:
220 */