fuse_kernel.h revision 253331
1/*- 2 * This file defines the kernel interface of FUSE 3 * Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> 4 * 5 * This program can be distributed under the terms of the GNU GPL. 6 * See the file COPYING. 7 * 8 * This -- and only this -- header file may also be distributed under 9 * the terms of the BSD Licence as follows: 10 * 11 * Copyright (C) 2001-2007 Miklos Szeredi. All rights reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $FreeBSD: head/sys/fs/fuse/fuse_kernel.h 253331 2013-07-13 22:06:41Z pfg $ 35 */ 36 37#ifndef linux 38#include <sys/types.h> 39#define __u64 uint64_t 40#define __u32 uint32_t 41#define __s32 int32_t 42#else 43#include <asm/types.h> 44#include <linux/major.h> 45#endif 46 47/** Version number of this interface */ 48#define FUSE_KERNEL_VERSION 7 49 50/** Minor version number of this interface */ 51#define FUSE_KERNEL_MINOR_VERSION 8 52 53/** The node ID of the root inode */ 54#define FUSE_ROOT_ID 1 55 56/** The major number of the fuse character device */ 57#define FUSE_MAJOR MISC_MAJOR 58 59/** The minor number of the fuse character device */ 60#define FUSE_MINOR 229 61 62/* Make sure all structures are padded to 64bit boundary, so 32bit 63 userspace works under 64bit kernels */ 64 65struct fuse_attr { 66 __u64 ino; 67 __u64 size; 68 __u64 blocks; 69 __u64 atime; 70 __u64 mtime; 71 __u64 ctime; 72 __u64 crtime; 73 __u32 atimensec; 74 __u32 mtimensec; 75 __u32 ctimensec; 76 __u32 crtimensec; 77 __u32 mode; 78 __u32 nlink; 79 __u32 uid; 80 __u32 gid; 81 __u32 rdev; 82 __u32 padding; 83}; 84 85struct fuse_kstatfs { 86 __u64 blocks; 87 __u64 bfree; 88 __u64 bavail; 89 __u64 files; 90 __u64 ffree; 91 __u32 bsize; 92 __u32 namelen; 93 __u32 frsize; 94 __u32 padding; 95 __u32 spare[6]; 96}; 97 98struct fuse_file_lock { 99 __u64 start; 100 __u64 end; 101 __u32 type; 102 __u32 pid; /* tgid */ 103}; 104 105/** 106 * Bitmasks for fuse_setattr_in.valid 107 */ 108#define FATTR_MODE (1 << 0) 109#define FATTR_UID (1 << 1) 110#define FATTR_GID (1 << 2) 111#define FATTR_SIZE (1 << 3) 112#define FATTR_ATIME (1 << 4) 113#define FATTR_MTIME (1 << 5) 114#define FATTR_FH (1 << 6) 115 116/** 117 * Flags returned by the OPEN request 118 * 119 * FOPEN_DIRECT_IO: bypass page cache for this open file 120 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open 121 */ 122#define FOPEN_DIRECT_IO (1 << 0) 123#define FOPEN_KEEP_CACHE (1 << 1) 124 125/** 126 * INIT request/reply flags 127 */ 128#define FUSE_ASYNC_READ (1 << 0) 129#define FUSE_POSIX_LOCKS (1 << 1) 130 131/** 132 * Release flags 133 */ 134#define FUSE_RELEASE_FLUSH (1 << 0) 135 136enum fuse_opcode { 137 FUSE_LOOKUP = 1, 138 FUSE_FORGET = 2, /* no reply */ 139 FUSE_GETATTR = 3, 140 FUSE_SETATTR = 4, 141 FUSE_READLINK = 5, 142 FUSE_SYMLINK = 6, 143 FUSE_MKNOD = 8, 144 FUSE_MKDIR = 9, 145 FUSE_UNLINK = 10, 146 FUSE_RMDIR = 11, 147 FUSE_RENAME = 12, 148 FUSE_LINK = 13, 149 FUSE_OPEN = 14, 150 FUSE_READ = 15, 151 FUSE_WRITE = 16, 152 FUSE_STATFS = 17, 153 FUSE_RELEASE = 18, 154 FUSE_FSYNC = 20, 155 FUSE_SETXATTR = 21, 156 FUSE_GETXATTR = 22, 157 FUSE_LISTXATTR = 23, 158 FUSE_REMOVEXATTR = 24, 159 FUSE_FLUSH = 25, 160 FUSE_INIT = 26, 161 FUSE_OPENDIR = 27, 162 FUSE_READDIR = 28, 163 FUSE_RELEASEDIR = 29, 164 FUSE_FSYNCDIR = 30, 165 FUSE_GETLK = 31, 166 FUSE_SETLK = 32, 167 FUSE_SETLKW = 33, 168 FUSE_ACCESS = 34, 169 FUSE_CREATE = 35, 170 FUSE_INTERRUPT = 36, 171 FUSE_BMAP = 37, 172 FUSE_DESTROY = 38, 173}; 174 175/* The read buffer is required to be at least 8k, but may be much larger */ 176#define FUSE_MIN_READ_BUFFER 8192 177 178struct fuse_entry_out { 179 __u64 nodeid; /* Inode ID */ 180 __u64 generation; /* Inode generation: nodeid:gen must 181 be unique for the fs's lifetime */ 182 __u64 entry_valid; /* Cache timeout for the name */ 183 __u64 attr_valid; /* Cache timeout for the attributes */ 184 __u32 entry_valid_nsec; 185 __u32 attr_valid_nsec; 186 struct fuse_attr attr; 187}; 188 189struct fuse_forget_in { 190 __u64 nlookup; 191}; 192 193struct fuse_attr_out { 194 __u64 attr_valid; /* Cache timeout for the attributes */ 195 __u32 attr_valid_nsec; 196 __u32 dummy; 197 struct fuse_attr attr; 198}; 199 200struct fuse_mkdir_in { 201 __u32 mode; 202 __u32 padding; 203}; 204 205struct fuse_rename_in { 206 __u64 newdir; 207}; 208 209struct fuse_link_in { 210 __u64 oldnodeid; 211}; 212 213struct fuse_setattr_in { 214 __u32 valid; 215 __u32 padding; 216 __u64 fh; 217 __u64 size; 218 __u64 unused1; 219 __u64 atime; 220 __u64 mtime; 221 __u64 unused2; 222 __u32 atimensec; 223 __u32 mtimensec; 224 __u32 unused3; 225 __u32 mode; 226 __u32 unused4; 227 __u32 uid; 228 __u32 gid; 229 __u32 unused5; 230}; 231 232struct fuse_open_in { 233 __u32 flags; 234 __u32 mode; 235}; 236 237struct fuse_open_out { 238 __u64 fh; 239 __u32 open_flags; 240 __u32 padding; 241}; 242 243struct fuse_release_in { 244 __u64 fh; 245 __u32 flags; 246 __u32 release_flags; 247 __u64 lock_owner; 248}; 249 250struct fuse_flush_in { 251 __u64 fh; 252 __u32 unused; 253 __u32 padding; 254 __u64 lock_owner; 255}; 256 257struct fuse_read_in { 258 __u64 fh; 259 __u64 offset; 260 __u32 size; 261 __u32 padding; 262}; 263 264struct fuse_write_in { 265 __u64 fh; 266 __u64 offset; 267 __u32 size; 268 __u32 write_flags; 269}; 270 271struct fuse_write_out { 272 __u32 size; 273 __u32 padding; 274}; 275 276#define FUSE_COMPAT_STATFS_SIZE 48 277 278struct fuse_statfs_out { 279 struct fuse_kstatfs st; 280}; 281 282struct fuse_fsync_in { 283 __u64 fh; 284 __u32 fsync_flags; 285 __u32 padding; 286}; 287 288struct fuse_setxattr_in { 289 __u32 size; 290 __u32 flags; 291}; 292 293struct fuse_getxattr_in { 294 __u32 size; 295 __u32 padding; 296}; 297 298struct fuse_getxattr_out { 299 __u32 size; 300 __u32 padding; 301}; 302 303struct fuse_lk_in { 304 __u64 fh; 305 __u64 owner; 306 struct fuse_file_lock lk; 307}; 308 309struct fuse_lk_out { 310 struct fuse_file_lock lk; 311}; 312 313struct fuse_access_in { 314 __u32 mask; 315 __u32 padding; 316}; 317 318struct fuse_init_in { 319 __u32 major; 320 __u32 minor; 321 __u32 max_readahead; 322 __u32 flags; 323}; 324 325struct fuse_init_out { 326 __u32 major; 327 __u32 minor; 328 __u32 max_readahead; 329 __u32 flags; 330 __u32 unused; 331 __u32 max_write; 332}; 333 334struct fuse_interrupt_in { 335 __u64 unique; 336}; 337 338struct fuse_bmap_in { 339 __u64 block; 340 __u32 blocksize; 341 __u32 padding; 342}; 343 344struct fuse_bmap_out { 345 __u64 block; 346}; 347 348struct fuse_in_header { 349 __u32 len; 350 __u32 opcode; 351 __u64 unique; 352 __u64 nodeid; 353 __u32 uid; 354 __u32 gid; 355 __u32 pid; 356 __u32 padding; 357}; 358 359struct fuse_out_header { 360 __u32 len; 361 __s32 error; 362 __u64 unique; 363}; 364 365struct fuse_dirent { 366 __u64 ino; 367 __u64 off; 368 __u32 namelen; 369 __u32 type; 370 char name[0]; 371}; 372 373#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) 374#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) 375#define FUSE_DIRENT_SIZE(d) \ 376 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) 377