blob: 40f395043ef0cf08cdf9300ba11749cf3f64230d [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
20/** Data passed to mount */
21struct fuse_mount_data {
22 /** Must be set to FUSE_KERNEL_VERSION */
23 int version;
24
25 /** The control file descriptor */
26 int fd;
27
28 /** The file type of the root inode */
29 unsigned int rootmode;
30
31 /** The user ID of the user initiating this mount */
32 unsigned int uid;
33
34 /** FUSE specific mount flags */
35 unsigned int flags;
36};
37
Miklos Szeredife25def2001-12-20 15:38:05 +000038/* FUSE mount flags: */
39
40/** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
41module will check permissions based on the file mode. Otherwise no
42permission checking is done in the kernel */
43#define FUSE_DEFAULT_PERMISSIONS (1 << 0)
44
45/** If the FUSE_ALLOW_OTHER flag is given, then not only the user
46 doing the mount will be allowed to access the filesystem */
47#define FUSE_ALLOW_OTHER (1 << 1)
48
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000049struct fuse_attr {
Miklos Szeredi5e183482001-10-31 14:52:35 +000050 unsigned int mode;
51 unsigned int nlink;
52 unsigned int uid;
53 unsigned int gid;
54 unsigned int rdev;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000055 unsigned long long size;
Miklos Szeredi05033042001-11-13 16:11:35 +000056 unsigned long _dummy;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000057 unsigned long blocks;
58 unsigned long atime;
59 unsigned long mtime;
60 unsigned long ctime;
61};
62
Miklos Szeredi5e183482001-10-31 14:52:35 +000063#define FATTR_MODE (1 << 0)
64#define FATTR_UID (1 << 1)
65#define FATTR_GID (1 << 2)
66#define FATTR_SIZE (1 << 3)
67#define FATTR_UTIME (1 << 4)
68
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000069enum fuse_opcode {
Miklos Szeredi43696432001-11-18 19:15:05 +000070 FUSE_LOOKUP = 1,
71 FUSE_FORGET = 2,
72 FUSE_GETATTR = 3,
73 FUSE_SETATTR = 4,
74 FUSE_READLINK = 5,
75 FUSE_SYMLINK = 6,
76 FUSE_GETDIR = 7,
77 FUSE_MKNOD = 8,
78 FUSE_MKDIR = 9,
79 FUSE_UNLINK = 10,
80 FUSE_RMDIR = 11,
81 FUSE_RENAME = 12,
82 FUSE_LINK = 13,
83 FUSE_OPEN = 14,
84 FUSE_READ = 15,
85 FUSE_WRITE = 16,
Mark Glinesd84b39a2002-01-07 16:32:02 +000086 FUSE_STATFS = 17,
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000087};
88
89/* Conservative buffer size for the client */
90#define FUSE_MAX_IN 8192
91
92struct fuse_lookup_out {
93 unsigned long ino;
94 struct fuse_attr attr;
95};
96
Miklos Szeredia181e612001-11-06 12:03:23 +000097struct fuse_forget_in {
98 int version;
99};
100
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000101struct fuse_getattr_out {
102 struct fuse_attr attr;
103};
104
105struct fuse_getdir_out {
106 int fd;
107 void *file; /* Used by kernel only */
108};
109
110struct fuse_mknod_in {
111 unsigned short mode;
112 unsigned short rdev;
Miklos Szeredi43696432001-11-18 19:15:05 +0000113 char name[0];
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000114};
115
116struct fuse_mknod_out {
117 unsigned long ino;
118 struct fuse_attr attr;
119};
120
Miklos Szeredib483c932001-10-29 14:57:57 +0000121struct fuse_mkdir_in {
122 unsigned short mode;
Miklos Szeredi43696432001-11-18 19:15:05 +0000123 char name[0];
Miklos Szeredib483c932001-10-29 14:57:57 +0000124};
125
Miklos Szeredib483c932001-10-29 14:57:57 +0000126struct fuse_rename_in {
127 unsigned long newdir;
Miklos Szeredi43696432001-11-18 19:15:05 +0000128 char names[0];
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000129};
130
131struct fuse_link_in {
132 unsigned long newdir;
Miklos Szeredi43696432001-11-18 19:15:05 +0000133 char name[0];
Miklos Szeredib483c932001-10-29 14:57:57 +0000134};
135
Miklos Szeredi5e183482001-10-31 14:52:35 +0000136struct fuse_setattr_in {
137 struct fuse_attr attr;
138 unsigned int valid;
139};
140
Miklos Szeredia181e612001-11-06 12:03:23 +0000141struct fuse_setattr_out {
Miklos Szeredif3ea83b2001-11-07 14:55:16 +0000142 struct fuse_attr attr;
Miklos Szeredia181e612001-11-06 12:03:23 +0000143};
144
Miklos Szeredi5e183482001-10-31 14:52:35 +0000145struct fuse_open_in {
146 unsigned int flags;
147};
148
149struct fuse_read_in {
150 unsigned long long offset;
151 unsigned int size;
152};
153
Miklos Szeredia181e612001-11-06 12:03:23 +0000154struct fuse_write_in {
155 unsigned long long offset;
156 unsigned int size;
Miklos Szeredi43696432001-11-18 19:15:05 +0000157 char buf[0];
Miklos Szeredia181e612001-11-06 12:03:23 +0000158};
159
Mark Glinesd84b39a2002-01-07 16:32:02 +0000160typedef struct fuse_statfs {
161 long block_size;
162 long blocks;
163 long blocks_free;
164 long files;
165 long files_free;
166 long namelen;
167} fuse_statfs_t;
168
169struct fuse_statfs_out {
170 struct fuse_statfs st;
171};
172
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000173struct fuse_in_header {
174 int unique;
175 enum fuse_opcode opcode;
Miklos Szeredib483c932001-10-29 14:57:57 +0000176 unsigned long ino;
Miklos Szeredife25def2001-12-20 15:38:05 +0000177 unsigned int uid;
178 unsigned int gid;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000179};
180
181struct fuse_out_header {
182 int unique;
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000183 int error;
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000184};
185
186struct fuse_dirent {
187 unsigned long ino;
188 unsigned short namelen;
189 unsigned char type;
190 char name[256];
191};
192
193#define FUSE_NAME_OFFSET ((unsigned int) ((struct fuse_dirent *) 0)->name)
194#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(long) - 1) & ~(sizeof(long) - 1))
195#define FUSE_DIRENT_SIZE(d) \
196 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
197
198/*
199 * Local Variables:
200 * indent-tabs-mode: t
201 * c-basic-offset: 8
202 * End:
203 */