blob: b6f41db925eb96525dd0d645192084e230396ed2 [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 Szeredi24ed9452002-10-07 10:24:26 +000063struct fuse_kstatfs {
64 long block_size;
65 long blocks;
66 long blocks_free;
67 long files;
68 long files_free;
69 long namelen;
70};
71
Miklos Szeredi5e183482001-10-31 14:52:35 +000072#define FATTR_MODE (1 << 0)
73#define FATTR_UID (1 << 1)
74#define FATTR_GID (1 << 2)
75#define FATTR_SIZE (1 << 3)
76#define FATTR_UTIME (1 << 4)
77
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000078enum fuse_opcode {
Miklos Szeredi43696432001-11-18 19:15:05 +000079 FUSE_LOOKUP = 1,
80 FUSE_FORGET = 2,
81 FUSE_GETATTR = 3,
82 FUSE_SETATTR = 4,
83 FUSE_READLINK = 5,
84 FUSE_SYMLINK = 6,
85 FUSE_GETDIR = 7,
86 FUSE_MKNOD = 8,
87 FUSE_MKDIR = 9,
88 FUSE_UNLINK = 10,
89 FUSE_RMDIR = 11,
90 FUSE_RENAME = 12,
91 FUSE_LINK = 13,
92 FUSE_OPEN = 14,
93 FUSE_READ = 15,
94 FUSE_WRITE = 16,
Mark Glinesd84b39a2002-01-07 16:32:02 +000095 FUSE_STATFS = 17,
Miklos Szeredi85c74fc2001-10-28 19:44:14 +000096};
97
98/* Conservative buffer size for the client */
99#define FUSE_MAX_IN 8192
100
101struct fuse_lookup_out {
102 unsigned long ino;
103 struct fuse_attr attr;
104};
105
Miklos Szeredia181e612001-11-06 12:03:23 +0000106struct fuse_forget_in {
107 int version;
108};
109
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000110struct fuse_getattr_out {
111 struct fuse_attr attr;
112};
113
114struct fuse_getdir_out {
115 int fd;
116 void *file; /* Used by kernel only */
117};
118
119struct fuse_mknod_in {
120 unsigned short mode;
121 unsigned short rdev;
Miklos Szeredi43696432001-11-18 19:15:05 +0000122 char name[0];
Miklos Szeredi85c74fc2001-10-28 19:44:14 +0000123};
124
125struct fuse_mknod_out {
126 unsigned long ino;
127 struct fuse_attr attr;
128};
129
Miklos Szeredib483c932001-10-29 14:57:57 +0000130struct fuse_mkdir_in {
131 unsigned short mode;
Miklos Szeredi43696432001-11-18 19:15:05 +0000132 char name[0];
Miklos Szeredib483c932001-10-29 14:57:57 +0000133};
134
Miklos Szeredib483c932001-10-29 14:57:57 +0000135struct fuse_rename_in {
136 unsigned long newdir;
Miklos Szeredi43696432001-11-18 19:15:05 +0000137 char names[0];
Miklos Szeredi19dff1b2001-10-30 15:06:52 +0000138};
139
140struct fuse_link_in {
141 unsigned long newdir;
Miklos Szeredi43696432001-11-18 19:15:05 +0000142 char name[0];
Miklos Szeredib483c932001-10-29 14:57:57 +0000143};
144
Miklos Szeredi5e183482001-10-31 14:52:35 +0000145struct fuse_setattr_in {
146 struct fuse_attr attr;
147 unsigned int valid;
148};
149
Miklos Szeredia181e612001-11-06 12:03:23 +0000150struct fuse_setattr_out {
Miklos Szeredif3ea83b2001-11-07 14:55:16 +0000151 struct fuse_attr attr;
Miklos Szeredia181e612001-11-06 12:03:23 +0000152};
153
Miklos Szeredi5e183482001-10-31 14:52:35 +0000154struct fuse_open_in {
155 unsigned int flags;
156};
157
158struct fuse_read_in {
159 unsigned long long offset;
160 unsigned int size;
161};
162
Miklos Szeredia181e612001-11-06 12:03:23 +0000163struct fuse_write_in {
164 unsigned long long offset;
165 unsigned int size;
Miklos Szeredi43696432001-11-18 19:15:05 +0000166 char buf[0];
Miklos Szeredia181e612001-11-06 12:03:23 +0000167};
168
Mark Glinesd84b39a2002-01-07 16:32:02 +0000169struct fuse_statfs_out {
Miklos Szeredi24ed9452002-10-07 10:24:26 +0000170 struct fuse_kstatfs st;
Mark Glinesd84b39a2002-01-07 16:32:02 +0000171};
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 */