bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | FUSE: Filesystem in Userspace |
| 3 | Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> |
| 4 | |
| 5 | This program can be distributed under the terms of the GNU LGPLv2. |
| 6 | See the file COPYING.LIB. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _FUSE_H_ |
| 10 | #define _FUSE_H_ |
| 11 | |
| 12 | /** @file |
| 13 | * |
| 14 | * This file defines the library interface of FUSE |
| 15 | * |
| 16 | * IMPORTANT: you should define FUSE_USE_VERSION before including this |
| 17 | * header. To use the newest API define it to 26 (recommended for any |
| 18 | * new application), to use the old API define it to 21 (default) 22 |
| 19 | * or 25, to use the even older 1.X API define it to 11. |
| 20 | */ |
| 21 | |
| 22 | #ifndef FUSE_USE_VERSION |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 23 | #define FUSE_USE_VERSION 21 |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 24 | #endif |
| 25 | |
| 26 | #include "fuse_common.h" |
| 27 | |
| 28 | #include <fcntl.h> |
| 29 | #include <time.h> |
| 30 | #include <utime.h> |
| 31 | #include <sys/types.h> |
| 32 | #include <sys/stat.h> |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 33 | #if defined(__ANDROID__) |
| 34 | #include <pthread.h> |
| 35 | #endif |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 36 | #include <sys/statvfs.h> |
| 37 | #include <sys/uio.h> |
| 38 | |
| 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | |
| 43 | /* ----------------------------------------------------------- * |
| 44 | * Basic FUSE API * |
| 45 | * ----------------------------------------------------------- */ |
| 46 | |
| 47 | /** Handle for a FUSE filesystem */ |
| 48 | struct fuse; |
| 49 | |
| 50 | /** Structure containing a raw command */ |
| 51 | struct fuse_cmd; |
| 52 | |
| 53 | /** Function to add an entry in a readdir() operation |
| 54 | * |
| 55 | * @param buf the buffer passed to the readdir() operation |
| 56 | * @param name the file name of the directory entry |
| 57 | * @param stat file attributes, can be NULL |
| 58 | * @param off offset of the next entry or zero |
| 59 | * @return 1 if buffer is full, zero otherwise |
| 60 | */ |
| 61 | typedef int (*fuse_fill_dir_t) (void *buf, const char *name, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 62 | const struct stat *stbuf, loff_t off); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 63 | |
| 64 | /* Used by deprecated getdir() method */ |
| 65 | typedef struct fuse_dirhandle *fuse_dirh_t; |
| 66 | typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type, |
| 67 | ino_t ino); |
| 68 | |
| 69 | /** |
| 70 | * The file system operations: |
| 71 | * |
| 72 | * Most of these should work very similarly to the well known UNIX |
| 73 | * file system operations. A major exception is that instead of |
| 74 | * returning an error in 'errno', the operation should return the |
| 75 | * negated error value (-errno) directly. |
| 76 | * |
| 77 | * All methods are optional, but some are essential for a useful |
| 78 | * filesystem (e.g. getattr). Open, flush, release, fsync, opendir, |
| 79 | * releasedir, fsyncdir, access, create, ftruncate, fgetattr, lock, |
| 80 | * init and destroy are special purpose methods, without which a full |
| 81 | * featured filesystem can still be implemented. |
| 82 | * |
| 83 | * Almost all operations take a path which can be of any length. |
| 84 | * |
| 85 | * Changed in fuse 2.8.0 (regardless of API version) |
| 86 | * Previously, paths were limited to a length of PATH_MAX. |
| 87 | * |
| 88 | * See http://fuse.sourceforge.net/wiki/ for more information. There |
| 89 | * is also a snapshot of the relevant wiki pages in the doc/ folder. |
| 90 | */ |
| 91 | struct fuse_operations { |
| 92 | /** Get file attributes. |
| 93 | * |
| 94 | * Similar to stat(). The 'st_dev' and 'st_blksize' fields are |
| 95 | * ignored. The 'st_ino' field is ignored except if the 'use_ino' |
| 96 | * mount option is given. |
| 97 | */ |
| 98 | int (*getattr) (const char *, struct stat *); |
| 99 | |
| 100 | /** Read the target of a symbolic link |
| 101 | * |
| 102 | * The buffer should be filled with a null terminated string. The |
| 103 | * buffer size argument includes the space for the terminating |
| 104 | * null character. If the linkname is too long to fit in the |
| 105 | * buffer, it should be truncated. The return value should be 0 |
| 106 | * for success. |
| 107 | */ |
| 108 | int (*readlink) (const char *, char *, size_t); |
| 109 | |
| 110 | /* Deprecated, use readdir() instead */ |
| 111 | int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t); |
| 112 | |
| 113 | /** Create a file node |
| 114 | * |
| 115 | * This is called for creation of all non-directory, non-symlink |
| 116 | * nodes. If the filesystem defines a create() method, then for |
| 117 | * regular files that will be called instead. |
| 118 | */ |
| 119 | int (*mknod) (const char *, mode_t, dev_t); |
| 120 | |
| 121 | /** Create a directory |
| 122 | * |
| 123 | * Note that the mode argument may not have the type specification |
| 124 | * bits set, i.e. S_ISDIR(mode) can be false. To obtain the |
| 125 | * correct directory type bits use mode|S_IFDIR |
| 126 | * */ |
| 127 | int (*mkdir) (const char *, mode_t); |
| 128 | |
| 129 | /** Remove a file */ |
| 130 | int (*unlink) (const char *); |
| 131 | |
| 132 | /** Remove a directory */ |
| 133 | int (*rmdir) (const char *); |
| 134 | |
| 135 | /** Create a symbolic link */ |
| 136 | int (*symlink) (const char *, const char *); |
| 137 | |
| 138 | /** Rename a file */ |
| 139 | int (*rename) (const char *, const char *); |
| 140 | |
| 141 | /** Create a hard link to a file */ |
| 142 | int (*link) (const char *, const char *); |
| 143 | |
| 144 | /** Change the permission bits of a file */ |
| 145 | int (*chmod) (const char *, mode_t); |
| 146 | |
| 147 | /** Change the owner and group of a file */ |
| 148 | int (*chown) (const char *, uid_t, gid_t); |
| 149 | |
| 150 | /** Change the size of a file */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 151 | int (*truncate) (const char *, loff_t); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 152 | |
| 153 | /** Change the access and/or modification times of a file |
| 154 | * |
| 155 | * Deprecated, use utimens() instead. |
| 156 | */ |
| 157 | int (*utime) (const char *, struct utimbuf *); |
| 158 | |
| 159 | /** File open operation |
| 160 | * |
| 161 | * No creation (O_CREAT, O_EXCL) and by default also no |
| 162 | * truncation (O_TRUNC) flags will be passed to open(). If an |
| 163 | * application specifies O_TRUNC, fuse first calls truncate() |
| 164 | * and then open(). Only if 'atomic_o_trunc' has been |
| 165 | * specified and kernel version is 2.6.24 or later, O_TRUNC is |
| 166 | * passed on to open. |
| 167 | * |
| 168 | * Unless the 'default_permissions' mount option is given, |
| 169 | * open should check if the operation is permitted for the |
| 170 | * given flags. Optionally open may also return an arbitrary |
| 171 | * filehandle in the fuse_file_info structure, which will be |
| 172 | * passed to all file operations. |
| 173 | * |
| 174 | * Changed in version 2.2 |
| 175 | */ |
| 176 | int (*open) (const char *, struct fuse_file_info *); |
| 177 | |
| 178 | /** Read data from an open file |
| 179 | * |
| 180 | * Read should return exactly the number of bytes requested except |
| 181 | * on EOF or error, otherwise the rest of the data will be |
| 182 | * substituted with zeroes. An exception to this is when the |
| 183 | * 'direct_io' mount option is specified, in which case the return |
| 184 | * value of the read system call will reflect the return value of |
| 185 | * this operation. |
| 186 | * |
| 187 | * Changed in version 2.2 |
| 188 | */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 189 | int (*read) (const char *, char *, size_t, loff_t, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 190 | struct fuse_file_info *); |
| 191 | |
| 192 | /** Write data to an open file |
| 193 | * |
| 194 | * Write should return exactly the number of bytes requested |
| 195 | * except on error. An exception to this is when the 'direct_io' |
| 196 | * mount option is specified (see read operation). |
| 197 | * |
| 198 | * Changed in version 2.2 |
| 199 | */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 200 | int (*write) (const char *, const char *, size_t, loff_t, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 201 | struct fuse_file_info *); |
| 202 | |
| 203 | /** Get file system statistics |
| 204 | * |
| 205 | * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored |
| 206 | * |
| 207 | * Replaced 'struct statfs' parameter with 'struct statvfs' in |
| 208 | * version 2.5 |
| 209 | */ |
| 210 | int (*statfs) (const char *, struct statvfs *); |
| 211 | |
| 212 | /** Possibly flush cached data |
| 213 | * |
| 214 | * BIG NOTE: This is not equivalent to fsync(). It's not a |
| 215 | * request to sync dirty data. |
| 216 | * |
| 217 | * Flush is called on each close() of a file descriptor. So if a |
| 218 | * filesystem wants to return write errors in close() and the file |
| 219 | * has cached dirty data, this is a good place to write back data |
| 220 | * and return any errors. Since many applications ignore close() |
| 221 | * errors this is not always useful. |
| 222 | * |
| 223 | * NOTE: The flush() method may be called more than once for each |
| 224 | * open(). This happens if more than one file descriptor refers |
| 225 | * to an opened file due to dup(), dup2() or fork() calls. It is |
| 226 | * not possible to determine if a flush is final, so each flush |
| 227 | * should be treated equally. Multiple write-flush sequences are |
| 228 | * relatively rare, so this shouldn't be a problem. |
| 229 | * |
| 230 | * Filesystems shouldn't assume that flush will always be called |
| 231 | * after some writes, or that if will be called at all. |
| 232 | * |
| 233 | * Changed in version 2.2 |
| 234 | */ |
| 235 | int (*flush) (const char *, struct fuse_file_info *); |
| 236 | |
| 237 | /** Release an open file |
| 238 | * |
| 239 | * Release is called when there are no more references to an open |
| 240 | * file: all file descriptors are closed and all memory mappings |
| 241 | * are unmapped. |
| 242 | * |
| 243 | * For every open() call there will be exactly one release() call |
| 244 | * with the same flags and file descriptor. It is possible to |
| 245 | * have a file opened more than once, in which case only the last |
| 246 | * release will mean, that no more reads/writes will happen on the |
| 247 | * file. The return value of release is ignored. |
| 248 | * |
| 249 | * Changed in version 2.2 |
| 250 | */ |
| 251 | int (*release) (const char *, struct fuse_file_info *); |
| 252 | |
| 253 | /** Synchronize file contents |
| 254 | * |
| 255 | * If the datasync parameter is non-zero, then only the user data |
| 256 | * should be flushed, not the meta data. |
| 257 | * |
| 258 | * Changed in version 2.2 |
| 259 | */ |
| 260 | int (*fsync) (const char *, int, struct fuse_file_info *); |
| 261 | |
| 262 | /** Set extended attributes */ |
| 263 | int (*setxattr) (const char *, const char *, const char *, size_t, int); |
| 264 | |
| 265 | /** Get extended attributes */ |
| 266 | int (*getxattr) (const char *, const char *, char *, size_t); |
| 267 | |
| 268 | /** List extended attributes */ |
| 269 | int (*listxattr) (const char *, char *, size_t); |
| 270 | |
| 271 | /** Remove extended attributes */ |
| 272 | int (*removexattr) (const char *, const char *); |
| 273 | |
| 274 | /** Open directory |
| 275 | * |
| 276 | * Unless the 'default_permissions' mount option is given, |
| 277 | * this method should check if opendir is permitted for this |
| 278 | * directory. Optionally opendir may also return an arbitrary |
| 279 | * filehandle in the fuse_file_info structure, which will be |
| 280 | * passed to readdir, closedir and fsyncdir. |
| 281 | * |
| 282 | * Introduced in version 2.3 |
| 283 | */ |
| 284 | int (*opendir) (const char *, struct fuse_file_info *); |
| 285 | |
| 286 | /** Read directory |
| 287 | * |
| 288 | * This supersedes the old getdir() interface. New applications |
| 289 | * should use this. |
| 290 | * |
| 291 | * The filesystem may choose between two modes of operation: |
| 292 | * |
| 293 | * 1) The readdir implementation ignores the offset parameter, and |
| 294 | * passes zero to the filler function's offset. The filler |
| 295 | * function will not return '1' (unless an error happens), so the |
| 296 | * whole directory is read in a single readdir operation. This |
| 297 | * works just like the old getdir() method. |
| 298 | * |
| 299 | * 2) The readdir implementation keeps track of the offsets of the |
| 300 | * directory entries. It uses the offset parameter and always |
| 301 | * passes non-zero offset to the filler function. When the buffer |
| 302 | * is full (or an error happens) the filler function will return |
| 303 | * '1'. |
| 304 | * |
| 305 | * Introduced in version 2.3 |
| 306 | */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 307 | int (*readdir) (const char *, void *, fuse_fill_dir_t, loff_t, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 308 | struct fuse_file_info *); |
| 309 | |
| 310 | /** Release directory |
| 311 | * |
| 312 | * Introduced in version 2.3 |
| 313 | */ |
| 314 | int (*releasedir) (const char *, struct fuse_file_info *); |
| 315 | |
| 316 | /** Synchronize directory contents |
| 317 | * |
| 318 | * If the datasync parameter is non-zero, then only the user data |
| 319 | * should be flushed, not the meta data |
| 320 | * |
| 321 | * Introduced in version 2.3 |
| 322 | */ |
| 323 | int (*fsyncdir) (const char *, int, struct fuse_file_info *); |
| 324 | |
| 325 | /** |
| 326 | * Initialize filesystem |
| 327 | * |
| 328 | * The return value will passed in the private_data field of |
| 329 | * fuse_context to all file operations and as a parameter to the |
| 330 | * destroy() method. |
| 331 | * |
| 332 | * Introduced in version 2.3 |
| 333 | * Changed in version 2.6 |
| 334 | */ |
| 335 | void *(*init) (struct fuse_conn_info *conn); |
| 336 | |
| 337 | /** |
| 338 | * Clean up filesystem |
| 339 | * |
| 340 | * Called on filesystem exit. |
| 341 | * |
| 342 | * Introduced in version 2.3 |
| 343 | */ |
| 344 | void (*destroy) (void *); |
| 345 | |
| 346 | /** |
| 347 | * Check file access permissions |
| 348 | * |
| 349 | * This will be called for the access() system call. If the |
| 350 | * 'default_permissions' mount option is given, this method is not |
| 351 | * called. |
| 352 | * |
| 353 | * This method is not called under Linux kernel versions 2.4.x |
| 354 | * |
| 355 | * Introduced in version 2.5 |
| 356 | */ |
| 357 | int (*access) (const char *, int); |
| 358 | |
| 359 | /** |
| 360 | * Create and open a file |
| 361 | * |
| 362 | * If the file does not exist, first create it with the specified |
| 363 | * mode, and then open it. |
| 364 | * |
| 365 | * If this method is not implemented or under Linux kernel |
| 366 | * versions earlier than 2.6.15, the mknod() and open() methods |
| 367 | * will be called instead. |
| 368 | * |
| 369 | * Introduced in version 2.5 |
| 370 | */ |
| 371 | int (*create) (const char *, mode_t, struct fuse_file_info *); |
| 372 | |
| 373 | /** |
| 374 | * Change the size of an open file |
| 375 | * |
| 376 | * This method is called instead of the truncate() method if the |
| 377 | * truncation was invoked from an ftruncate() system call. |
| 378 | * |
| 379 | * If this method is not implemented or under Linux kernel |
| 380 | * versions earlier than 2.6.15, the truncate() method will be |
| 381 | * called instead. |
| 382 | * |
| 383 | * Introduced in version 2.5 |
| 384 | */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 385 | int (*ftruncate) (const char *, loff_t, struct fuse_file_info *); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 386 | |
| 387 | /** |
| 388 | * Get attributes from an open file |
| 389 | * |
| 390 | * This method is called instead of the getattr() method if the |
| 391 | * file information is available. |
| 392 | * |
| 393 | * Currently this is only called after the create() method if that |
| 394 | * is implemented (see above). Later it may be called for |
| 395 | * invocations of fstat() too. |
| 396 | * |
| 397 | * Introduced in version 2.5 |
| 398 | */ |
| 399 | int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); |
| 400 | |
| 401 | /** |
| 402 | * Perform POSIX file locking operation |
| 403 | * |
| 404 | * The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW. |
| 405 | * |
| 406 | * For the meaning of fields in 'struct flock' see the man page |
| 407 | * for fcntl(2). The l_whence field will always be set to |
| 408 | * SEEK_SET. |
| 409 | * |
| 410 | * For checking lock ownership, the 'fuse_file_info->owner' |
| 411 | * argument must be used. |
| 412 | * |
| 413 | * For F_GETLK operation, the library will first check currently |
| 414 | * held locks, and if a conflicting lock is found it will return |
| 415 | * information without calling this method. This ensures, that |
| 416 | * for local locks the l_pid field is correctly filled in. The |
| 417 | * results may not be accurate in case of race conditions and in |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 418 | * the presence of hard links, but it's unlikely that an |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 419 | * application would rely on accurate GETLK results in these |
| 420 | * cases. If a conflicting lock is not found, this method will be |
| 421 | * called, and the filesystem may fill out l_pid by a meaningful |
| 422 | * value, or it may leave this field zero. |
| 423 | * |
| 424 | * For F_SETLK and F_SETLKW the l_pid field will be set to the pid |
| 425 | * of the process performing the locking operation. |
| 426 | * |
| 427 | * Note: if this method is not implemented, the kernel will still |
| 428 | * allow file locking to work locally. Hence it is only |
| 429 | * interesting for network filesystems and similar. |
| 430 | * |
| 431 | * Introduced in version 2.6 |
| 432 | */ |
| 433 | int (*lock) (const char *, struct fuse_file_info *, int cmd, |
| 434 | struct flock *); |
| 435 | |
| 436 | /** |
| 437 | * Change the access and modification times of a file with |
| 438 | * nanosecond resolution |
| 439 | * |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 440 | * This supersedes the old utime() interface. New applications |
| 441 | * should use this. |
| 442 | * |
| 443 | * See the utimensat(2) man page for details. |
| 444 | * |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 445 | * Introduced in version 2.6 |
| 446 | */ |
| 447 | int (*utimens) (const char *, const struct timespec tv[2]); |
| 448 | |
| 449 | /** |
| 450 | * Map block index within file to block index within device |
| 451 | * |
| 452 | * Note: This makes sense only for block device backed filesystems |
| 453 | * mounted with the 'blkdev' option |
| 454 | * |
| 455 | * Introduced in version 2.6 |
| 456 | */ |
| 457 | int (*bmap) (const char *, size_t blocksize, uint64_t *idx); |
| 458 | |
| 459 | /** |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 460 | * Flag indicating that the filesystem can accept a NULL path |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 461 | * as the first argument for the following operations: |
| 462 | * |
| 463 | * read, write, flush, release, fsync, readdir, releasedir, |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 464 | * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll |
| 465 | * |
| 466 | * If this flag is set these operations continue to work on |
| 467 | * unlinked files even if "-ohard_remove" option was specified. |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 468 | */ |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 469 | unsigned int flag_nullpath_ok:1; |
| 470 | |
| 471 | /** |
| 472 | * Flag indicating that the path need not be calculated for |
| 473 | * the following operations: |
| 474 | * |
| 475 | * read, write, flush, release, fsync, readdir, releasedir, |
| 476 | * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll |
| 477 | * |
| 478 | * Closely related to flag_nullpath_ok, but if this flag is |
| 479 | * set then the path will not be calculaged even if the file |
| 480 | * wasn't unlinked. However the path can still be non-NULL if |
| 481 | * it needs to be calculated for some other reason. |
| 482 | */ |
| 483 | unsigned int flag_nopath:1; |
| 484 | |
| 485 | /** |
| 486 | * Flag indicating that the filesystem accepts special |
| 487 | * UTIME_NOW and UTIME_OMIT values in its utimens operation. |
| 488 | */ |
| 489 | unsigned int flag_utime_omit_ok:1; |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 490 | |
| 491 | /** |
| 492 | * Reserved flags, don't set |
| 493 | */ |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 494 | unsigned int flag_reserved:29; |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 495 | |
| 496 | /** |
| 497 | * Ioctl |
| 498 | * |
| 499 | * flags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in |
| 500 | * 64bit environment. The size and direction of data is |
| 501 | * determined by _IOC_*() decoding of cmd. For _IOC_NONE, |
| 502 | * data will be NULL, for _IOC_WRITE data is out area, for |
| 503 | * _IOC_READ in area and if both are set in/out area. In all |
| 504 | * non-NULL cases, the area is of _IOC_SIZE(cmd) bytes. |
| 505 | * |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 506 | * If flags has FUSE_IOCTL_DIR then the fuse_file_info refers to a |
| 507 | * directory file handle. |
| 508 | * |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 509 | * Introduced in version 2.8 |
| 510 | */ |
| 511 | int (*ioctl) (const char *, int cmd, void *arg, |
| 512 | struct fuse_file_info *, unsigned int flags, void *data); |
| 513 | |
| 514 | /** |
| 515 | * Poll for IO readiness events |
| 516 | * |
| 517 | * Note: If ph is non-NULL, the client should notify |
| 518 | * when IO readiness events occur by calling |
| 519 | * fuse_notify_poll() with the specified ph. |
| 520 | * |
| 521 | * Regardless of the number of times poll with a non-NULL ph |
| 522 | * is received, single notification is enough to clear all. |
| 523 | * Notifying more times incurs overhead but doesn't harm |
| 524 | * correctness. |
| 525 | * |
| 526 | * The callee is responsible for destroying ph with |
| 527 | * fuse_pollhandle_destroy() when no longer in use. |
| 528 | * |
| 529 | * Introduced in version 2.8 |
| 530 | */ |
| 531 | int (*poll) (const char *, struct fuse_file_info *, |
| 532 | struct fuse_pollhandle *ph, unsigned *reventsp); |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 533 | |
| 534 | /** Write contents of buffer to an open file |
| 535 | * |
| 536 | * Similar to the write() method, but data is supplied in a |
| 537 | * generic buffer. Use fuse_buf_copy() to transfer data to |
| 538 | * the destination. |
| 539 | * |
| 540 | * Introduced in version 2.9 |
| 541 | */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 542 | int (*write_buf) (const char *, struct fuse_bufvec *buf, loff_t off, |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 543 | struct fuse_file_info *); |
| 544 | |
| 545 | /** Store data from an open file in a buffer |
| 546 | * |
| 547 | * Similar to the read() method, but data is stored and |
| 548 | * returned in a generic buffer. |
| 549 | * |
| 550 | * No actual copying of data has to take place, the source |
| 551 | * file descriptor may simply be stored in the buffer for |
| 552 | * later data transfer. |
| 553 | * |
| 554 | * The buffer must be allocated dynamically and stored at the |
| 555 | * location pointed to by bufp. If the buffer contains memory |
| 556 | * regions, they too must be allocated using malloc(). The |
| 557 | * allocated memory will be freed by the caller. |
| 558 | * |
| 559 | * Introduced in version 2.9 |
| 560 | */ |
| 561 | int (*read_buf) (const char *, struct fuse_bufvec **bufp, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 562 | size_t size, loff_t off, struct fuse_file_info *); |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 563 | /** |
| 564 | * Perform BSD file locking operation |
| 565 | * |
| 566 | * The op argument will be either LOCK_SH, LOCK_EX or LOCK_UN |
| 567 | * |
| 568 | * Nonblocking requests will be indicated by ORing LOCK_NB to |
| 569 | * the above operations |
| 570 | * |
| 571 | * For more information see the flock(2) manual page. |
| 572 | * |
| 573 | * Additionally fi->owner will be set to a value unique to |
| 574 | * this open file. This same value will be supplied to |
| 575 | * ->release() when the file is released. |
| 576 | * |
| 577 | * Note: if this method is not implemented, the kernel will still |
| 578 | * allow file locking to work locally. Hence it is only |
| 579 | * interesting for network filesystems and similar. |
| 580 | * |
| 581 | * Introduced in version 2.9 |
| 582 | */ |
| 583 | int (*flock) (const char *, struct fuse_file_info *, int op); |
| 584 | |
| 585 | /** |
| 586 | * Allocates space for an open file |
| 587 | * |
| 588 | * This function ensures that required space is allocated for specified |
| 589 | * file. If this function returns success then any subsequent write |
| 590 | * request to specified range is guaranteed not to fail because of lack |
| 591 | * of space on the file system media. |
| 592 | * |
| 593 | * Introduced in version 2.9.1 |
| 594 | */ |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 595 | int (*fallocate) (const char *, int, loff_t, loff_t, |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 596 | struct fuse_file_info *); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 597 | }; |
| 598 | |
| 599 | /** Extra context that may be needed by some filesystems |
| 600 | * |
| 601 | * The uid, gid and pid fields are not filled in case of a writepage |
| 602 | * operation. |
| 603 | */ |
| 604 | struct fuse_context { |
| 605 | /** Pointer to the fuse object */ |
| 606 | struct fuse *fuse; |
| 607 | |
| 608 | /** User ID of the calling process */ |
| 609 | uid_t uid; |
| 610 | |
| 611 | /** Group ID of the calling process */ |
| 612 | gid_t gid; |
| 613 | |
| 614 | /** Thread ID of the calling process */ |
| 615 | pid_t pid; |
| 616 | |
| 617 | /** Private filesystem data */ |
| 618 | void *private_data; |
| 619 | |
| 620 | /** Umask of the calling process (introduced in version 2.8) */ |
| 621 | mode_t umask; |
| 622 | }; |
| 623 | |
| 624 | /** |
| 625 | * Main function of FUSE. |
| 626 | * |
| 627 | * This is for the lazy. This is all that has to be called from the |
| 628 | * main() function. |
| 629 | * |
| 630 | * This function does the following: |
| 631 | * - parses command line options (-d -s and -h) |
| 632 | * - passes relevant mount options to the fuse_mount() |
| 633 | * - installs signal handlers for INT, HUP, TERM and PIPE |
| 634 | * - registers an exit handler to unmount the filesystem on program exit |
| 635 | * - creates a fuse handle |
| 636 | * - registers the operations |
| 637 | * - calls either the single-threaded or the multi-threaded event loop |
| 638 | * |
| 639 | * Note: this is currently implemented as a macro. |
| 640 | * |
| 641 | * @param argc the argument counter passed to the main() function |
| 642 | * @param argv the argument vector passed to the main() function |
| 643 | * @param op the file system operation |
| 644 | * @param user_data user data supplied in the context during the init() method |
| 645 | * @return 0 on success, nonzero on failure |
| 646 | */ |
| 647 | /* |
| 648 | int fuse_main(int argc, char *argv[], const struct fuse_operations *op, |
| 649 | void *user_data); |
| 650 | */ |
| 651 | #define fuse_main(argc, argv, op, user_data) \ |
| 652 | fuse_main_real(argc, argv, op, sizeof(*(op)), user_data) |
| 653 | |
| 654 | /* ----------------------------------------------------------- * |
| 655 | * More detailed API * |
| 656 | * ----------------------------------------------------------- */ |
| 657 | |
| 658 | /** |
| 659 | * Create a new FUSE filesystem. |
| 660 | * |
| 661 | * @param ch the communication channel |
| 662 | * @param args argument vector |
| 663 | * @param op the filesystem operations |
| 664 | * @param op_size the size of the fuse_operations structure |
| 665 | * @param user_data user data supplied in the context during the init() method |
| 666 | * @return the created FUSE handle |
| 667 | */ |
| 668 | struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args, |
| 669 | const struct fuse_operations *op, size_t op_size, |
| 670 | void *user_data); |
| 671 | |
| 672 | /** |
| 673 | * Destroy the FUSE handle. |
| 674 | * |
| 675 | * The communication channel attached to the handle is also destroyed. |
| 676 | * |
| 677 | * NOTE: This function does not unmount the filesystem. If this is |
| 678 | * needed, call fuse_unmount() before calling this function. |
| 679 | * |
| 680 | * @param f the FUSE handle |
| 681 | */ |
| 682 | void fuse_destroy(struct fuse *f); |
| 683 | |
| 684 | /** |
| 685 | * FUSE event loop. |
| 686 | * |
| 687 | * Requests from the kernel are processed, and the appropriate |
| 688 | * operations are called. |
| 689 | * |
| 690 | * @param f the FUSE handle |
| 691 | * @return 0 if no error occurred, -1 otherwise |
| 692 | */ |
| 693 | int fuse_loop(struct fuse *f); |
| 694 | |
| 695 | /** |
| 696 | * Exit from event loop |
| 697 | * |
| 698 | * @param f the FUSE handle |
| 699 | */ |
| 700 | void fuse_exit(struct fuse *f); |
| 701 | |
| 702 | /** |
| 703 | * FUSE event loop with multiple threads |
| 704 | * |
| 705 | * Requests from the kernel are processed, and the appropriate |
| 706 | * operations are called. Request are processed in parallel by |
| 707 | * distributing them between multiple threads. |
| 708 | * |
| 709 | * Calling this function requires the pthreads library to be linked to |
| 710 | * the application. |
| 711 | * |
| 712 | * @param f the FUSE handle |
| 713 | * @return 0 if no error occurred, -1 otherwise |
| 714 | */ |
| 715 | int fuse_loop_mt(struct fuse *f); |
| 716 | |
| 717 | /** |
| 718 | * Get the current context |
| 719 | * |
| 720 | * The context is only valid for the duration of a filesystem |
| 721 | * operation, and thus must not be stored and used later. |
| 722 | * |
| 723 | * @return the context |
| 724 | */ |
| 725 | struct fuse_context *fuse_get_context(void); |
| 726 | |
| 727 | /** |
| 728 | * Get the current supplementary group IDs for the current request |
| 729 | * |
| 730 | * Similar to the getgroups(2) system call, except the return value is |
| 731 | * always the total number of group IDs, even if it is larger than the |
| 732 | * specified size. |
| 733 | * |
| 734 | * The current fuse kernel module in linux (as of 2.6.30) doesn't pass |
| 735 | * the group list to userspace, hence this function needs to parse |
| 736 | * "/proc/$TID/task/$TID/status" to get the group IDs. |
| 737 | * |
| 738 | * This feature may not be supported on all operating systems. In |
| 739 | * such a case this function will return -ENOSYS. |
| 740 | * |
| 741 | * @param size size of given array |
| 742 | * @param list array of group IDs to be filled in |
| 743 | * @return the total number of supplementary group IDs or -errno on failure |
| 744 | */ |
| 745 | int fuse_getgroups(int size, gid_t list[]); |
| 746 | |
| 747 | /** |
| 748 | * Check if the current request has already been interrupted |
| 749 | * |
| 750 | * @return 1 if the request has been interrupted, 0 otherwise |
| 751 | */ |
| 752 | int fuse_interrupted(void); |
| 753 | |
| 754 | /** |
| 755 | * Obsolete, doesn't do anything |
| 756 | * |
| 757 | * @return -EINVAL |
| 758 | */ |
| 759 | int fuse_invalidate(struct fuse *f, const char *path); |
| 760 | |
| 761 | /* Deprecated, don't use */ |
| 762 | int fuse_is_lib_option(const char *opt); |
| 763 | |
| 764 | /** |
| 765 | * The real main function |
| 766 | * |
| 767 | * Do not call this directly, use fuse_main() |
| 768 | */ |
| 769 | int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, |
| 770 | size_t op_size, void *user_data); |
| 771 | |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 772 | /** |
| 773 | * Start the cleanup thread when using option "remember". |
| 774 | * |
| 775 | * This is done automatically by fuse_loop_mt() |
| 776 | * @param fuse struct fuse pointer for fuse instance |
| 777 | * @return 0 on success and -1 on error |
| 778 | */ |
| 779 | int fuse_start_cleanup_thread(struct fuse *fuse); |
| 780 | |
| 781 | /** |
| 782 | * Stop the cleanup thread when using option "remember". |
| 783 | * |
| 784 | * This is done automatically by fuse_loop_mt() |
| 785 | * @param fuse struct fuse pointer for fuse instance |
| 786 | */ |
| 787 | void fuse_stop_cleanup_thread(struct fuse *fuse); |
| 788 | |
| 789 | /** |
| 790 | * Iterate over cache removing stale entries |
| 791 | * use in conjunction with "-oremember" |
| 792 | * |
| 793 | * NOTE: This is already done for the standard sessions |
| 794 | * |
| 795 | * @param fuse struct fuse pointer for fuse instance |
| 796 | * @return the number of seconds until the next cleanup |
| 797 | */ |
| 798 | int fuse_clean_cache(struct fuse *fuse); |
| 799 | |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 800 | /* |
| 801 | * Stacking API |
| 802 | */ |
| 803 | |
| 804 | /** |
| 805 | * Fuse filesystem object |
| 806 | * |
| 807 | * This is opaque object represents a filesystem layer |
| 808 | */ |
| 809 | struct fuse_fs; |
| 810 | |
| 811 | /* |
| 812 | * These functions call the relevant filesystem operation, and return |
| 813 | * the result. |
| 814 | * |
| 815 | * If the operation is not defined, they return -ENOSYS, with the |
| 816 | * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir, |
| 817 | * fuse_fs_releasedir and fuse_fs_statfs, which return 0. |
| 818 | */ |
| 819 | |
| 820 | int fuse_fs_getattr(struct fuse_fs *fs, const char *path, struct stat *buf); |
| 821 | int fuse_fs_fgetattr(struct fuse_fs *fs, const char *path, struct stat *buf, |
| 822 | struct fuse_file_info *fi); |
| 823 | int fuse_fs_rename(struct fuse_fs *fs, const char *oldpath, |
| 824 | const char *newpath); |
| 825 | int fuse_fs_unlink(struct fuse_fs *fs, const char *path); |
| 826 | int fuse_fs_rmdir(struct fuse_fs *fs, const char *path); |
| 827 | int fuse_fs_symlink(struct fuse_fs *fs, const char *linkname, |
| 828 | const char *path); |
| 829 | int fuse_fs_link(struct fuse_fs *fs, const char *oldpath, const char *newpath); |
| 830 | int fuse_fs_release(struct fuse_fs *fs, const char *path, |
| 831 | struct fuse_file_info *fi); |
| 832 | int fuse_fs_open(struct fuse_fs *fs, const char *path, |
| 833 | struct fuse_file_info *fi); |
| 834 | int fuse_fs_read(struct fuse_fs *fs, const char *path, char *buf, size_t size, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 835 | loff_t off, struct fuse_file_info *fi); |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 836 | int fuse_fs_read_buf(struct fuse_fs *fs, const char *path, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 837 | struct fuse_bufvec **bufp, size_t size, loff_t off, |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 838 | struct fuse_file_info *fi); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 839 | int fuse_fs_write(struct fuse_fs *fs, const char *path, const char *buf, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 840 | size_t size, loff_t off, struct fuse_file_info *fi); |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 841 | int fuse_fs_write_buf(struct fuse_fs *fs, const char *path, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 842 | struct fuse_bufvec *buf, loff_t off, |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 843 | struct fuse_file_info *fi); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 844 | int fuse_fs_fsync(struct fuse_fs *fs, const char *path, int datasync, |
| 845 | struct fuse_file_info *fi); |
| 846 | int fuse_fs_flush(struct fuse_fs *fs, const char *path, |
| 847 | struct fuse_file_info *fi); |
| 848 | int fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf); |
| 849 | int fuse_fs_opendir(struct fuse_fs *fs, const char *path, |
| 850 | struct fuse_file_info *fi); |
| 851 | int fuse_fs_readdir(struct fuse_fs *fs, const char *path, void *buf, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 852 | fuse_fill_dir_t filler, loff_t off, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 853 | struct fuse_file_info *fi); |
| 854 | int fuse_fs_fsyncdir(struct fuse_fs *fs, const char *path, int datasync, |
| 855 | struct fuse_file_info *fi); |
| 856 | int fuse_fs_releasedir(struct fuse_fs *fs, const char *path, |
| 857 | struct fuse_file_info *fi); |
| 858 | int fuse_fs_create(struct fuse_fs *fs, const char *path, mode_t mode, |
| 859 | struct fuse_file_info *fi); |
| 860 | int fuse_fs_lock(struct fuse_fs *fs, const char *path, |
| 861 | struct fuse_file_info *fi, int cmd, struct flock *lock); |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 862 | int fuse_fs_flock(struct fuse_fs *fs, const char *path, |
| 863 | struct fuse_file_info *fi, int op); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 864 | int fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode); |
| 865 | int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid); |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 866 | int fuse_fs_truncate(struct fuse_fs *fs, const char *path, loff_t size); |
| 867 | int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, loff_t size, |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 868 | struct fuse_file_info *fi); |
| 869 | int fuse_fs_utimens(struct fuse_fs *fs, const char *path, |
| 870 | const struct timespec tv[2]); |
| 871 | int fuse_fs_access(struct fuse_fs *fs, const char *path, int mask); |
| 872 | int fuse_fs_readlink(struct fuse_fs *fs, const char *path, char *buf, |
| 873 | size_t len); |
| 874 | int fuse_fs_mknod(struct fuse_fs *fs, const char *path, mode_t mode, |
| 875 | dev_t rdev); |
| 876 | int fuse_fs_mkdir(struct fuse_fs *fs, const char *path, mode_t mode); |
| 877 | int fuse_fs_setxattr(struct fuse_fs *fs, const char *path, const char *name, |
| 878 | const char *value, size_t size, int flags); |
| 879 | int fuse_fs_getxattr(struct fuse_fs *fs, const char *path, const char *name, |
| 880 | char *value, size_t size); |
| 881 | int fuse_fs_listxattr(struct fuse_fs *fs, const char *path, char *list, |
| 882 | size_t size); |
| 883 | int fuse_fs_removexattr(struct fuse_fs *fs, const char *path, |
| 884 | const char *name); |
| 885 | int fuse_fs_bmap(struct fuse_fs *fs, const char *path, size_t blocksize, |
| 886 | uint64_t *idx); |
| 887 | int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, int cmd, void *arg, |
| 888 | struct fuse_file_info *fi, unsigned int flags, void *data); |
| 889 | int fuse_fs_poll(struct fuse_fs *fs, const char *path, |
| 890 | struct fuse_file_info *fi, struct fuse_pollhandle *ph, |
| 891 | unsigned *reventsp); |
Dees_Troy | e34c133 | 2013-02-06 19:13:00 +0000 | [diff] [blame] | 892 | int fuse_fs_fallocate(struct fuse_fs *fs, const char *path, int mode, |
Matt Mower | 523a059 | 2015-12-13 11:31:00 -0600 | [diff] [blame] | 893 | loff_t offset, loff_t length, struct fuse_file_info *fi); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 894 | void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn); |
| 895 | void fuse_fs_destroy(struct fuse_fs *fs); |
| 896 | |
| 897 | int fuse_notify_poll(struct fuse_pollhandle *ph); |
| 898 | |
| 899 | /** |
| 900 | * Create a new fuse filesystem object |
| 901 | * |
| 902 | * This is usually called from the factory of a fuse module to create |
| 903 | * a new instance of a filesystem. |
| 904 | * |
| 905 | * @param op the filesystem operations |
| 906 | * @param op_size the size of the fuse_operations structure |
| 907 | * @param user_data user data supplied in the context during the init() method |
| 908 | * @return a new filesystem object |
| 909 | */ |
| 910 | struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size, |
| 911 | void *user_data); |
| 912 | |
| 913 | /** |
| 914 | * Filesystem module |
| 915 | * |
| 916 | * Filesystem modules are registered with the FUSE_REGISTER_MODULE() |
| 917 | * macro. |
| 918 | * |
| 919 | * If the "-omodules=modname:..." option is present, filesystem |
| 920 | * objects are created and pushed onto the stack with the 'factory' |
| 921 | * function. |
| 922 | */ |
| 923 | struct fuse_module { |
| 924 | /** |
| 925 | * Name of filesystem |
| 926 | */ |
| 927 | const char *name; |
| 928 | |
| 929 | /** |
| 930 | * Factory for creating filesystem objects |
| 931 | * |
| 932 | * The function may use and remove options from 'args' that belong |
| 933 | * to this module. |
| 934 | * |
| 935 | * For now the 'fs' vector always contains exactly one filesystem. |
| 936 | * This is the filesystem which will be below the newly created |
| 937 | * filesystem in the stack. |
| 938 | * |
| 939 | * @param args the command line arguments |
| 940 | * @param fs NULL terminated filesystem object vector |
| 941 | * @return the new filesystem object |
| 942 | */ |
| 943 | struct fuse_fs *(*factory)(struct fuse_args *args, |
| 944 | struct fuse_fs *fs[]); |
| 945 | |
| 946 | struct fuse_module *next; |
| 947 | struct fusemod_so *so; |
| 948 | int ctr; |
| 949 | }; |
| 950 | |
| 951 | /** |
| 952 | * Register a filesystem module |
| 953 | * |
| 954 | * This function is used by FUSE_REGISTER_MODULE and there's usually |
| 955 | * no need to call it directly |
| 956 | */ |
| 957 | void fuse_register_module(struct fuse_module *mod); |
| 958 | |
| 959 | /** |
| 960 | * Register filesystem module |
| 961 | * |
| 962 | * For the parameters, see description of the fields in 'struct |
| 963 | * fuse_module' |
| 964 | */ |
| 965 | #define FUSE_REGISTER_MODULE(name_, factory_) \ |
| 966 | static __attribute__((constructor)) void name_ ## _register(void) \ |
| 967 | { \ |
| 968 | static struct fuse_module mod = \ |
| 969 | { #name_, factory_, NULL, NULL, 0 }; \ |
| 970 | fuse_register_module(&mod); \ |
| 971 | } |
| 972 | |
| 973 | |
| 974 | /* ----------------------------------------------------------- * |
| 975 | * Advanced API for event handling, don't worry about this... * |
| 976 | * ----------------------------------------------------------- */ |
| 977 | |
| 978 | /* NOTE: the following functions are deprecated, and will be removed |
| 979 | from the 3.0 API. Use the lowlevel session functions instead */ |
| 980 | |
| 981 | /** Function type used to process commands */ |
| 982 | typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *); |
| 983 | |
| 984 | /** This is the part of fuse_main() before the event loop */ |
| 985 | struct fuse *fuse_setup(int argc, char *argv[], |
| 986 | const struct fuse_operations *op, size_t op_size, |
| 987 | char **mountpoint, int *multithreaded, |
| 988 | void *user_data); |
| 989 | |
| 990 | /** This is the part of fuse_main() after the event loop */ |
| 991 | void fuse_teardown(struct fuse *fuse, char *mountpoint); |
| 992 | |
| 993 | /** Read a single command. If none are read, return NULL */ |
| 994 | struct fuse_cmd *fuse_read_cmd(struct fuse *f); |
| 995 | |
| 996 | /** Process a single command */ |
| 997 | void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd); |
| 998 | |
| 999 | /** Multi threaded event loop, which calls the custom command |
| 1000 | processor function */ |
| 1001 | int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data); |
| 1002 | |
| 1003 | /** Return the exited flag, which indicates if fuse_exit() has been |
| 1004 | called */ |
| 1005 | int fuse_exited(struct fuse *f); |
| 1006 | |
| 1007 | /** This function is obsolete and implemented as a no-op */ |
| 1008 | void fuse_set_getcontext_func(struct fuse_context *(*func)(void)); |
| 1009 | |
| 1010 | /** Get session from fuse object */ |
| 1011 | struct fuse_session *fuse_get_session(struct fuse *f); |
| 1012 | |
| 1013 | /* ----------------------------------------------------------- * |
| 1014 | * Compatibility stuff * |
| 1015 | * ----------------------------------------------------------- */ |
| 1016 | |
| 1017 | #if FUSE_USE_VERSION < 26 |
| 1018 | # include "fuse_compat.h" |
| 1019 | # undef fuse_main |
| 1020 | # if FUSE_USE_VERSION == 25 |
| 1021 | # define fuse_main(argc, argv, op) \ |
| 1022 | fuse_main_real_compat25(argc, argv, op, sizeof(*(op))) |
| 1023 | # define fuse_new fuse_new_compat25 |
| 1024 | # define fuse_setup fuse_setup_compat25 |
| 1025 | # define fuse_teardown fuse_teardown_compat22 |
| 1026 | # define fuse_operations fuse_operations_compat25 |
| 1027 | # elif FUSE_USE_VERSION == 22 |
| 1028 | # define fuse_main(argc, argv, op) \ |
| 1029 | fuse_main_real_compat22(argc, argv, op, sizeof(*(op))) |
| 1030 | # define fuse_new fuse_new_compat22 |
| 1031 | # define fuse_setup fuse_setup_compat22 |
| 1032 | # define fuse_teardown fuse_teardown_compat22 |
| 1033 | # define fuse_operations fuse_operations_compat22 |
| 1034 | # define fuse_file_info fuse_file_info_compat |
| 1035 | # elif FUSE_USE_VERSION == 24 |
| 1036 | # error Compatibility with high-level API version 24 not supported |
| 1037 | # else |
| 1038 | # define fuse_dirfil_t fuse_dirfil_t_compat |
| 1039 | # define __fuse_read_cmd fuse_read_cmd |
| 1040 | # define __fuse_process_cmd fuse_process_cmd |
| 1041 | # define __fuse_loop_mt fuse_loop_mt_proc |
| 1042 | # if FUSE_USE_VERSION == 21 |
| 1043 | # define fuse_operations fuse_operations_compat2 |
| 1044 | # define fuse_main fuse_main_compat2 |
| 1045 | # define fuse_new fuse_new_compat2 |
| 1046 | # define __fuse_setup fuse_setup_compat2 |
| 1047 | # define __fuse_teardown fuse_teardown_compat22 |
| 1048 | # define __fuse_exited fuse_exited |
| 1049 | # define __fuse_set_getcontext_func fuse_set_getcontext_func |
| 1050 | # else |
| 1051 | # define fuse_statfs fuse_statfs_compat1 |
| 1052 | # define fuse_operations fuse_operations_compat1 |
| 1053 | # define fuse_main fuse_main_compat1 |
| 1054 | # define fuse_new fuse_new_compat1 |
| 1055 | # define FUSE_DEBUG FUSE_DEBUG_COMPAT1 |
| 1056 | # endif |
| 1057 | # endif |
| 1058 | #endif |
| 1059 | |
| 1060 | #ifdef __cplusplus |
| 1061 | } |
| 1062 | #endif |
| 1063 | |
| 1064 | #endif /* _FUSE_H_ */ |