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.
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"
23 #include <sys/types.h>
25 #include <sys/statvfs.h>
32 /* ----------------------------------------------------------- *
34 * ----------------------------------------------------------- */
36 /** Handle for a FUSE filesystem */
39 /** Function to add an entry in a readdir() operation
41 * @param buf the buffer passed to the readdir() operation
42 * @param name the file name of the directory entry
43 * @param stat file attributes, can be NULL
44 * @param off offset of the next entry or zero
45 * @return 1 if buffer is full, zero otherwise
47 typedef int (*fuse_fill_dir_t
) (void *buf
, const char *name
,
48 const struct stat
*stbuf
, off_t off
);
51 * The file system operations:
53 * Most of these should work very similarly to the well known UNIX
54 * file system operations. A major exception is that instead of
55 * returning an error in 'errno', the operation should return the
56 * negated error value (-errno) directly.
58 * All methods are optional, but some are essential for a useful
59 * filesystem (e.g. getattr). Open, flush, release, fsync, opendir,
60 * releasedir, fsyncdir, access, create, ftruncate, fgetattr, lock,
61 * init and destroy are special purpose methods, without which a full
62 * featured filesystem can still be implemented.
64 * Almost all operations take a path which can be of any length.
66 * Changed in fuse 2.8.0 (regardless of API version)
67 * Previously, paths were limited to a length of PATH_MAX.
69 * See http://fuse.sourceforge.net/wiki/ for more information. There
70 * is also a snapshot of the relevant wiki pages in the doc/ folder.
72 struct fuse_operations
{
74 * Flag indicating that the path need not be calculated for
75 * the following operations:
77 * read, write, flush, release, fsync, readdir, releasedir,
78 * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
80 * If this flag is set then the path will not be calculaged even if the
81 * file wasn't unlinked. However the path can still be non-NULL if it
82 * needs to be calculated for some other reason.
84 unsigned int flag_nopath
:1;
87 * Reserved flags, don't set
89 unsigned int flag_reserved
:31;
91 /** Get file attributes.
93 * Similar to stat(). The 'st_dev' and 'st_blksize' fields are
94 * ignored. The 'st_ino' field is ignored except if the 'use_ino'
95 * mount option is given.
97 int (*getattr
) (const char *, struct stat
*);
99 /** Read the target of a symbolic link
101 * The buffer should be filled with a null terminated string. The
102 * buffer size argument includes the space for the terminating
103 * null character. If the linkname is too long to fit in the
104 * buffer, it should be truncated. The return value should be 0
107 int (*readlink
) (const char *, char *, size_t);
109 /** Create a file node
111 * This is called for creation of all non-directory, non-symlink
112 * nodes. If the filesystem defines a create() method, then for
113 * regular files that will be called instead.
115 int (*mknod
) (const char *, mode_t
, dev_t
);
117 /** Create a directory
119 * Note that the mode argument may not have the type specification
120 * bits set, i.e. S_ISDIR(mode) can be false. To obtain the
121 * correct directory type bits use mode|S_IFDIR
123 int (*mkdir
) (const char *, mode_t
);
126 int (*unlink
) (const char *);
128 /** Remove a directory */
129 int (*rmdir
) (const char *);
131 /** Create a symbolic link */
132 int (*symlink
) (const char *, const char *);
135 int (*rename
) (const char *, const char *);
137 /** Create a hard link to a file */
138 int (*link
) (const char *, const char *);
140 /** Change the permission bits of a file */
141 int (*chmod
) (const char *, mode_t
);
143 /** Change the owner and group of a file */
144 int (*chown
) (const char *, uid_t
, gid_t
);
146 /** Change the size of a file */
147 int (*truncate
) (const char *, off_t
);
149 /** File open operation
151 * No creation (O_CREAT, O_EXCL) and by default also no
152 * truncation (O_TRUNC) flags will be passed to open(). If an
153 * application specifies O_TRUNC, fuse first calls truncate()
154 * and then open(). Only if 'atomic_o_trunc' has been
155 * specified and kernel version is 2.6.24 or later, O_TRUNC is
158 * Unless the 'default_permissions' mount option is given,
159 * open should check if the operation is permitted for the
160 * given flags. Optionally open may also return an arbitrary
161 * filehandle in the fuse_file_info structure, which will be
162 * passed to all file operations.
164 * Changed in version 2.2
166 int (*open
) (const char *, struct fuse_file_info
*);
168 /** Read data from an open file
170 * Read should return exactly the number of bytes requested except
171 * on EOF or error, otherwise the rest of the data will be
172 * substituted with zeroes. An exception to this is when the
173 * 'direct_io' mount option is specified, in which case the return
174 * value of the read system call will reflect the return value of
177 * Changed in version 2.2
179 int (*read
) (const char *, char *, size_t, off_t
,
180 struct fuse_file_info
*);
182 /** Write data to an open file
184 * Write should return exactly the number of bytes requested
185 * except on error. An exception to this is when the 'direct_io'
186 * mount option is specified (see read operation).
188 * Changed in version 2.2
190 int (*write
) (const char *, const char *, size_t, off_t
,
191 struct fuse_file_info
*);
193 /** Get file system statistics
195 * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored
197 * Replaced 'struct statfs' parameter with 'struct statvfs' in
200 int (*statfs
) (const char *, struct statvfs
*);
202 /** Possibly flush cached data
204 * BIG NOTE: This is not equivalent to fsync(). It's not a
205 * request to sync dirty data.
207 * Flush is called on each close() of a file descriptor. So if a
208 * filesystem wants to return write errors in close() and the file
209 * has cached dirty data, this is a good place to write back data
210 * and return any errors. Since many applications ignore close()
211 * errors this is not always useful.
213 * NOTE: The flush() method may be called more than once for each
214 * open(). This happens if more than one file descriptor refers
215 * to an opened file due to dup(), dup2() or fork() calls. It is
216 * not possible to determine if a flush is final, so each flush
217 * should be treated equally. Multiple write-flush sequences are
218 * relatively rare, so this shouldn't be a problem.
220 * Filesystems shouldn't assume that flush will always be called
221 * after some writes, or that if will be called at all.
223 * Changed in version 2.2
225 int (*flush
) (const char *, struct fuse_file_info
*);
227 /** Release an open file
229 * Release is called when there are no more references to an open
230 * file: all file descriptors are closed and all memory mappings
233 * For every open() call there will be exactly one release() call
234 * with the same flags and file descriptor. It is possible to
235 * have a file opened more than once, in which case only the last
236 * release will mean, that no more reads/writes will happen on the
237 * file. The return value of release is ignored.
239 * Changed in version 2.2
241 int (*release
) (const char *, struct fuse_file_info
*);
243 /** Synchronize file contents
245 * If the datasync parameter is non-zero, then only the user data
246 * should be flushed, not the meta data.
248 * Changed in version 2.2
250 int (*fsync
) (const char *, int, struct fuse_file_info
*);
252 /** Set extended attributes */
253 int (*setxattr
) (const char *, const char *, const char *, size_t, int);
255 /** Get extended attributes */
256 int (*getxattr
) (const char *, const char *, char *, size_t);
258 /** List extended attributes */
259 int (*listxattr
) (const char *, char *, size_t);
261 /** Remove extended attributes */
262 int (*removexattr
) (const char *, const char *);
266 * Unless the 'default_permissions' mount option is given,
267 * this method should check if opendir is permitted for this
268 * directory. Optionally opendir may also return an arbitrary
269 * filehandle in the fuse_file_info structure, which will be
270 * passed to readdir, closedir and fsyncdir.
272 * Introduced in version 2.3
274 int (*opendir
) (const char *, struct fuse_file_info
*);
278 * The filesystem may choose between two modes of operation:
280 * 1) The readdir implementation ignores the offset parameter, and
281 * passes zero to the filler function's offset. The filler
282 * function will not return '1' (unless an error happens), so the
283 * whole directory is read in a single readdir operation.
285 * 2) The readdir implementation keeps track of the offsets of the
286 * directory entries. It uses the offset parameter and always
287 * passes non-zero offset to the filler function. When the buffer
288 * is full (or an error happens) the filler function will return
291 * Introduced in version 2.3
293 int (*readdir
) (const char *, void *, fuse_fill_dir_t
, off_t
,
294 struct fuse_file_info
*);
296 /** Release directory
298 * Introduced in version 2.3
300 int (*releasedir
) (const char *, struct fuse_file_info
*);
302 /** Synchronize directory contents
304 * If the datasync parameter is non-zero, then only the user data
305 * should be flushed, not the meta data
307 * Introduced in version 2.3
309 int (*fsyncdir
) (const char *, int, struct fuse_file_info
*);
312 * Initialize filesystem
314 * The return value will passed in the private_data field of
315 * fuse_context to all file operations and as a parameter to the
318 * Introduced in version 2.3
319 * Changed in version 2.6
321 void *(*init
) (struct fuse_conn_info
*conn
);
324 * Clean up filesystem
326 * Called on filesystem exit.
328 * Introduced in version 2.3
330 void (*destroy
) (void *);
333 * Check file access permissions
335 * This will be called for the access() system call. If the
336 * 'default_permissions' mount option is given, this method is not
339 * This method is not called under Linux kernel versions 2.4.x
341 * Introduced in version 2.5
343 int (*access
) (const char *, int);
346 * Create and open a file
348 * If the file does not exist, first create it with the specified
349 * mode, and then open it.
351 * If this method is not implemented or under Linux kernel
352 * versions earlier than 2.6.15, the mknod() and open() methods
353 * will be called instead.
355 * Introduced in version 2.5
357 int (*create
) (const char *, mode_t
, struct fuse_file_info
*);
360 * Change the size of an open file
362 * This method is called instead of the truncate() method if the
363 * truncation was invoked from an ftruncate() system call.
365 * If this method is not implemented or under Linux kernel
366 * versions earlier than 2.6.15, the truncate() method will be
369 * Introduced in version 2.5
371 int (*ftruncate
) (const char *, off_t
, struct fuse_file_info
*);
374 * Get attributes from an open file
376 * This method is called instead of the getattr() method if the
377 * file information is available.
379 * Currently this is only called after the create() method if that
380 * is implemented (see above). Later it may be called for
381 * invocations of fstat() too.
383 * Introduced in version 2.5
385 int (*fgetattr
) (const char *, struct stat
*, struct fuse_file_info
*);
388 * Perform POSIX file locking operation
390 * The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW.
392 * For the meaning of fields in 'struct flock' see the man page
393 * for fcntl(2). The l_whence field will always be set to
396 * For checking lock ownership, the 'fuse_file_info->owner'
397 * argument must be used.
399 * For F_GETLK operation, the library will first check currently
400 * held locks, and if a conflicting lock is found it will return
401 * information without calling this method. This ensures, that
402 * for local locks the l_pid field is correctly filled in. The
403 * results may not be accurate in case of race conditions and in
404 * the presence of hard links, but it's unlikely that an
405 * application would rely on accurate GETLK results in these
406 * cases. If a conflicting lock is not found, this method will be
407 * called, and the filesystem may fill out l_pid by a meaningful
408 * value, or it may leave this field zero.
410 * For F_SETLK and F_SETLKW the l_pid field will be set to the pid
411 * of the process performing the locking operation.
413 * Note: if this method is not implemented, the kernel will still
414 * allow file locking to work locally. Hence it is only
415 * interesting for network filesystems and similar.
417 * Introduced in version 2.6
419 int (*lock
) (const char *, struct fuse_file_info
*, int cmd
,
423 * Change the access and modification times of a file with
424 * nanosecond resolution
426 * This supersedes the old utime() interface. New applications
429 * See the utimensat(2) man page for details.
431 * Introduced in version 2.6
433 int (*utimens
) (const char *, const struct timespec tv
[2]);
436 * Map block index within file to block index within device
438 * Note: This makes sense only for block device backed filesystems
439 * mounted with the 'blkdev' option
441 * Introduced in version 2.6
443 int (*bmap
) (const char *, size_t blocksize
, uint64_t *idx
);
448 * flags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in
449 * 64bit environment. The size and direction of data is
450 * determined by _IOC_*() decoding of cmd. For _IOC_NONE,
451 * data will be NULL, for _IOC_WRITE data is out area, for
452 * _IOC_READ in area and if both are set in/out area. In all
453 * non-NULL cases, the area is of _IOC_SIZE(cmd) bytes.
455 * Introduced in version 2.8
457 int (*ioctl
) (const char *, int cmd
, void *arg
,
458 struct fuse_file_info
*, unsigned int flags
, void *data
);
461 * Poll for IO readiness events
463 * Note: If ph is non-NULL, the client should notify
464 * when IO readiness events occur by calling
465 * fuse_notify_poll() with the specified ph.
467 * Regardless of the number of times poll with a non-NULL ph
468 * is received, single notification is enough to clear all.
469 * Notifying more times incurs overhead but doesn't harm
472 * The callee is responsible for destroying ph with
473 * fuse_pollhandle_destroy() when no longer in use.
475 * Introduced in version 2.8
477 int (*poll
) (const char *, struct fuse_file_info
*,
478 struct fuse_pollhandle
*ph
, unsigned *reventsp
);
480 /** Write contents of buffer to an open file
482 * Similar to the write() method, but data is supplied in a
483 * generic buffer. Use fuse_buf_copy() to transfer data to
486 * Introduced in version 2.9
488 int (*write_buf
) (const char *, struct fuse_bufvec
*buf
, off_t off
,
489 struct fuse_file_info
*);
491 /** Store data from an open file in a buffer
493 * Similar to the read() method, but data is stored and
494 * returned in a generic buffer.
496 * No actual copying of data has to take place, the source
497 * file descriptor may simply be stored in the buffer for
498 * later data transfer.
500 * The buffer must be allocated dynamically and stored at the
501 * location pointed to by bufp. If the buffer contains memory
502 * regions, they too must be allocated using malloc(). The
503 * allocated memory will be freed by the caller.
505 * Introduced in version 2.9
507 int (*read_buf
) (const char *, struct fuse_bufvec
**bufp
,
508 size_t size
, off_t off
, struct fuse_file_info
*);
510 * Perform BSD file locking operation
512 * The op argument will be either LOCK_SH, LOCK_EX or LOCK_UN
514 * Nonblocking requests will be indicated by ORing LOCK_NB to
515 * the above operations
517 * For more information see the flock(2) manual page.
519 * Additionally fi->owner will be set to a value unique to
520 * this open file. This same value will be supplied to
521 * ->release() when the file is released.
523 * Note: if this method is not implemented, the kernel will still
524 * allow file locking to work locally. Hence it is only
525 * interesting for network filesystems and similar.
527 * Introduced in version 2.9
529 int (*flock
) (const char *, struct fuse_file_info
*, int op
);
532 * Allocates space for an open file
534 * This function ensures that required space is allocated for specified
535 * file. If this function returns success then any subsequent write
536 * request to specified range is guaranteed not to fail because of lack
537 * of space on the file system media.
539 * Introduced in version 2.9.1
541 int (*fallocate
) (const char *, int, off_t
, off_t
,
542 struct fuse_file_info
*);
545 /** Extra context that may be needed by some filesystems
547 * The uid, gid and pid fields are not filled in case of a writepage
550 struct fuse_context
{
551 /** Pointer to the fuse object */
554 /** User ID of the calling process */
557 /** Group ID of the calling process */
560 /** Thread ID of the calling process */
563 /** Private filesystem data */
566 /** Umask of the calling process (introduced in version 2.8) */
571 * Main function of FUSE.
573 * This is for the lazy. This is all that has to be called from the
576 * This function does the following:
577 * - parses command line options (-d -s and -h)
578 * - passes relevant mount options to the fuse_mount()
579 * - installs signal handlers for INT, HUP, TERM and PIPE
580 * - registers an exit handler to unmount the filesystem on program exit
581 * - creates a fuse handle
582 * - registers the operations
583 * - calls either the single-threaded or the multi-threaded event loop
585 * Note: this is currently implemented as a macro.
587 * @param argc the argument counter passed to the main() function
588 * @param argv the argument vector passed to the main() function
589 * @param op the file system operation
590 * @param user_data user data supplied in the context during the init() method
591 * @return 0 on success, nonzero on failure
593 * Example usage, see hello.c
596 int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
599 #define fuse_main(argc, argv, op, user_data) \
600 fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)
602 /* ----------------------------------------------------------- *
603 * More detailed API *
604 * ----------------------------------------------------------- */
607 * Create a new FUSE filesystem.
609 * @param ch the communication channel
610 * @param args argument vector
611 * @param op the filesystem operations
612 * @param op_size the size of the fuse_operations structure
613 * @param user_data user data supplied in the context during the init() method
614 * @return the created FUSE handle
616 struct fuse
*fuse_new(struct fuse_chan
*ch
, struct fuse_args
*args
,
617 const struct fuse_operations
*op
, size_t op_size
,
621 * Destroy the FUSE handle.
623 * The communication channel attached to the handle is also destroyed.
625 * NOTE: This function does not unmount the filesystem. If this is
626 * needed, call fuse_unmount() before calling this function.
628 * @param f the FUSE handle
630 void fuse_destroy(struct fuse
*f
);
635 * Requests from the kernel are processed, and the appropriate
636 * operations are called.
638 * @param f the FUSE handle
639 * @return 0 if no error occurred, -1 otherwise
641 * See also: fuse_loop()
643 int fuse_loop(struct fuse
*f
);
646 * Exit from event loop
648 * @param f the FUSE handle
650 void fuse_exit(struct fuse
*f
);
653 * FUSE event loop with multiple threads
655 * Requests from the kernel are processed, and the appropriate
656 * operations are called. Request are processed in parallel by
657 * distributing them between multiple threads.
659 * Calling this function requires the pthreads library to be linked to
662 * Note: using fuse_loop() instead of fuse_loop_mt() means you are running in
663 * single-threaded mode, and that you will not have to worry about reentrancy,
664 * though you will have to worry about recursive lookups. In single-threaded
665 * mode, FUSE will wait for one callback to return before calling another.
667 * Enabling multiple threads, by using fuse_loop_mt(), will cause FUSE to make
668 * multiple simultaneous calls into the various callback functions given by your
669 * fuse_operations record.
671 * If you are using multiple threads, you can enjoy all the parallel execution
672 * and interactive response benefits of threads, and you get to enjoy all the
673 * benefits of race conditions and locking bugs, too. Ensure that any code used
674 * in the callback funtion of fuse_operations is also thread-safe.
676 * @param f the FUSE handle
677 * @return 0 if no error occurred, -1 otherwise
679 * See also: fuse_loop()
681 int fuse_loop_mt(struct fuse
*f
);
684 * Get the current context
686 * The context is only valid for the duration of a filesystem
687 * operation, and thus must not be stored and used later.
689 * @return the context
691 struct fuse_context
*fuse_get_context(void);
694 * Get the current supplementary group IDs for the current request
696 * Similar to the getgroups(2) system call, except the return value is
697 * always the total number of group IDs, even if it is larger than the
700 * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
701 * the group list to userspace, hence this function needs to parse
702 * "/proc/$TID/task/$TID/status" to get the group IDs.
704 * This feature may not be supported on all operating systems. In
705 * such a case this function will return -ENOSYS.
707 * @param size size of given array
708 * @param list array of group IDs to be filled in
709 * @return the total number of supplementary group IDs or -errno on failure
711 int fuse_getgroups(int size
, gid_t list
[]);
714 * Check if the current request has already been interrupted
716 * @return 1 if the request has been interrupted, 0 otherwise
718 int fuse_interrupted(void);
721 * The real main function
723 * Do not call this directly, use fuse_main()
725 int fuse_main_real(int argc
, char *argv
[], const struct fuse_operations
*op
,
726 size_t op_size
, void *user_data
);
729 * Start the cleanup thread when using option "remember".
731 * This is done automatically by fuse_loop_mt()
732 * @param fuse struct fuse pointer for fuse instance
733 * @return 0 on success and -1 on error
735 int fuse_start_cleanup_thread(struct fuse
*fuse
);
738 * Stop the cleanup thread when using option "remember".
740 * This is done automatically by fuse_loop_mt()
741 * @param fuse struct fuse pointer for fuse instance
743 void fuse_stop_cleanup_thread(struct fuse
*fuse
);
746 * Iterate over cache removing stale entries
747 * use in conjunction with "-oremember"
749 * NOTE: This is already done for the standard sessions
751 * @param fuse struct fuse pointer for fuse instance
752 * @return the number of seconds until the next cleanup
754 int fuse_clean_cache(struct fuse
*fuse
);
761 * Fuse filesystem object
763 * This is opaque object represents a filesystem layer
768 * These functions call the relevant filesystem operation, and return
771 * If the operation is not defined, they return -ENOSYS, with the
772 * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir,
773 * fuse_fs_releasedir and fuse_fs_statfs, which return 0.
776 int fuse_fs_getattr(struct fuse_fs
*fs
, const char *path
, struct stat
*buf
);
777 int fuse_fs_fgetattr(struct fuse_fs
*fs
, const char *path
, struct stat
*buf
,
778 struct fuse_file_info
*fi
);
779 int fuse_fs_rename(struct fuse_fs
*fs
, const char *oldpath
,
780 const char *newpath
);
781 int fuse_fs_unlink(struct fuse_fs
*fs
, const char *path
);
782 int fuse_fs_rmdir(struct fuse_fs
*fs
, const char *path
);
783 int fuse_fs_symlink(struct fuse_fs
*fs
, const char *linkname
,
785 int fuse_fs_link(struct fuse_fs
*fs
, const char *oldpath
, const char *newpath
);
786 int fuse_fs_release(struct fuse_fs
*fs
, const char *path
,
787 struct fuse_file_info
*fi
);
788 int fuse_fs_open(struct fuse_fs
*fs
, const char *path
,
789 struct fuse_file_info
*fi
);
790 int fuse_fs_read(struct fuse_fs
*fs
, const char *path
, char *buf
, size_t size
,
791 off_t off
, struct fuse_file_info
*fi
);
792 int fuse_fs_read_buf(struct fuse_fs
*fs
, const char *path
,
793 struct fuse_bufvec
**bufp
, size_t size
, off_t off
,
794 struct fuse_file_info
*fi
);
795 int fuse_fs_write(struct fuse_fs
*fs
, const char *path
, const char *buf
,
796 size_t size
, off_t off
, struct fuse_file_info
*fi
);
797 int fuse_fs_write_buf(struct fuse_fs
*fs
, const char *path
,
798 struct fuse_bufvec
*buf
, off_t off
,
799 struct fuse_file_info
*fi
);
800 int fuse_fs_fsync(struct fuse_fs
*fs
, const char *path
, int datasync
,
801 struct fuse_file_info
*fi
);
802 int fuse_fs_flush(struct fuse_fs
*fs
, const char *path
,
803 struct fuse_file_info
*fi
);
804 int fuse_fs_statfs(struct fuse_fs
*fs
, const char *path
, struct statvfs
*buf
);
805 int fuse_fs_opendir(struct fuse_fs
*fs
, const char *path
,
806 struct fuse_file_info
*fi
);
807 int fuse_fs_readdir(struct fuse_fs
*fs
, const char *path
, void *buf
,
808 fuse_fill_dir_t filler
, off_t off
,
809 struct fuse_file_info
*fi
);
810 int fuse_fs_fsyncdir(struct fuse_fs
*fs
, const char *path
, int datasync
,
811 struct fuse_file_info
*fi
);
812 int fuse_fs_releasedir(struct fuse_fs
*fs
, const char *path
,
813 struct fuse_file_info
*fi
);
814 int fuse_fs_create(struct fuse_fs
*fs
, const char *path
, mode_t mode
,
815 struct fuse_file_info
*fi
);
816 int fuse_fs_lock(struct fuse_fs
*fs
, const char *path
,
817 struct fuse_file_info
*fi
, int cmd
, struct flock
*lock
);
818 int fuse_fs_flock(struct fuse_fs
*fs
, const char *path
,
819 struct fuse_file_info
*fi
, int op
);
820 int fuse_fs_chmod(struct fuse_fs
*fs
, const char *path
, mode_t mode
);
821 int fuse_fs_chown(struct fuse_fs
*fs
, const char *path
, uid_t uid
, gid_t gid
);
822 int fuse_fs_truncate(struct fuse_fs
*fs
, const char *path
, off_t size
);
823 int fuse_fs_ftruncate(struct fuse_fs
*fs
, const char *path
, off_t size
,
824 struct fuse_file_info
*fi
);
825 int fuse_fs_utimens(struct fuse_fs
*fs
, const char *path
,
826 const struct timespec tv
[2]);
827 int fuse_fs_access(struct fuse_fs
*fs
, const char *path
, int mask
);
828 int fuse_fs_readlink(struct fuse_fs
*fs
, const char *path
, char *buf
,
830 int fuse_fs_mknod(struct fuse_fs
*fs
, const char *path
, mode_t mode
,
832 int fuse_fs_mkdir(struct fuse_fs
*fs
, const char *path
, mode_t mode
);
833 int fuse_fs_setxattr(struct fuse_fs
*fs
, const char *path
, const char *name
,
834 const char *value
, size_t size
, int flags
);
835 int fuse_fs_getxattr(struct fuse_fs
*fs
, const char *path
, const char *name
,
836 char *value
, size_t size
);
837 int fuse_fs_listxattr(struct fuse_fs
*fs
, const char *path
, char *list
,
839 int fuse_fs_removexattr(struct fuse_fs
*fs
, const char *path
,
841 int fuse_fs_bmap(struct fuse_fs
*fs
, const char *path
, size_t blocksize
,
843 int fuse_fs_ioctl(struct fuse_fs
*fs
, const char *path
, int cmd
, void *arg
,
844 struct fuse_file_info
*fi
, unsigned int flags
, void *data
);
845 int fuse_fs_poll(struct fuse_fs
*fs
, const char *path
,
846 struct fuse_file_info
*fi
, struct fuse_pollhandle
*ph
,
848 int fuse_fs_fallocate(struct fuse_fs
*fs
, const char *path
, int mode
,
849 off_t offset
, off_t length
, struct fuse_file_info
*fi
);
850 void fuse_fs_init(struct fuse_fs
*fs
, struct fuse_conn_info
*conn
);
851 void fuse_fs_destroy(struct fuse_fs
*fs
);
853 int fuse_notify_poll(struct fuse_pollhandle
*ph
);
856 * Create a new fuse filesystem object
858 * This is usually called from the factory of a fuse module to create
859 * a new instance of a filesystem.
861 * @param op the filesystem operations
862 * @param op_size the size of the fuse_operations structure
863 * @param user_data user data supplied in the context during the init() method
864 * @return a new filesystem object
866 struct fuse_fs
*fuse_fs_new(const struct fuse_operations
*op
, size_t op_size
,
870 * Factory for creating filesystem objects
872 * The function may use and remove options from 'args' that belong
875 * For now the 'fs' vector always contains exactly one filesystem.
876 * This is the filesystem which will be below the newly created
877 * filesystem in the stack.
879 * @param args the command line arguments
880 * @param fs NULL terminated filesystem object vector
881 * @return the new filesystem object
883 typedef struct fuse_fs
*(*fuse_module_factory_t
)(struct fuse_args
*args
,
884 struct fuse_fs
*fs
[]);
886 * Register filesystem module
888 * If the "-omodules=@name_:..." option is present, filesystem
889 * objects are created and pushed onto the stack with the @factory_
892 * @name_ the name of this filesystem module
893 * @factory_ the factory function for this filesystem module
895 #define FUSE_REGISTER_MODULE(name_, factory_) \
896 fuse_module_factory_t fuse_module_ ## name_ ## _factory = factory_;
898 /** Get session from fuse object */
899 struct fuse_session
*fuse_get_session(struct fuse
*f
);
905 #endif /* _FUSE_H_ */