bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | This file defines the kernel interface of FUSE |
| 3 | Copyright (C) 2001-2008 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 | |
| 35 | /* |
| 36 | * This file defines the kernel interface of FUSE |
| 37 | * |
| 38 | * Protocol changelog: |
| 39 | * |
| 40 | * 7.9: |
| 41 | * - new fuse_getattr_in input argument of GETATTR |
| 42 | * - add lk_flags in fuse_lk_in |
| 43 | * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in |
| 44 | * - add blksize field to fuse_attr |
| 45 | * - add file flags field to fuse_read_in and fuse_write_in |
| 46 | * |
| 47 | * 7.10 |
| 48 | * - add nonseekable open flag |
| 49 | * |
| 50 | * 7.11 |
| 51 | * - add IOCTL message |
| 52 | * - add unsolicited notification support |
| 53 | * - add POLL message and NOTIFY_POLL notification |
| 54 | * |
| 55 | * 7.12 |
| 56 | * - add umask flag to input argument of open, mknod and mkdir |
| 57 | * - add notification messages for invalidation of inodes and |
| 58 | * directory entries |
| 59 | */ |
| 60 | |
| 61 | #ifndef _LINUX_FUSE_H |
| 62 | #define _LINUX_FUSE_H |
| 63 | |
| 64 | #include <sys/types.h> |
| 65 | #define __u64 uint64_t |
| 66 | #define __s64 int64_t |
| 67 | #define __u32 uint32_t |
| 68 | #define __s32 int32_t |
| 69 | |
| 70 | /* |
| 71 | * Version negotiation: |
| 72 | * |
| 73 | * Both the kernel and userspace send the version they support in the |
| 74 | * INIT request and reply respectively. |
| 75 | * |
| 76 | * If the major versions match then both shall use the smallest |
| 77 | * of the two minor versions for communication. |
| 78 | * |
| 79 | * If the kernel supports a larger major version, then userspace shall |
| 80 | * reply with the major version it supports, ignore the rest of the |
| 81 | * INIT message and expect a new INIT message from the kernel with a |
| 82 | * matching major version. |
| 83 | * |
| 84 | * If the library supports a larger major version, then it shall fall |
| 85 | * back to the major protocol version sent by the kernel for |
| 86 | * communication and reply with that major version (and an arbitrary |
| 87 | * supported minor version). |
| 88 | */ |
| 89 | |
| 90 | /** Version number of this interface */ |
| 91 | #define FUSE_KERNEL_VERSION 7 |
| 92 | |
| 93 | /** Minor version number of this interface */ |
| 94 | #define FUSE_KERNEL_MINOR_VERSION 12 |
| 95 | |
| 96 | /** The node ID of the root inode */ |
| 97 | #define FUSE_ROOT_ID 1 |
| 98 | |
| 99 | /* Make sure all structures are padded to 64bit boundary, so 32bit |
| 100 | userspace works under 64bit kernels */ |
| 101 | |
| 102 | struct fuse_attr { |
| 103 | __u64 ino; |
| 104 | __u64 size; |
| 105 | __u64 blocks; |
| 106 | __u64 atime; |
| 107 | __u64 mtime; |
| 108 | __u64 ctime; |
| 109 | __u32 atimensec; |
| 110 | __u32 mtimensec; |
| 111 | __u32 ctimensec; |
| 112 | __u32 mode; |
| 113 | __u32 nlink; |
| 114 | __u32 uid; |
| 115 | __u32 gid; |
| 116 | __u32 rdev; |
| 117 | __u32 blksize; |
| 118 | __u32 padding; |
| 119 | }; |
| 120 | |
| 121 | struct fuse_kstatfs { |
| 122 | __u64 blocks; |
| 123 | __u64 bfree; |
| 124 | __u64 bavail; |
| 125 | __u64 files; |
| 126 | __u64 ffree; |
| 127 | __u32 bsize; |
| 128 | __u32 namelen; |
| 129 | __u32 frsize; |
| 130 | __u32 padding; |
| 131 | __u32 spare[6]; |
| 132 | }; |
| 133 | |
| 134 | struct fuse_file_lock { |
| 135 | __u64 start; |
| 136 | __u64 end; |
| 137 | __u32 type; |
| 138 | __u32 pid; /* tgid */ |
| 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * Bitmasks for fuse_setattr_in.valid |
| 143 | */ |
| 144 | #define FATTR_MODE (1 << 0) |
| 145 | #define FATTR_UID (1 << 1) |
| 146 | #define FATTR_GID (1 << 2) |
| 147 | #define FATTR_SIZE (1 << 3) |
| 148 | #define FATTR_ATIME (1 << 4) |
| 149 | #define FATTR_MTIME (1 << 5) |
| 150 | #define FATTR_FH (1 << 6) |
| 151 | #define FATTR_ATIME_NOW (1 << 7) |
| 152 | #define FATTR_MTIME_NOW (1 << 8) |
| 153 | #define FATTR_LOCKOWNER (1 << 9) |
| 154 | |
| 155 | /** |
| 156 | * Flags returned by the OPEN request |
| 157 | * |
| 158 | * FOPEN_DIRECT_IO: bypass page cache for this open file |
| 159 | * FOPEN_KEEP_CACHE: don't invalidate the data cache on open |
| 160 | * FOPEN_NONSEEKABLE: the file is not seekable |
| 161 | */ |
| 162 | #define FOPEN_DIRECT_IO (1 << 0) |
| 163 | #define FOPEN_KEEP_CACHE (1 << 1) |
| 164 | #define FOPEN_NONSEEKABLE (1 << 2) |
| 165 | |
| 166 | /** |
| 167 | * INIT request/reply flags |
| 168 | * |
| 169 | * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." |
| 170 | * FUSE_DONT_MASK: don't apply umask to file mode on create operations |
| 171 | */ |
| 172 | #define FUSE_ASYNC_READ (1 << 0) |
| 173 | #define FUSE_POSIX_LOCKS (1 << 1) |
| 174 | #define FUSE_FILE_OPS (1 << 2) |
| 175 | #define FUSE_ATOMIC_O_TRUNC (1 << 3) |
| 176 | #define FUSE_EXPORT_SUPPORT (1 << 4) |
| 177 | #define FUSE_BIG_WRITES (1 << 5) |
| 178 | #define FUSE_DONT_MASK (1 << 6) |
| 179 | |
| 180 | /** |
| 181 | * CUSE INIT request/reply flags |
| 182 | * |
| 183 | * CUSE_UNRESTRICTED_IOCTL: use unrestricted ioctl |
| 184 | */ |
| 185 | #define CUSE_UNRESTRICTED_IOCTL (1 << 0) |
| 186 | |
| 187 | /** |
| 188 | * Release flags |
| 189 | */ |
| 190 | #define FUSE_RELEASE_FLUSH (1 << 0) |
| 191 | |
| 192 | /** |
| 193 | * Getattr flags |
| 194 | */ |
| 195 | #define FUSE_GETATTR_FH (1 << 0) |
| 196 | |
| 197 | /** |
| 198 | * Lock flags |
| 199 | */ |
| 200 | #define FUSE_LK_FLOCK (1 << 0) |
| 201 | |
| 202 | /** |
| 203 | * WRITE flags |
| 204 | * |
| 205 | * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed |
| 206 | * FUSE_WRITE_LOCKOWNER: lock_owner field is valid |
| 207 | */ |
| 208 | #define FUSE_WRITE_CACHE (1 << 0) |
| 209 | #define FUSE_WRITE_LOCKOWNER (1 << 1) |
| 210 | |
| 211 | /** |
| 212 | * Read flags |
| 213 | */ |
| 214 | #define FUSE_READ_LOCKOWNER (1 << 1) |
| 215 | |
| 216 | /** |
| 217 | * Ioctl flags |
| 218 | * |
| 219 | * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine |
| 220 | * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed |
| 221 | * FUSE_IOCTL_RETRY: retry with new iovecs |
| 222 | * |
| 223 | * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs |
| 224 | */ |
| 225 | #define FUSE_IOCTL_COMPAT (1 << 0) |
| 226 | #define FUSE_IOCTL_UNRESTRICTED (1 << 1) |
| 227 | #define FUSE_IOCTL_RETRY (1 << 2) |
| 228 | |
| 229 | #define FUSE_IOCTL_MAX_IOV 256 |
| 230 | |
| 231 | /** |
| 232 | * Poll flags |
| 233 | * |
| 234 | * FUSE_POLL_SCHEDULE_NOTIFY: request poll notify |
| 235 | */ |
| 236 | #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) |
| 237 | |
| 238 | enum fuse_opcode { |
| 239 | FUSE_LOOKUP = 1, |
| 240 | FUSE_FORGET = 2, /* no reply */ |
| 241 | FUSE_GETATTR = 3, |
| 242 | FUSE_SETATTR = 4, |
| 243 | FUSE_READLINK = 5, |
| 244 | FUSE_SYMLINK = 6, |
| 245 | FUSE_MKNOD = 8, |
| 246 | FUSE_MKDIR = 9, |
| 247 | FUSE_UNLINK = 10, |
| 248 | FUSE_RMDIR = 11, |
| 249 | FUSE_RENAME = 12, |
| 250 | FUSE_LINK = 13, |
| 251 | FUSE_OPEN = 14, |
| 252 | FUSE_READ = 15, |
| 253 | FUSE_WRITE = 16, |
| 254 | FUSE_STATFS = 17, |
| 255 | FUSE_RELEASE = 18, |
| 256 | FUSE_FSYNC = 20, |
| 257 | FUSE_SETXATTR = 21, |
| 258 | FUSE_GETXATTR = 22, |
| 259 | FUSE_LISTXATTR = 23, |
| 260 | FUSE_REMOVEXATTR = 24, |
| 261 | FUSE_FLUSH = 25, |
| 262 | FUSE_INIT = 26, |
| 263 | FUSE_OPENDIR = 27, |
| 264 | FUSE_READDIR = 28, |
| 265 | FUSE_RELEASEDIR = 29, |
| 266 | FUSE_FSYNCDIR = 30, |
| 267 | FUSE_GETLK = 31, |
| 268 | FUSE_SETLK = 32, |
| 269 | FUSE_SETLKW = 33, |
| 270 | FUSE_ACCESS = 34, |
| 271 | FUSE_CREATE = 35, |
| 272 | FUSE_INTERRUPT = 36, |
| 273 | FUSE_BMAP = 37, |
| 274 | FUSE_DESTROY = 38, |
| 275 | FUSE_IOCTL = 39, |
| 276 | FUSE_POLL = 40, |
| 277 | |
| 278 | /* CUSE specific operations */ |
| 279 | CUSE_INIT = 4096, |
| 280 | }; |
| 281 | |
| 282 | enum fuse_notify_code { |
| 283 | FUSE_NOTIFY_POLL = 1, |
| 284 | FUSE_NOTIFY_INVAL_INODE = 2, |
| 285 | FUSE_NOTIFY_INVAL_ENTRY = 3, |
| 286 | FUSE_NOTIFY_CODE_MAX, |
| 287 | }; |
| 288 | |
| 289 | /* The read buffer is required to be at least 8k, but may be much larger */ |
| 290 | #define FUSE_MIN_READ_BUFFER 8192 |
| 291 | |
| 292 | #define FUSE_COMPAT_ENTRY_OUT_SIZE 120 |
| 293 | |
| 294 | struct fuse_entry_out { |
| 295 | __u64 nodeid; /* Inode ID */ |
| 296 | __u64 generation; /* Inode generation: nodeid:gen must |
| 297 | be unique for the fs's lifetime */ |
| 298 | __u64 entry_valid; /* Cache timeout for the name */ |
| 299 | __u64 attr_valid; /* Cache timeout for the attributes */ |
| 300 | __u32 entry_valid_nsec; |
| 301 | __u32 attr_valid_nsec; |
| 302 | struct fuse_attr attr; |
| 303 | }; |
| 304 | |
| 305 | struct fuse_forget_in { |
| 306 | __u64 nlookup; |
| 307 | }; |
| 308 | |
| 309 | struct fuse_getattr_in { |
| 310 | __u32 getattr_flags; |
| 311 | __u32 dummy; |
| 312 | __u64 fh; |
| 313 | }; |
| 314 | |
| 315 | #define FUSE_COMPAT_ATTR_OUT_SIZE 96 |
| 316 | |
| 317 | struct fuse_attr_out { |
| 318 | __u64 attr_valid; /* Cache timeout for the attributes */ |
| 319 | __u32 attr_valid_nsec; |
| 320 | __u32 dummy; |
| 321 | struct fuse_attr attr; |
| 322 | }; |
| 323 | |
| 324 | #define FUSE_COMPAT_MKNOD_IN_SIZE 8 |
| 325 | |
| 326 | struct fuse_mknod_in { |
| 327 | __u32 mode; |
| 328 | __u32 rdev; |
| 329 | __u32 umask; |
| 330 | __u32 padding; |
| 331 | }; |
| 332 | |
| 333 | struct fuse_mkdir_in { |
| 334 | __u32 mode; |
| 335 | __u32 umask; |
| 336 | }; |
| 337 | |
| 338 | struct fuse_rename_in { |
| 339 | __u64 newdir; |
| 340 | }; |
| 341 | |
| 342 | struct fuse_link_in { |
| 343 | __u64 oldnodeid; |
| 344 | }; |
| 345 | |
| 346 | struct fuse_setattr_in { |
| 347 | __u32 valid; |
| 348 | __u32 padding; |
| 349 | __u64 fh; |
| 350 | __u64 size; |
| 351 | __u64 lock_owner; |
| 352 | __u64 atime; |
| 353 | __u64 mtime; |
| 354 | __u64 unused2; |
| 355 | __u32 atimensec; |
| 356 | __u32 mtimensec; |
| 357 | __u32 unused3; |
| 358 | __u32 mode; |
| 359 | __u32 unused4; |
| 360 | __u32 uid; |
| 361 | __u32 gid; |
| 362 | __u32 unused5; |
| 363 | }; |
| 364 | |
| 365 | struct fuse_open_in { |
| 366 | __u32 flags; |
| 367 | __u32 unused; |
| 368 | }; |
| 369 | |
| 370 | struct fuse_create_in { |
| 371 | __u32 flags; |
| 372 | __u32 mode; |
| 373 | __u32 umask; |
| 374 | __u32 padding; |
| 375 | }; |
| 376 | |
| 377 | struct fuse_open_out { |
| 378 | __u64 fh; |
| 379 | __u32 open_flags; |
| 380 | __u32 padding; |
| 381 | }; |
| 382 | |
| 383 | struct fuse_release_in { |
| 384 | __u64 fh; |
| 385 | __u32 flags; |
| 386 | __u32 release_flags; |
| 387 | __u64 lock_owner; |
| 388 | }; |
| 389 | |
| 390 | struct fuse_flush_in { |
| 391 | __u64 fh; |
| 392 | __u32 unused; |
| 393 | __u32 padding; |
| 394 | __u64 lock_owner; |
| 395 | }; |
| 396 | |
| 397 | struct fuse_read_in { |
| 398 | __u64 fh; |
| 399 | __u64 offset; |
| 400 | __u32 size; |
| 401 | __u32 read_flags; |
| 402 | __u64 lock_owner; |
| 403 | __u32 flags; |
| 404 | __u32 padding; |
| 405 | }; |
| 406 | |
| 407 | #define FUSE_COMPAT_WRITE_IN_SIZE 24 |
| 408 | |
| 409 | struct fuse_write_in { |
| 410 | __u64 fh; |
| 411 | __u64 offset; |
| 412 | __u32 size; |
| 413 | __u32 write_flags; |
| 414 | __u64 lock_owner; |
| 415 | __u32 flags; |
| 416 | __u32 padding; |
| 417 | }; |
| 418 | |
| 419 | struct fuse_write_out { |
| 420 | __u32 size; |
| 421 | __u32 padding; |
| 422 | }; |
| 423 | |
| 424 | #define FUSE_COMPAT_STATFS_SIZE 48 |
| 425 | |
| 426 | struct fuse_statfs_out { |
| 427 | struct fuse_kstatfs st; |
| 428 | }; |
| 429 | |
| 430 | struct fuse_fsync_in { |
| 431 | __u64 fh; |
| 432 | __u32 fsync_flags; |
| 433 | __u32 padding; |
| 434 | }; |
| 435 | |
| 436 | struct fuse_setxattr_in { |
| 437 | __u32 size; |
| 438 | __u32 flags; |
| 439 | }; |
| 440 | |
| 441 | struct fuse_getxattr_in { |
| 442 | __u32 size; |
| 443 | __u32 padding; |
| 444 | }; |
| 445 | |
| 446 | struct fuse_getxattr_out { |
| 447 | __u32 size; |
| 448 | __u32 padding; |
| 449 | }; |
| 450 | |
| 451 | struct fuse_lk_in { |
| 452 | __u64 fh; |
| 453 | __u64 owner; |
| 454 | struct fuse_file_lock lk; |
| 455 | __u32 lk_flags; |
| 456 | __u32 padding; |
| 457 | }; |
| 458 | |
| 459 | struct fuse_lk_out { |
| 460 | struct fuse_file_lock lk; |
| 461 | }; |
| 462 | |
| 463 | struct fuse_access_in { |
| 464 | __u32 mask; |
| 465 | __u32 padding; |
| 466 | }; |
| 467 | |
| 468 | struct fuse_init_in { |
| 469 | __u32 major; |
| 470 | __u32 minor; |
| 471 | __u32 max_readahead; |
| 472 | __u32 flags; |
| 473 | }; |
| 474 | |
| 475 | struct fuse_init_out { |
| 476 | __u32 major; |
| 477 | __u32 minor; |
| 478 | __u32 max_readahead; |
| 479 | __u32 flags; |
| 480 | __u32 unused; |
| 481 | __u32 max_write; |
| 482 | }; |
| 483 | |
| 484 | #define CUSE_INIT_INFO_MAX 4096 |
| 485 | |
| 486 | struct cuse_init_in { |
| 487 | __u32 major; |
| 488 | __u32 minor; |
| 489 | __u32 unused; |
| 490 | __u32 flags; |
| 491 | }; |
| 492 | |
| 493 | struct cuse_init_out { |
| 494 | __u32 major; |
| 495 | __u32 minor; |
| 496 | __u32 unused; |
| 497 | __u32 flags; |
| 498 | __u32 max_read; |
| 499 | __u32 max_write; |
| 500 | __u32 dev_major; /* chardev major */ |
| 501 | __u32 dev_minor; /* chardev minor */ |
| 502 | __u32 spare[10]; |
| 503 | }; |
| 504 | |
| 505 | struct fuse_interrupt_in { |
| 506 | __u64 unique; |
| 507 | }; |
| 508 | |
| 509 | struct fuse_bmap_in { |
| 510 | __u64 block; |
| 511 | __u32 blocksize; |
| 512 | __u32 padding; |
| 513 | }; |
| 514 | |
| 515 | struct fuse_bmap_out { |
| 516 | __u64 block; |
| 517 | }; |
| 518 | |
| 519 | struct fuse_ioctl_in { |
| 520 | __u64 fh; |
| 521 | __u32 flags; |
| 522 | __u32 cmd; |
| 523 | __u64 arg; |
| 524 | __u32 in_size; |
| 525 | __u32 out_size; |
| 526 | }; |
| 527 | |
| 528 | struct fuse_ioctl_out { |
| 529 | __s32 result; |
| 530 | __u32 flags; |
| 531 | __u32 in_iovs; |
| 532 | __u32 out_iovs; |
| 533 | }; |
| 534 | |
| 535 | struct fuse_poll_in { |
| 536 | __u64 fh; |
| 537 | __u64 kh; |
| 538 | __u32 flags; |
| 539 | __u32 padding; |
| 540 | }; |
| 541 | |
| 542 | struct fuse_poll_out { |
| 543 | __u32 revents; |
| 544 | __u32 padding; |
| 545 | }; |
| 546 | |
| 547 | struct fuse_notify_poll_wakeup_out { |
| 548 | __u64 kh; |
| 549 | }; |
| 550 | |
| 551 | struct fuse_in_header { |
| 552 | __u32 len; |
| 553 | __u32 opcode; |
| 554 | __u64 unique; |
| 555 | __u64 nodeid; |
| 556 | __u32 uid; |
| 557 | __u32 gid; |
| 558 | __u32 pid; |
| 559 | __u32 padding; |
| 560 | }; |
| 561 | |
| 562 | struct fuse_out_header { |
| 563 | __u32 len; |
| 564 | __s32 error; |
| 565 | __u64 unique; |
| 566 | }; |
| 567 | |
| 568 | struct fuse_dirent { |
| 569 | __u64 ino; |
| 570 | __u64 off; |
| 571 | __u32 namelen; |
| 572 | __u32 type; |
| 573 | char name[0]; |
| 574 | }; |
| 575 | |
| 576 | #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) |
| 577 | #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) |
| 578 | #define FUSE_DIRENT_SIZE(d) \ |
| 579 | FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) |
| 580 | |
| 581 | struct fuse_notify_inval_inode_out { |
| 582 | __u64 ino; |
| 583 | __s64 off; |
| 584 | __s64 len; |
| 585 | }; |
| 586 | |
| 587 | struct fuse_notify_inval_entry_out { |
| 588 | __u64 parent; |
| 589 | __u32 namelen; |
| 590 | __u32 padding; |
| 591 | }; |
| 592 | |
| 593 | #endif /* _LINUX_FUSE_H */ |