blob: d5fd35781e6b8fc21b08e35f294b58b0a73caa41 [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
Miklos Szeredic40748a2004-02-20 16:38:45 +000023/** The file containing the version in the form MAJOR.MINOR */
24#define FUSE_VERSION_FILE "/proc/fs/fuse/version"
25
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000026/** Data passed to mount */
27struct fuse_mount_data {
Miklos Szeredi8cffdb92001-11-09 14:49:18 +000028 /** 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
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000122struct fuse_entry_out {
123 unsigned long ino; /* Inode number */
124 unsigned long generation; /* Inode generation: ino:gen must
125 be unique for the fs's lifetime */
126 unsigned long entry_valid; /* Cache timeout for the name */
127 unsigned long entry_valid_nsec;
128 unsigned long attr_valid; /* Cache timeout for the attributes */
129 unsigned long attr_valid_nsec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000130 struct fuse_attr attr;
131};
132
Miklos Szeredia181e612001-11-06 12:03:23 +0000133struct fuse_forget_in {
134 int version;
135};
136
Miklos Szeredi254d5ed2004-03-02 11:11:24 +0000137struct fuse_attr_out {
138 unsigned long attr_valid; /* Cache timeout for the attributes */
139 unsigned long attr_valid_nsec;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000140 struct fuse_attr attr;
141};
142
143struct fuse_getdir_out {
144 int fd;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000145};
146
147struct fuse_mknod_in {
Miklos Szeredi76f65782004-02-19 16:55:40 +0000148 unsigned int mode;
149 unsigned int rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000150};
151
Miklos Szeredib483c932001-10-29 14:57:57 +0000152struct fuse_mkdir_in {
Miklos Szeredi76f65782004-02-19 16:55:40 +0000153 unsigned int mode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000154};
155
Miklos Szeredib483c932001-10-29 14:57:57 +0000156struct fuse_rename_in {
157 unsigned long newdir;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000158};
159
160struct fuse_link_in {
161 unsigned long newdir;
Miklos Szeredib483c932001-10-29 14:57:57 +0000162};
163
Miklos Szeredi5e183482001-10-31 14:52:35 +0000164struct fuse_setattr_in {
165 struct fuse_attr attr;
166 unsigned int valid;
167};
168
169struct fuse_open_in {
170 unsigned int flags;
171};
172
173struct fuse_read_in {
174 unsigned long long offset;
175 unsigned int size;
176};
177
Miklos Szeredia181e612001-11-06 12:03:23 +0000178struct fuse_write_in {
179 unsigned long long offset;
180 unsigned int size;
Miklos Szeredia181e612001-11-06 12:03:23 +0000181};
182
Mark Glinesd84b39a2002-01-07 16:32:02 +0000183struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000184 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000185};
186
Miklos Szeredi5e43f2c2003-12-12 14:06:41 +0000187struct fuse_fsync_in {
188 int datasync;
189};
190
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000191struct fuse_in_header {
192 int unique;
193 enum fuse_opcode opcode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000194 unsigned long ino;
Miklos Szeredife25def2001-12-20 15:38:05 +0000195 unsigned int uid;
196 unsigned int gid;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000197};
198
199struct fuse_out_header {
200 int unique;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000201 int error;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000202};
203
Miklos Szeredida4e4862003-09-08 11:14:11 +0000204struct fuse_user_header {
205 int unique; /* zero */
206 enum fuse_opcode opcode;
207 unsigned long ino;
208};
209
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000210struct fuse_dirent {
211 unsigned long ino;
212 unsigned short namelen;
213 unsigned char type;
214 char name[256];
215};
216
217#define FUSE_NAME_OFFSET ((unsigned int) ((struct fuse_dirent *) 0)->name)
218#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(long) - 1) & ~(sizeof(long) - 1))
219#define FUSE_DIRENT_SIZE(d) \
220 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
221
222/*
223 * Local Variables:
224 * indent-tabs-mode: t
225 * c-basic-offset: 8
226 * End:
227 */