Merge branch 'clone_fd'
[fuse.git] / include / fuse.h
blobe16104c3f6152d7315ff334ef87a3cfaa5b4dcd7
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB.
7 */
9 #ifndef _FUSE_H_
10 #define _FUSE_H_
12 /** @file
14 * This file defines the library interface of FUSE
16 * IMPORTANT: you should define FUSE_USE_VERSION before including this header.
19 #include "fuse_common.h"
21 #include <fcntl.h>
22 #include <time.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <sys/statvfs.h>
26 #include <sys/uio.h>
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 /* ----------------------------------------------------------- *
33 * Basic FUSE API *
34 * ----------------------------------------------------------- */
36 /** Handle for a FUSE filesystem */
37 struct fuse;
39 /**
40 * Readdir flags, passed to ->readdir()
42 enum fuse_readdir_flags {
43 /**
44 * "Plus" mode.
46 * The kernel wants to prefill the inode cache during readdir. The
47 * filesystem may honour this by filling in the attributes and setting
48 * FUSE_FILL_DIR_FLAGS for the filler function. The filesystem may also
49 * just ignore this flag completely.
51 FUSE_READDIR_PLUS = (1 << 0),
54 enum fuse_fill_dir_flags {
55 /**
56 * "Plus" mode: all file attributes are valid
58 * The attributes are used by the kernel to prefill the inode cache
59 * during a readdir.
61 * It is okay to set FUSE_FILL_DIR_PLUS if FUSE_READDIR_PLUS is not set
62 * and vice versa.
64 FUSE_FILL_DIR_PLUS = (1 << 1),
67 /** Function to add an entry in a readdir() operation
69 * @param buf the buffer passed to the readdir() operation
70 * @param name the file name of the directory entry
71 * @param stat file attributes, can be NULL
72 * @param off offset of the next entry or zero
73 * @param flags fill flags
74 * @return 1 if buffer is full, zero otherwise
76 typedef int (*fuse_fill_dir_t) (void *buf, const char *name,
77 const struct stat *stbuf, off_t off,
78 enum fuse_fill_dir_flags flags);
80 /**
81 * The file system operations:
83 * Most of these should work very similarly to the well known UNIX
84 * file system operations. A major exception is that instead of
85 * returning an error in 'errno', the operation should return the
86 * negated error value (-errno) directly.
88 * All methods are optional, but some are essential for a useful
89 * filesystem (e.g. getattr). Open, flush, release, fsync, opendir,
90 * releasedir, fsyncdir, access, create, ftruncate, fgetattr, lock,
91 * init and destroy are special purpose methods, without which a full
92 * featured filesystem can still be implemented.
94 * Almost all operations take a path which can be of any length.
96 * Changed in fuse 2.8.0 (regardless of API version)
97 * Previously, paths were limited to a length of PATH_MAX.
99 * See http://fuse.sourceforge.net/wiki/ for more information. There
100 * is also a snapshot of the relevant wiki pages in the doc/ folder.
102 struct fuse_operations {
104 * Flag indicating that the path need not be calculated for
105 * the following operations:
107 * read, write, flush, release, fsync, readdir, releasedir,
108 * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
110 * If this flag is set then the path will not be calculaged even if the
111 * file wasn't unlinked. However the path can still be non-NULL if it
112 * needs to be calculated for some other reason.
114 unsigned int flag_nopath:1;
117 * Reserved flags, don't set
119 unsigned int flag_reserved:31;
121 /** Get file attributes.
123 * Similar to stat(). The 'st_dev' and 'st_blksize' fields are
124 * ignored. The 'st_ino' field is ignored except if the 'use_ino'
125 * mount option is given.
127 int (*getattr) (const char *, struct stat *);
129 /** Read the target of a symbolic link
131 * The buffer should be filled with a null terminated string. The
132 * buffer size argument includes the space for the terminating
133 * null character. If the linkname is too long to fit in the
134 * buffer, it should be truncated. The return value should be 0
135 * for success.
137 int (*readlink) (const char *, char *, size_t);
139 /** Create a file node
141 * This is called for creation of all non-directory, non-symlink
142 * nodes. If the filesystem defines a create() method, then for
143 * regular files that will be called instead.
145 int (*mknod) (const char *, mode_t, dev_t);
147 /** Create a directory
149 * Note that the mode argument may not have the type specification
150 * bits set, i.e. S_ISDIR(mode) can be false. To obtain the
151 * correct directory type bits use mode|S_IFDIR
152 * */
153 int (*mkdir) (const char *, mode_t);
155 /** Remove a file */
156 int (*unlink) (const char *);
158 /** Remove a directory */
159 int (*rmdir) (const char *);
161 /** Create a symbolic link */
162 int (*symlink) (const char *, const char *);
164 /** Rename a file */
165 int (*rename) (const char *, const char *, unsigned int);
167 /** Create a hard link to a file */
168 int (*link) (const char *, const char *);
170 /** Change the permission bits of a file */
171 int (*chmod) (const char *, mode_t);
173 /** Change the owner and group of a file */
174 int (*chown) (const char *, uid_t, gid_t);
176 /** Change the size of a file */
177 int (*truncate) (const char *, off_t);
179 /** File open operation
181 * No creation (O_CREAT, O_EXCL) and by default also no
182 * truncation (O_TRUNC) flags will be passed to open(). If an
183 * application specifies O_TRUNC, fuse first calls truncate()
184 * and then open(). Only if 'atomic_o_trunc' has been
185 * specified and kernel version is 2.6.24 or later, O_TRUNC is
186 * passed on to open.
188 * Unless the 'default_permissions' mount option is given,
189 * open should check if the operation is permitted for the
190 * given flags. Optionally open may also return an arbitrary
191 * filehandle in the fuse_file_info structure, which will be
192 * passed to all file operations.
194 * Changed in version 2.2
196 int (*open) (const char *, struct fuse_file_info *);
198 /** Read data from an open file
200 * Read should return exactly the number of bytes requested except
201 * on EOF or error, otherwise the rest of the data will be
202 * substituted with zeroes. An exception to this is when the
203 * 'direct_io' mount option is specified, in which case the return
204 * value of the read system call will reflect the return value of
205 * this operation.
207 * Changed in version 2.2
209 int (*read) (const char *, char *, size_t, off_t,
210 struct fuse_file_info *);
212 /** Write data to an open file
214 * Write should return exactly the number of bytes requested
215 * except on error. An exception to this is when the 'direct_io'
216 * mount option is specified (see read operation).
218 * Changed in version 2.2
220 int (*write) (const char *, const char *, size_t, off_t,
221 struct fuse_file_info *);
223 /** Get file system statistics
225 * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored
227 * Replaced 'struct statfs' parameter with 'struct statvfs' in
228 * version 2.5
230 int (*statfs) (const char *, struct statvfs *);
232 /** Possibly flush cached data
234 * BIG NOTE: This is not equivalent to fsync(). It's not a
235 * request to sync dirty data.
237 * Flush is called on each close() of a file descriptor. So if a
238 * filesystem wants to return write errors in close() and the file
239 * has cached dirty data, this is a good place to write back data
240 * and return any errors. Since many applications ignore close()
241 * errors this is not always useful.
243 * NOTE: The flush() method may be called more than once for each
244 * open(). This happens if more than one file descriptor refers
245 * to an opened file due to dup(), dup2() or fork() calls. It is
246 * not possible to determine if a flush is final, so each flush
247 * should be treated equally. Multiple write-flush sequences are
248 * relatively rare, so this shouldn't be a problem.
250 * Filesystems shouldn't assume that flush will always be called
251 * after some writes, or that if will be called at all.
253 * Changed in version 2.2
255 int (*flush) (const char *, struct fuse_file_info *);
257 /** Release an open file
259 * Release is called when there are no more references to an open
260 * file: all file descriptors are closed and all memory mappings
261 * are unmapped.
263 * For every open() call there will be exactly one release() call
264 * with the same flags and file descriptor. It is possible to
265 * have a file opened more than once, in which case only the last
266 * release will mean, that no more reads/writes will happen on the
267 * file. The return value of release is ignored.
269 * Changed in version 2.2
271 int (*release) (const char *, struct fuse_file_info *);
273 /** Synchronize file contents
275 * If the datasync parameter is non-zero, then only the user data
276 * should be flushed, not the meta data.
278 * Changed in version 2.2
280 int (*fsync) (const char *, int, struct fuse_file_info *);
282 /** Set extended attributes */
283 int (*setxattr) (const char *, const char *, const char *, size_t, int);
285 /** Get extended attributes */
286 int (*getxattr) (const char *, const char *, char *, size_t);
288 /** List extended attributes */
289 int (*listxattr) (const char *, char *, size_t);
291 /** Remove extended attributes */
292 int (*removexattr) (const char *, const char *);
294 /** Open directory
296 * Unless the 'default_permissions' mount option is given,
297 * this method should check if opendir is permitted for this
298 * directory. Optionally opendir may also return an arbitrary
299 * filehandle in the fuse_file_info structure, which will be
300 * passed to readdir, closedir and fsyncdir.
302 * Introduced in version 2.3
304 int (*opendir) (const char *, struct fuse_file_info *);
306 /** Read directory
308 * The filesystem may choose between two modes of operation:
310 * 1) The readdir implementation ignores the offset parameter, and
311 * passes zero to the filler function's offset. The filler
312 * function will not return '1' (unless an error happens), so the
313 * whole directory is read in a single readdir operation.
315 * 2) The readdir implementation keeps track of the offsets of the
316 * directory entries. It uses the offset parameter and always
317 * passes non-zero offset to the filler function. When the buffer
318 * is full (or an error happens) the filler function will return
319 * '1'.
321 * Introduced in version 2.3
322 * The "flags" argument added in version 3.0
324 int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
325 struct fuse_file_info *, enum fuse_readdir_flags);
327 /** Release directory
329 * Introduced in version 2.3
331 int (*releasedir) (const char *, struct fuse_file_info *);
333 /** Synchronize directory contents
335 * If the datasync parameter is non-zero, then only the user data
336 * should be flushed, not the meta data
338 * Introduced in version 2.3
340 int (*fsyncdir) (const char *, int, struct fuse_file_info *);
343 * Initialize filesystem
345 * The return value will passed in the private_data field of
346 * fuse_context to all file operations and as a parameter to the
347 * destroy() method.
349 * Introduced in version 2.3
350 * Changed in version 2.6
352 void *(*init) (struct fuse_conn_info *conn);
355 * Clean up filesystem
357 * Called on filesystem exit.
359 * Introduced in version 2.3
361 void (*destroy) (void *);
364 * Check file access permissions
366 * This will be called for the access() system call. If the
367 * 'default_permissions' mount option is given, this method is not
368 * called.
370 * This method is not called under Linux kernel versions 2.4.x
372 * Introduced in version 2.5
374 int (*access) (const char *, int);
377 * Create and open a file
379 * If the file does not exist, first create it with the specified
380 * mode, and then open it.
382 * If this method is not implemented or under Linux kernel
383 * versions earlier than 2.6.15, the mknod() and open() methods
384 * will be called instead.
386 * Introduced in version 2.5
388 int (*create) (const char *, mode_t, struct fuse_file_info *);
391 * Change the size of an open file
393 * This method is called instead of the truncate() method if the
394 * truncation was invoked from an ftruncate() system call.
396 * If this method is not implemented or under Linux kernel
397 * versions earlier than 2.6.15, the truncate() method will be
398 * called instead.
400 * Introduced in version 2.5
402 int (*ftruncate) (const char *, off_t, struct fuse_file_info *);
405 * Get attributes from an open file
407 * This method is called instead of the getattr() method if the
408 * file information is available.
410 * Currently this is only called after the create() method if that
411 * is implemented (see above). Later it may be called for
412 * invocations of fstat() too.
414 * Introduced in version 2.5
416 int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *);
419 * Perform POSIX file locking operation
421 * The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW.
423 * For the meaning of fields in 'struct flock' see the man page
424 * for fcntl(2). The l_whence field will always be set to
425 * SEEK_SET.
427 * For checking lock ownership, the 'fuse_file_info->owner'
428 * argument must be used.
430 * For F_GETLK operation, the library will first check currently
431 * held locks, and if a conflicting lock is found it will return
432 * information without calling this method. This ensures, that
433 * for local locks the l_pid field is correctly filled in. The
434 * results may not be accurate in case of race conditions and in
435 * the presence of hard links, but it's unlikely that an
436 * application would rely on accurate GETLK results in these
437 * cases. If a conflicting lock is not found, this method will be
438 * called, and the filesystem may fill out l_pid by a meaningful
439 * value, or it may leave this field zero.
441 * For F_SETLK and F_SETLKW the l_pid field will be set to the pid
442 * of the process performing the locking operation.
444 * Note: if this method is not implemented, the kernel will still
445 * allow file locking to work locally. Hence it is only
446 * interesting for network filesystems and similar.
448 * Introduced in version 2.6
450 int (*lock) (const char *, struct fuse_file_info *, int cmd,
451 struct flock *);
454 * Change the access and modification times of a file with
455 * nanosecond resolution
457 * This supersedes the old utime() interface. New applications
458 * should use this.
460 * See the utimensat(2) man page for details.
462 * Introduced in version 2.6
464 int (*utimens) (const char *, const struct timespec tv[2]);
467 * Map block index within file to block index within device
469 * Note: This makes sense only for block device backed filesystems
470 * mounted with the 'blkdev' option
472 * Introduced in version 2.6
474 int (*bmap) (const char *, size_t blocksize, uint64_t *idx);
477 * Ioctl
479 * flags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in
480 * 64bit environment. The size and direction of data is
481 * determined by _IOC_*() decoding of cmd. For _IOC_NONE,
482 * data will be NULL, for _IOC_WRITE data is out area, for
483 * _IOC_READ in area and if both are set in/out area. In all
484 * non-NULL cases, the area is of _IOC_SIZE(cmd) bytes.
486 * If flags has FUSE_IOCTL_DIR then the fuse_file_info refers to a
487 * directory file handle.
489 * Introduced in version 2.8
491 int (*ioctl) (const char *, int cmd, void *arg,
492 struct fuse_file_info *, unsigned int flags, void *data);
495 * Poll for IO readiness events
497 * Note: If ph is non-NULL, the client should notify
498 * when IO readiness events occur by calling
499 * fuse_notify_poll() with the specified ph.
501 * Regardless of the number of times poll with a non-NULL ph
502 * is received, single notification is enough to clear all.
503 * Notifying more times incurs overhead but doesn't harm
504 * correctness.
506 * The callee is responsible for destroying ph with
507 * fuse_pollhandle_destroy() when no longer in use.
509 * Introduced in version 2.8
511 int (*poll) (const char *, struct fuse_file_info *,
512 struct fuse_pollhandle *ph, unsigned *reventsp);
514 /** Write contents of buffer to an open file
516 * Similar to the write() method, but data is supplied in a
517 * generic buffer. Use fuse_buf_copy() to transfer data to
518 * the destination.
520 * Introduced in version 2.9
522 int (*write_buf) (const char *, struct fuse_bufvec *buf, off_t off,
523 struct fuse_file_info *);
525 /** Store data from an open file in a buffer
527 * Similar to the read() method, but data is stored and
528 * returned in a generic buffer.
530 * No actual copying of data has to take place, the source
531 * file descriptor may simply be stored in the buffer for
532 * later data transfer.
534 * The buffer must be allocated dynamically and stored at the
535 * location pointed to by bufp. If the buffer contains memory
536 * regions, they too must be allocated using malloc(). The
537 * allocated memory will be freed by the caller.
539 * Introduced in version 2.9
541 int (*read_buf) (const char *, struct fuse_bufvec **bufp,
542 size_t size, off_t off, struct fuse_file_info *);
544 * Perform BSD file locking operation
546 * The op argument will be either LOCK_SH, LOCK_EX or LOCK_UN
548 * Nonblocking requests will be indicated by ORing LOCK_NB to
549 * the above operations
551 * For more information see the flock(2) manual page.
553 * Additionally fi->owner will be set to a value unique to
554 * this open file. This same value will be supplied to
555 * ->release() when the file is released.
557 * Note: if this method is not implemented, the kernel will still
558 * allow file locking to work locally. Hence it is only
559 * interesting for network filesystems and similar.
561 * Introduced in version 2.9
563 int (*flock) (const char *, struct fuse_file_info *, int op);
566 * Allocates space for an open file
568 * This function ensures that required space is allocated for specified
569 * file. If this function returns success then any subsequent write
570 * request to specified range is guaranteed not to fail because of lack
571 * of space on the file system media.
573 * Introduced in version 2.9.1
575 int (*fallocate) (const char *, int, off_t, off_t,
576 struct fuse_file_info *);
579 /** Extra context that may be needed by some filesystems
581 * The uid, gid and pid fields are not filled in case of a writepage
582 * operation.
584 struct fuse_context {
585 /** Pointer to the fuse object */
586 struct fuse *fuse;
588 /** User ID of the calling process */
589 uid_t uid;
591 /** Group ID of the calling process */
592 gid_t gid;
594 /** Thread ID of the calling process */
595 pid_t pid;
597 /** Private filesystem data */
598 void *private_data;
600 /** Umask of the calling process (introduced in version 2.8) */
601 mode_t umask;
605 * Main function of FUSE.
607 * This is for the lazy. This is all that has to be called from the
608 * main() function.
610 * This function does the following:
611 * - parses command line options (-d -s and -h)
612 * - passes relevant mount options to the fuse_mount()
613 * - installs signal handlers for INT, HUP, TERM and PIPE
614 * - registers an exit handler to unmount the filesystem on program exit
615 * - creates a fuse handle
616 * - registers the operations
617 * - calls either the single-threaded or the multi-threaded event loop
619 * Note: this is currently implemented as a macro.
621 * @param argc the argument counter passed to the main() function
622 * @param argv the argument vector passed to the main() function
623 * @param op the file system operation
624 * @param user_data user data supplied in the context during the init() method
625 * @return 0 on success, nonzero on failure
627 * Example usage, see hello.c
630 int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
631 void *user_data);
633 #define fuse_main(argc, argv, op, user_data) \
634 fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)
636 /* ----------------------------------------------------------- *
637 * More detailed API *
638 * ----------------------------------------------------------- */
641 * Create a new FUSE filesystem.
643 * @param ch the communication channel
644 * @param args argument vector
645 * @param op the filesystem operations
646 * @param op_size the size of the fuse_operations structure
647 * @param user_data user data supplied in the context during the init() method
648 * @return the created FUSE handle
650 struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
651 const struct fuse_operations *op, size_t op_size,
652 void *user_data);
655 * Destroy the FUSE handle.
657 * The communication channel attached to the handle is also destroyed.
659 * NOTE: This function does not unmount the filesystem. If this is
660 * needed, call fuse_unmount() before calling this function.
662 * @param f the FUSE handle
664 void fuse_destroy(struct fuse *f);
667 * FUSE event loop.
669 * Requests from the kernel are processed, and the appropriate
670 * operations are called.
672 * @param f the FUSE handle
673 * @return 0 if no error occurred, -1 otherwise
675 * See also: fuse_loop()
677 int fuse_loop(struct fuse *f);
680 * Exit from event loop
682 * @param f the FUSE handle
684 void fuse_exit(struct fuse *f);
687 * FUSE event loop with multiple threads
689 * Requests from the kernel are processed, and the appropriate
690 * operations are called. Request are processed in parallel by
691 * distributing them between multiple threads.
693 * Calling this function requires the pthreads library to be linked to
694 * the application.
696 * Note: using fuse_loop() instead of fuse_loop_mt() means you are running in
697 * single-threaded mode, and that you will not have to worry about reentrancy,
698 * though you will have to worry about recursive lookups. In single-threaded
699 * mode, FUSE will wait for one callback to return before calling another.
701 * Enabling multiple threads, by using fuse_loop_mt(), will cause FUSE to make
702 * multiple simultaneous calls into the various callback functions given by your
703 * fuse_operations record.
705 * If you are using multiple threads, you can enjoy all the parallel execution
706 * and interactive response benefits of threads, and you get to enjoy all the
707 * benefits of race conditions and locking bugs, too. Ensure that any code used
708 * in the callback funtion of fuse_operations is also thread-safe.
710 * @param f the FUSE handle
711 * @return 0 if no error occurred, -1 otherwise
713 * See also: fuse_loop()
715 int fuse_loop_mt(struct fuse *f);
718 * Get the current context
720 * The context is only valid for the duration of a filesystem
721 * operation, and thus must not be stored and used later.
723 * @return the context
725 struct fuse_context *fuse_get_context(void);
728 * Get the current supplementary group IDs for the current request
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.
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.
738 * This feature may not be supported on all operating systems. In
739 * such a case this function will return -ENOSYS.
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
745 int fuse_getgroups(int size, gid_t list[]);
748 * Check if the current request has already been interrupted
750 * @return 1 if the request has been interrupted, 0 otherwise
752 int fuse_interrupted(void);
755 * The real main function
757 * Do not call this directly, use fuse_main()
759 int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
760 size_t op_size, void *user_data);
763 * Start the cleanup thread when using option "remember".
765 * This is done automatically by fuse_loop_mt()
766 * @param fuse struct fuse pointer for fuse instance
767 * @return 0 on success and -1 on error
769 int fuse_start_cleanup_thread(struct fuse *fuse);
772 * Stop the cleanup thread when using option "remember".
774 * This is done automatically by fuse_loop_mt()
775 * @param fuse struct fuse pointer for fuse instance
777 void fuse_stop_cleanup_thread(struct fuse *fuse);
780 * Iterate over cache removing stale entries
781 * use in conjunction with "-oremember"
783 * NOTE: This is already done for the standard sessions
785 * @param fuse struct fuse pointer for fuse instance
786 * @return the number of seconds until the next cleanup
788 int fuse_clean_cache(struct fuse *fuse);
791 * Stacking API
795 * Fuse filesystem object
797 * This is opaque object represents a filesystem layer
799 struct fuse_fs;
802 * These functions call the relevant filesystem operation, and return
803 * the result.
805 * If the operation is not defined, they return -ENOSYS, with the
806 * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir,
807 * fuse_fs_releasedir and fuse_fs_statfs, which return 0.
810 int fuse_fs_getattr(struct fuse_fs *fs, const char *path, struct stat *buf);
811 int fuse_fs_fgetattr(struct fuse_fs *fs, const char *path, struct stat *buf,
812 struct fuse_file_info *fi);
813 int fuse_fs_rename(struct fuse_fs *fs, const char *oldpath,
814 const char *newpath, unsigned int flags);
815 int fuse_fs_unlink(struct fuse_fs *fs, const char *path);
816 int fuse_fs_rmdir(struct fuse_fs *fs, const char *path);
817 int fuse_fs_symlink(struct fuse_fs *fs, const char *linkname,
818 const char *path);
819 int fuse_fs_link(struct fuse_fs *fs, const char *oldpath, const char *newpath);
820 int fuse_fs_release(struct fuse_fs *fs, const char *path,
821 struct fuse_file_info *fi);
822 int fuse_fs_open(struct fuse_fs *fs, const char *path,
823 struct fuse_file_info *fi);
824 int fuse_fs_read(struct fuse_fs *fs, const char *path, char *buf, size_t size,
825 off_t off, struct fuse_file_info *fi);
826 int fuse_fs_read_buf(struct fuse_fs *fs, const char *path,
827 struct fuse_bufvec **bufp, size_t size, off_t off,
828 struct fuse_file_info *fi);
829 int fuse_fs_write(struct fuse_fs *fs, const char *path, const char *buf,
830 size_t size, off_t off, struct fuse_file_info *fi);
831 int fuse_fs_write_buf(struct fuse_fs *fs, const char *path,
832 struct fuse_bufvec *buf, off_t off,
833 struct fuse_file_info *fi);
834 int fuse_fs_fsync(struct fuse_fs *fs, const char *path, int datasync,
835 struct fuse_file_info *fi);
836 int fuse_fs_flush(struct fuse_fs *fs, const char *path,
837 struct fuse_file_info *fi);
838 int fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf);
839 int fuse_fs_opendir(struct fuse_fs *fs, const char *path,
840 struct fuse_file_info *fi);
841 int fuse_fs_readdir(struct fuse_fs *fs, const char *path, void *buf,
842 fuse_fill_dir_t filler, off_t off,
843 struct fuse_file_info *fi, enum fuse_readdir_flags flags);
844 int fuse_fs_fsyncdir(struct fuse_fs *fs, const char *path, int datasync,
845 struct fuse_file_info *fi);
846 int fuse_fs_releasedir(struct fuse_fs *fs, const char *path,
847 struct fuse_file_info *fi);
848 int fuse_fs_create(struct fuse_fs *fs, const char *path, mode_t mode,
849 struct fuse_file_info *fi);
850 int fuse_fs_lock(struct fuse_fs *fs, const char *path,
851 struct fuse_file_info *fi, int cmd, struct flock *lock);
852 int fuse_fs_flock(struct fuse_fs *fs, const char *path,
853 struct fuse_file_info *fi, int op);
854 int fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode);
855 int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid);
856 int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size);
857 int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, off_t size,
858 struct fuse_file_info *fi);
859 int fuse_fs_utimens(struct fuse_fs *fs, const char *path,
860 const struct timespec tv[2]);
861 int fuse_fs_access(struct fuse_fs *fs, const char *path, int mask);
862 int fuse_fs_readlink(struct fuse_fs *fs, const char *path, char *buf,
863 size_t len);
864 int fuse_fs_mknod(struct fuse_fs *fs, const char *path, mode_t mode,
865 dev_t rdev);
866 int fuse_fs_mkdir(struct fuse_fs *fs, const char *path, mode_t mode);
867 int fuse_fs_setxattr(struct fuse_fs *fs, const char *path, const char *name,
868 const char *value, size_t size, int flags);
869 int fuse_fs_getxattr(struct fuse_fs *fs, const char *path, const char *name,
870 char *value, size_t size);
871 int fuse_fs_listxattr(struct fuse_fs *fs, const char *path, char *list,
872 size_t size);
873 int fuse_fs_removexattr(struct fuse_fs *fs, const char *path,
874 const char *name);
875 int fuse_fs_bmap(struct fuse_fs *fs, const char *path, size_t blocksize,
876 uint64_t *idx);
877 int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, int cmd, void *arg,
878 struct fuse_file_info *fi, unsigned int flags, void *data);
879 int fuse_fs_poll(struct fuse_fs *fs, const char *path,
880 struct fuse_file_info *fi, struct fuse_pollhandle *ph,
881 unsigned *reventsp);
882 int fuse_fs_fallocate(struct fuse_fs *fs, const char *path, int mode,
883 off_t offset, off_t length, struct fuse_file_info *fi);
884 void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn);
885 void fuse_fs_destroy(struct fuse_fs *fs);
887 int fuse_notify_poll(struct fuse_pollhandle *ph);
890 * Create a new fuse filesystem object
892 * This is usually called from the factory of a fuse module to create
893 * a new instance of a filesystem.
895 * @param op the filesystem operations
896 * @param op_size the size of the fuse_operations structure
897 * @param user_data user data supplied in the context during the init() method
898 * @return a new filesystem object
900 struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size,
901 void *user_data);
904 * Factory for creating filesystem objects
906 * The function may use and remove options from 'args' that belong
907 * to this module.
909 * For now the 'fs' vector always contains exactly one filesystem.
910 * This is the filesystem which will be below the newly created
911 * filesystem in the stack.
913 * @param args the command line arguments
914 * @param fs NULL terminated filesystem object vector
915 * @return the new filesystem object
917 typedef struct fuse_fs *(*fuse_module_factory_t)(struct fuse_args *args,
918 struct fuse_fs *fs[]);
920 * Register filesystem module
922 * If the "-omodules=@name_:..." option is present, filesystem
923 * objects are created and pushed onto the stack with the @factory_
924 * function.
926 * @name_ the name of this filesystem module
927 * @factory_ the factory function for this filesystem module
929 #define FUSE_REGISTER_MODULE(name_, factory_) \
930 fuse_module_factory_t fuse_module_ ## name_ ## _factory = factory_;
932 /** Get session from fuse object */
933 struct fuse_session *fuse_get_session(struct fuse *f);
935 #ifdef __cplusplus
937 #endif
939 #endif /* _FUSE_H_ */