Home | History | Annotate | Line # | Download | only in libperfuse
fuse.h revision 1.4
      1 /*  $NetBSD: fuse.h,v 1.4 2011/06/28 16:19:16 manu Exp $ */
      2 
      3 /*-
      4  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
      5  *
      6  *  Redistribution and use in source and binary forms, with or without
      7  *  modification, are permitted provided that the following conditions
      8  *  are met:
      9  *  1. Redistributions of source code must retain the above copyright
     10  *     notice, this list of conditions and the following disclaimer.
     11  *  2. Redistributions in binary form must reproduce the above copyright
     12  *     notice, this list of conditions and the following disclaimer in the
     13  *     documentation and/or other materials provided with the distribution.
     14  *
     15  *  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  *  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  *  POSSIBILITY OF SUCH DAMAGE.
     26  */
     27 
     28 #ifndef _FUSE_H
     29 #define _FUSE_H
     30 
     31 #define FUSE_KERNEL_VERSION 7
     32 #define FUSE_KERNEL_MINOR_VERSION 12
     33 #define FUSE_ROOT_ID 1
     34 #define FUSE_UNKNOWN_FH (uint64_t)0
     35 
     36 #ifndef FUSE_BUFSIZE
     37 #define FUSE_MIN_BUFSIZE 0x21000
     38 #define FUSE_PREF_BUFSIZE (sysconf(_SC_PAGESIZE) + 0x1000)
     39 #define FUSE_BUFSIZE MAX(FUSE_PREF_BUFSIZE /* CONSTCOND */, FUSE_MIN_BUFSIZE)
     40 #endif /* FUSE_BUFSIZE */
     41 
     42 /* From <linux/limits.h> */
     43 #define LINUX_XATTR_NAME_MAX   255
     44 #define LINUX_XATTR_SIZE_MAX 65536
     45 #define LINUX_XATTR_LIST_MAX 65536
     46 
     47 struct fuse_attr {
     48 	uint64_t	ino;
     49 	uint64_t	size;
     50 	uint64_t	blocks;
     51 	uint64_t	atime;
     52 	uint64_t	mtime;
     53 	uint64_t	ctime;
     54 	uint32_t	atimensec;
     55 	uint32_t	mtimensec;
     56 	uint32_t	ctimensec;
     57 	uint32_t	mode;
     58 	uint32_t	nlink;
     59 	uint32_t	uid;
     60 	uint32_t	gid;
     61 	uint32_t	rdev;
     62 	uint32_t	blksize;
     63 	uint32_t	padding;
     64 };
     65 
     66 struct fuse_kstatfs {
     67 	uint64_t	blocks;
     68 	uint64_t	bfree;
     69 	uint64_t	bavail;
     70 	uint64_t	files;
     71 	uint64_t	ffree;
     72 	uint32_t	bsize;
     73 	uint32_t	namelen;
     74 	uint32_t	frsize;
     75 	uint32_t	padding;
     76 	uint32_t	spare[6];
     77 };
     78 
     79 struct fuse_file_lock {
     80 	uint64_t	start;
     81 	uint64_t	end;
     82 	uint32_t	type;
     83 	uint32_t	pid;
     84 };
     85 
     86 /*
     87  * Various flags
     88  */
     89 #define FUSE_FATTR_MODE		0x0001
     90 #define FUSE_FATTR_UID		0x0002
     91 #define FUSE_FATTR_GID		0x0004
     92 #define FUSE_FATTR_SIZE		0x0008
     93 #define FUSE_FATTR_ATIME	0x0010
     94 #define FUSE_FATTR_MTIME	0x0020
     95 #define FUSE_FATTR_FH		0x0040
     96 #define FUSE_FATTR_ATIME_NOW	0x0080
     97 #define FUSE_FATTR_MTIME_NOW	0x0100
     98 #define FUSE_FATTR_LOCKOWNER	0x0200
     99 
    100 #define FUSE_FOPEN_DIRECT_IO	0x0001
    101 #define FUSE_FOPEN_KEEP_CACHE	0x0002
    102 #define FUSE_FOPEN_NONSEEKABLE	0x0004
    103 
    104 #define FUSE_ASYNC_READ		0x0001
    105 #define FUSE_POSIX_LOCKS	0x0002
    106 #define FUSE_FILE_OPS		0x0004
    107 #define FUSE_ATOMIC_O_TRUNC	0x0008
    108 #define FUSE_EXPORT_SUPPORT	0x0010
    109 #define FUSE_BIG_WRITES		0x0020
    110 #define FUSE_DONT_MASK		0x0040
    111 
    112 #define FUSE_CUSE_UNRESTRICTED_IOCTL	0x0001
    113 
    114 #define FUSE_RELEASE_FLUSH	0x0001
    115 
    116 #define FUSE_GETATTR_FH		0x0001
    117 
    118 #define FUSE_LK_FLOCK		0x0001
    119 
    120 #define FUSE_WRITE_CACHE	0x0001
    121 #define FUSE_WRITE_LOCKOWNER	0x0002
    122 
    123 #define FUSE_READ_LOCKOWNER	0x0002
    124 
    125 #define FUSE_IOCTL_COMPAT	0x0001
    126 #define FUSE_IOCTL_UNRESTRICTED	0x0002
    127 #define FUSE_IOCTL_RETRY	0x0004
    128 
    129 #define FUSE_IOCTL_MAX_IOV	256
    130 
    131 #define FUSE_POLL_SCHEDULE_NOTIFY 0x0001
    132 
    133 enum fuse_opcode {
    134 	FUSE_LOOKUP	   = 1,
    135 	FUSE_FORGET	   = 2,
    136 	FUSE_GETATTR	   = 3,
    137 	FUSE_SETATTR	   = 4,
    138 	FUSE_READLINK	   = 5,
    139 	FUSE_SYMLINK	   = 6,
    140 	FUSE_MKNOD	   = 8,
    141 	FUSE_MKDIR	   = 9,
    142 	FUSE_UNLINK	   = 10,
    143 	FUSE_RMDIR	   = 11,
    144 	FUSE_RENAME	   = 12,
    145 	FUSE_LINK	   = 13,
    146 	FUSE_OPEN	   = 14,
    147 	FUSE_READ	   = 15,
    148 	FUSE_WRITE	   = 16,
    149 	FUSE_STATFS	   = 17,
    150 	FUSE_RELEASE       = 18,
    151 	FUSE_FSYNC         = 20,
    152 	FUSE_SETXATTR      = 21,
    153 	FUSE_GETXATTR      = 22,
    154 	FUSE_LISTXATTR     = 23,
    155 	FUSE_REMOVEXATTR   = 24,
    156 	FUSE_FLUSH         = 25,
    157 	FUSE_INIT          = 26,
    158 	FUSE_OPENDIR       = 27,
    159 	FUSE_READDIR       = 28,
    160 	FUSE_RELEASEDIR    = 29,
    161 	FUSE_FSYNCDIR      = 30,
    162 	FUSE_GETLK         = 31,
    163 	FUSE_SETLK         = 32,
    164 	FUSE_SETLKW        = 33,
    165 	FUSE_ACCESS        = 34,
    166 	FUSE_CREATE        = 35,
    167 	FUSE_INTERRUPT     = 36,
    168 	FUSE_BMAP          = 37,
    169 	FUSE_DESTROY       = 38,
    170 	FUSE_IOCTL         = 39,
    171 	FUSE_POLL          = 40,
    172 
    173 	FUSE_CUSE_INIT     = 4096
    174 };
    175 
    176 enum fuse_notify_code {
    177 	FUSE_NOTIFY_POLL   = 1,
    178 	FUSE_NOTIFY_INVAL_INODE = 2,
    179 	FUSE_NOTIFY_INVAL_ENTRY = 3,
    180 	FUSE_NOTIFY_CODE_MAX
    181 };
    182 
    183 #define FUSE_MIN_READ_BUFFER 8192
    184 
    185 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
    186 
    187 struct fuse_entry_out {
    188 	uint64_t	nodeid;
    189 	uint64_t	generation;
    190 	uint64_t	entry_valid;
    191 	uint64_t	attr_valid;
    192 	uint32_t	entry_valid_nsec;
    193 	uint32_t	attr_valid_nsec;
    194 	struct fuse_attr attr;
    195 };
    196 
    197 struct fuse_forget_in {
    198 	uint64_t	nlookup;
    199 };
    200 
    201 struct fuse_getattr_in {
    202 	uint32_t	getattr_flags;
    203 	uint32_t	dummy;
    204 	uint64_t	fh;
    205 };
    206 
    207 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
    208 
    209 struct fuse_attr_out {
    210 	uint64_t	attr_valid;
    211 	uint32_t	attr_valid_nsec;
    212 	uint32_t	dummy;
    213 	struct fuse_attr attr;
    214 };
    215 
    216 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
    217 
    218 struct fuse_mknod_in {
    219 	uint32_t	mode;
    220 	uint32_t	rdev;
    221 	uint32_t	umask;
    222 	uint32_t	padding;
    223 };
    224 
    225 struct fuse_mkdir_in {
    226 	uint32_t	mode;
    227 	uint32_t	umask;
    228 };
    229 
    230 struct fuse_rename_in {
    231 	uint64_t	newdir;
    232 };
    233 
    234 struct fuse_link_in {
    235 	uint64_t	oldnodeid;
    236 };
    237 
    238 struct fuse_setattr_in {
    239 	uint32_t	valid;
    240 	uint32_t	padding;
    241 	uint64_t	fh;
    242 	uint64_t	size;
    243 	uint64_t	lock_owner;
    244 	uint64_t	atime;
    245 	uint64_t	mtime;
    246 	uint64_t	unused2;
    247 	uint32_t	atimensec;
    248 	uint32_t	mtimensec;
    249 	uint32_t	unused3;
    250 	uint32_t	mode;
    251 	uint32_t	unused4;
    252 	uint32_t	uid;
    253 	uint32_t	gid;
    254 	uint32_t	unused5;
    255 };
    256 
    257 struct fuse_open_in {
    258 	uint32_t	flags;
    259 	uint32_t	unused;
    260 };
    261 
    262 struct fuse_create_in {
    263 	uint32_t	flags;
    264 	uint32_t	mode;
    265 	uint32_t	umask;
    266 	uint32_t	padding;
    267 };
    268 
    269 struct fuse_open_out {
    270 	uint64_t	fh;
    271 	uint32_t	open_flags; /* FUSE_FOPEN_ */
    272 	uint32_t	padding;
    273 };
    274 
    275 struct fuse_release_in {
    276 	uint64_t	fh;
    277 	uint32_t	flags;
    278 	uint32_t	release_flags;
    279 	uint64_t	lock_owner;
    280 };
    281 
    282 struct fuse_flush_in {
    283 	uint64_t	fh;
    284 	uint32_t	unused;
    285 	uint32_t	padding;
    286 	uint64_t	lock_owner;
    287 };
    288 
    289 struct fuse_read_in {
    290 	uint64_t	fh;
    291 	uint64_t	offset;
    292 	uint32_t	size;
    293 	uint32_t	read_flags;
    294 	uint64_t	lock_owner;
    295 	uint32_t	flags;
    296 	uint32_t	padding;
    297 };
    298 
    299 #define FUSE_COMPAT_WRITE_IN_SIZE 24
    300 
    301 struct fuse_write_in {
    302 	uint64_t	fh;
    303 	uint64_t	offset;
    304 	uint32_t	size;
    305 	uint32_t	write_flags;
    306 	uint64_t	lock_owner;
    307 	uint32_t	flags;
    308 	uint32_t	padding;
    309 };
    310 
    311 struct fuse_write_out {
    312 	uint32_t	size;
    313 	uint32_t	padding;
    314 };
    315 
    316 #define FUSE_COMPAT_STATFS_SIZE 48
    317 
    318 struct fuse_statfs_out {
    319 	struct fuse_kstatfs st;
    320 };
    321 
    322 struct fuse_fsync_in {
    323 	uint64_t	fh;
    324 	uint32_t	fsync_flags;
    325 	uint32_t	padding;
    326 };
    327 
    328 struct fuse_setxattr_in {
    329 	uint32_t	size;
    330 	uint32_t	flags;
    331 };
    332 
    333 struct fuse_getxattr_in {
    334 	uint32_t	size;
    335 	uint32_t	padding;
    336 };
    337 
    338 struct fuse_getxattr_out {
    339 	uint32_t	size;
    340 	uint32_t	padding;
    341 };
    342 
    343 struct fuse_lk_in {
    344 	uint64_t	fh;
    345 	uint64_t	owner;
    346 	struct fuse_file_lock lk;
    347 	uint32_t	lk_flags;
    348 	uint32_t	padding;
    349 };
    350 
    351 struct fuse_lk_out {
    352 	struct fuse_file_lock lk;
    353 };
    354 
    355 struct fuse_access_in {
    356 	uint32_t	mask;
    357 	uint32_t	padding;
    358 };
    359 
    360 struct fuse_init_in {
    361 	uint32_t	major;
    362 	uint32_t	minor;
    363 	uint32_t	max_readahead;
    364 	uint32_t	flags;
    365 };
    366 
    367 struct fuse_init_out {
    368 	uint32_t	major;
    369 	uint32_t	minor;
    370 	uint32_t	max_readahead;
    371 	uint32_t	flags;
    372 	uint32_t	unused;
    373 	uint32_t	max_write;
    374 };
    375 
    376 #define FUSE_CUSE_INIT_INFO_MAX 4096
    377 
    378 struct fuse_cuse_init_in {
    379 	uint32_t	major;
    380 	uint32_t	minor;
    381 	uint32_t	unused;
    382 	uint32_t	flags;
    383 };
    384 
    385 struct fuse_cuse_init_out {
    386 	uint32_t	major;
    387 	uint32_t	minor;
    388 	uint32_t	unused;
    389 	uint32_t	flags;
    390 	uint32_t	max_read;
    391 	uint32_t	max_write;
    392 	uint32_t	dev_major;		/* chardev major */
    393 	uint32_t	dev_minor;		/* chardev minor */
    394 	uint32_t	spare[10];
    395 };
    396 
    397 struct fuse_interrupt_in {
    398 	uint64_t	unique;
    399 };
    400 
    401 struct fuse_bmap_in {
    402 	uint64_t	block;
    403 	uint32_t	blocksize;
    404 	uint32_t	padding;
    405 };
    406 
    407 struct fuse_bmap_out {
    408 	uint64_t	block;
    409 };
    410 
    411 struct fuse_ioctl_in {
    412 	uint64_t	fh;
    413 	uint32_t	flags;
    414 	uint32_t	cmd;
    415 	uint64_t	arg;
    416 	uint32_t	in_size;
    417 	uint32_t	out_size;
    418 };
    419 
    420 struct fuse_ioctl_out {
    421 	int32_t	result;
    422 	uint32_t	flags;
    423 	uint32_t	in_iovs;
    424 	uint32_t	out_iovs;
    425 };
    426 
    427 struct fuse_poll_in {
    428 	uint64_t	fh;
    429 	uint64_t	kh;
    430 	uint32_t	flags;
    431 	uint32_t   padding;
    432 };
    433 
    434 struct fuse_poll_out {
    435 	uint32_t	revents;
    436 	uint32_t	padding;
    437 };
    438 
    439 struct fuse_notify_poll_wakeup_out {
    440 	uint64_t	kh;
    441 };
    442 
    443 #if 0 /* Duplicated in perfuse.h to avoid making fuse.h public */
    444 /* Send from kernel to proces */
    445 struct fuse_in_header {
    446 	uint32_t	len;
    447 	uint32_t	opcode;
    448 	uint64_t	unique;
    449 	uint64_t	nodeid;
    450 	uint32_t	uid;
    451 	uint32_t	gid;
    452 	uint32_t	pid;
    453 	uint32_t	padding;
    454 };
    455 
    456 struct fuse_in_arg {
    457 	uint32_t	size;
    458 	const void *value;
    459 };
    460 
    461 struct fuse_in {
    462 	struct 		fuse_in_header h;
    463 	uint32_t	argpages:1;	/* Req fits in a page? Always 1 */
    464 	uint32_t	numargs;
    465 	struct fuse_in_arg args[3];	/* args copied to userspace */
    466 };
    467 
    468 
    469 /* From process to kernel */
    470 struct fuse_out_header {
    471 	uint32_t	len;
    472 	int32_t	error;
    473 	uint64_t	unique;
    474 };
    475 #endif
    476 
    477 struct fuse_dirent {
    478 	uint64_t	ino;
    479 	uint64_t	off;	/* offset of next field from after foh */
    480 	uint32_t	namelen;
    481 	uint32_t	type;
    482 	char name[0];
    483 };
    484 
    485 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
    486 #define FUSE_DIRENT_ALIGN(x) \
    487 	(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
    488 #define FUSE_DIRENT_SIZE(d) \
    489 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
    490 
    491 struct fuse_notify_inval_inode_out {
    492 	uint64_t	ino;
    493 	int64_t	off;
    494 	int64_t	len;
    495 };
    496 
    497 struct fuse_notify_inval_entry_out {
    498 	uint64_t	parent;
    499 	uint32_t	namelen;
    500 	uint32_t	padding;
    501 };
    502 
    503 #endif /* _FUSE_H */
    504