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"
24 #include <sys/types.h>
26 #include <sys/statvfs.h>
33 /* ----------------------------------------------------------- *
35 * ----------------------------------------------------------- */
37 /** Handle for a FUSE filesystem */
40 /** Structure containing a raw command */
43 /** Function to add an entry in a readdir() operation
45 * @param buf the buffer passed to the readdir() operation
46 * @param name the file name of the directory entry
47 * @param stat file attributes, can be NULL
48 * @param off offset of the next entry or zero
49 * @return 1 if buffer is full, zero otherwise
51 typedef int (*fuse_fill_dir_t
) (void *buf
, const char *name
,
52 const struct stat
*stbuf
, off_t off
);
54 /* Used by deprecated getdir() method */
55 typedef struct fuse_dirhandle
*fuse_dirh_t
;
56 typedef int (*fuse_dirfil_t
) (fuse_dirh_t h
, const char *name
, int type
,
60 * The file system operations:
62 * Most of these should work very similarly to the well known UNIX
63 * file system operations. A major exception is that instead of
64 * returning an error in 'errno', the operation should return the
65 * negated error value (-errno) directly.
67 * All methods are optional, but some are essential for a useful
68 * filesystem (e.g. getattr). Open, flush, release, fsync, opendir,
69 * releasedir, fsyncdir, access, create, ftruncate, fgetattr, lock,
70 * init and destroy are special purpose methods, without which a full
71 * featured filesystem can still be implemented.
73 * Almost all operations take a path which can be of any length.
75 * Changed in fuse 2.8.0 (regardless of API version)
76 * Previously, paths were limited to a length of PATH_MAX.
78 * See http://fuse.sourceforge.net/wiki/ for more information. There
79 * is also a snapshot of the relevant wiki pages in the doc/ folder.
81 struct fuse_operations
{
83 * Flag indicating that the path need not be calculated for
84 * the following operations:
86 * read, write, flush, release, fsync, readdir, releasedir,
87 * fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
89 * If this flag is set then the path will not be calculaged even if the
90 * file wasn't unlinked. However the path can still be non-NULL if it
91 * needs to be calculated for some other reason.
93 unsigned int flag_nopath
:1;
96 * Flag indicating that the filesystem accepts special
97 * UTIME_NOW and UTIME_OMIT values in its utimens operation.
99 unsigned int flag_utime_omit_ok
:1;
102 * Reserved flags, don't set
104 unsigned int flag_reserved
:30;
106 /** Get file attributes.
108 * Similar to stat(). The 'st_dev' and 'st_blksize' fields are
109 * ignored. The 'st_ino' field is ignored except if the 'use_ino'
110 * mount option is given.
112 int (*getattr
) (const char *, struct stat
*);
114 /** Read the target of a symbolic link
116 * The buffer should be filled with a null terminated string. The
117 * buffer size argument includes the space for the terminating
118 * null character. If the linkname is too long to fit in the
119 * buffer, it should be truncated. The return value should be 0
122 int (*readlink
) (const char *, char *, size_t);
124 /* Deprecated, use readdir() instead */
125 int (*getdir
) (const char *, fuse_dirh_t
, fuse_dirfil_t
);
127 /** Create a file node
129 * This is called for creation of all non-directory, non-symlink
130 * nodes. If the filesystem defines a create() method, then for
131 * regular files that will be called instead.
133 int (*mknod
) (const char *, mode_t
, dev_t
);
135 /** Create a directory
137 * Note that the mode argument may not have the type specification
138 * bits set, i.e. S_ISDIR(mode) can be false. To obtain the
139 * correct directory type bits use mode|S_IFDIR
141 int (*mkdir
) (const char *, mode_t
);
144 int (*unlink
) (const char *);
146 /** Remove a directory */
147 int (*rmdir
) (const char *);
149 /** Create a symbolic link */
150 int (*symlink
) (const char *, const char *);
153 int (*rename
) (const char *, const char *);
155 /** Create a hard link to a file */
156 int (*link
) (const char *, const char *);
158 /** Change the permission bits of a file */
159 int (*chmod
) (const char *, mode_t
);
161 /** Change the owner and group of a file */
162 int (*chown
) (const char *, uid_t
, gid_t
);
164 /** Change the size of a file */
165 int (*truncate
) (const char *, off_t
);
167 /** Change the access and/or modification times of a file
169 * Deprecated, use utimens() instead.
171 int (*utime
) (const char *, struct utimbuf
*);
173 /** File open operation
175 * No creation (O_CREAT, O_EXCL) and by default also no
176 * truncation (O_TRUNC) flags will be passed to open(). If an
177 * application specifies O_TRUNC, fuse first calls truncate()
178 * and then open(). Only if 'atomic_o_trunc' has been
179 * specified and kernel version is 2.6.24 or later, O_TRUNC is
182 * Unless the 'default_permissions' mount option is given,
183 * open should check if the operation is permitted for the
184 * given flags. Optionally open may also return an arbitrary
185 * filehandle in the fuse_file_info structure, which will be
186 * passed to all file operations.
188 * Changed in version 2.2
190 int (*open
) (const char *, struct fuse_file_info
*);
192 /** Read data from an open file
194 * Read should return exactly the number of bytes requested except
195 * on EOF or error, otherwise the rest of the data will be
196 * substituted with zeroes. An exception to this is when the
197 * 'direct_io' mount option is specified, in which case the return
198 * value of the read system call will reflect the return value of
201 * Changed in version 2.2
203 int (*read
) (const char *, char *, size_t, off_t
,
204 struct fuse_file_info
*);
206 /** Write data to an open file
208 * Write should return exactly the number of bytes requested
209 * except on error. An exception to this is when the 'direct_io'
210 * mount option is specified (see read operation).
212 * Changed in version 2.2
214 int (*write
) (const char *, const char *, size_t, off_t
,
215 struct fuse_file_info
*);
217 /** Get file system statistics
219 * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored
221 * Replaced 'struct statfs' parameter with 'struct statvfs' in
224 int (*statfs
) (const char *, struct statvfs
*);
226 /** Possibly flush cached data
228 * BIG NOTE: This is not equivalent to fsync(). It's not a
229 * request to sync dirty data.
231 * Flush is called on each close() of a file descriptor. So if a
232 * filesystem wants to return write errors in close() and the file
233 * has cached dirty data, this is a good place to write back data
234 * and return any errors. Since many applications ignore close()
235 * errors this is not always useful.
237 * NOTE: The flush() method may be called more than once for each
238 * open(). This happens if more than one file descriptor refers
239 * to an opened file due to dup(), dup2() or fork() calls. It is
240 * not possible to determine if a flush is final, so each flush
241 * should be treated equally. Multiple write-flush sequences are
242 * relatively rare, so this shouldn't be a problem.
244 * Filesystems shouldn't assume that flush will always be called
245 * after some writes, or that if will be called at all.
247 * Changed in version 2.2
249 int (*flush
) (const char *, struct fuse_file_info
*);
251 /** Release an open file
253 * Release is called when there are no more references to an open
254 * file: all file descriptors are closed and all memory mappings
257 * For every open() call there will be exactly one release() call
258 * with the same flags and file descriptor. It is possible to
259 * have a file opened more than once, in which case only the last
260 * release will mean, that no more reads/writes will happen on the
261 * file. The return value of release is ignored.
263 * Changed in version 2.2
265 int (*release
) (const char *, struct fuse_file_info
*);
267 /** Synchronize file contents
269 * If the datasync parameter is non-zero, then only the user data
270 * should be flushed, not the meta data.
272 * Changed in version 2.2
274 int (*fsync
) (const char *, int, struct fuse_file_info
*);
276 /** Set extended attributes */
277 int (*setxattr
) (const char *, const char *, const char *, size_t, int);
279 /** Get extended attributes */
280 int (*getxattr
) (const char *, const char *, char *, size_t);
282 /** List extended attributes */
283 int (*listxattr
) (const char *, char *, size_t);
285 /** Remove extended attributes */
286 int (*removexattr
) (const char *, const char *);
290 * Unless the 'default_permissions' mount option is given,
291 * this method should check if opendir is permitted for this
292 * directory. Optionally opendir may also return an arbitrary
293 * filehandle in the fuse_file_info structure, which will be
294 * passed to readdir, closedir and fsyncdir.
296 * Introduced in version 2.3
298 int (*opendir
) (const char *, struct fuse_file_info
*);
302 * This supersedes the old getdir() interface. New applications
305 * The filesystem may choose between two modes of operation:
307 * 1) The readdir implementation ignores the offset parameter, and
308 * passes zero to the filler function's offset. The filler
309 * function will not return '1' (unless an error happens), so the
310 * whole directory is read in a single readdir operation. This
311 * works just like the old getdir() method.
313 * 2) The readdir implementation keeps track of the offsets of the
314 * directory entries. It uses the offset parameter and always
315 * passes non-zero offset to the filler function. When the buffer
316 * is full (or an error happens) the filler function will return
319 * Introduced in version 2.3
321 int (*readdir
) (const char *, void *, fuse_fill_dir_t
, off_t
,
322 struct fuse_file_info
*);
324 /** Release directory
326 * Introduced in version 2.3
328 int (*releasedir
) (const char *, struct fuse_file_info
*);
330 /** Synchronize directory contents
332 * If the datasync parameter is non-zero, then only the user data
333 * should be flushed, not the meta data
335 * Introduced in version 2.3
337 int (*fsyncdir
) (const char *, int, struct fuse_file_info
*);
340 * Initialize filesystem
342 * The return value will passed in the private_data field of
343 * fuse_context to all file operations and as a parameter to the
346 * Introduced in version 2.3
347 * Changed in version 2.6
349 void *(*init
) (struct fuse_conn_info
*conn
);
352 * Clean up filesystem
354 * Called on filesystem exit.
356 * Introduced in version 2.3
358 void (*destroy
) (void *);
361 * Check file access permissions
363 * This will be called for the access() system call. If the
364 * 'default_permissions' mount option is given, this method is not
367 * This method is not called under Linux kernel versions 2.4.x
369 * Introduced in version 2.5
371 int (*access
) (const char *, int);
374 * Create and open a file
376 * If the file does not exist, first create it with the specified
377 * mode, and then open it.
379 * If this method is not implemented or under Linux kernel
380 * versions earlier than 2.6.15, the mknod() and open() methods
381 * will be called instead.
383 * Introduced in version 2.5
385 int (*create
) (const char *, mode_t
, struct fuse_file_info
*);
388 * Change the size of an open file
390 * This method is called instead of the truncate() method if the
391 * truncation was invoked from an ftruncate() system call.
393 * If this method is not implemented or under Linux kernel
394 * versions earlier than 2.6.15, the truncate() method will be
397 * Introduced in version 2.5
399 int (*ftruncate
) (const char *, off_t
, struct fuse_file_info
*);
402 * Get attributes from an open file
404 * This method is called instead of the getattr() method if the
405 * file information is available.
407 * Currently this is only called after the create() method if that
408 * is implemented (see above). Later it may be called for
409 * invocations of fstat() too.
411 * Introduced in version 2.5
413 int (*fgetattr
) (const char *, struct stat
*, struct fuse_file_info
*);
416 * Perform POSIX file locking operation
418 * The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW.
420 * For the meaning of fields in 'struct flock' see the man page
421 * for fcntl(2). The l_whence field will always be set to
424 * For checking lock ownership, the 'fuse_file_info->owner'
425 * argument must be used.
427 * For F_GETLK operation, the library will first check currently
428 * held locks, and if a conflicting lock is found it will return
429 * information without calling this method. This ensures, that
430 * for local locks the l_pid field is correctly filled in. The
431 * results may not be accurate in case of race conditions and in
432 * the presence of hard links, but it's unlikely that an
433 * application would rely on accurate GETLK results in these
434 * cases. If a conflicting lock is not found, this method will be
435 * called, and the filesystem may fill out l_pid by a meaningful
436 * value, or it may leave this field zero.
438 * For F_SETLK and F_SETLKW the l_pid field will be set to the pid
439 * of the process performing the locking operation.
441 * Note: if this method is not implemented, the kernel will still
442 * allow file locking to work locally. Hence it is only
443 * interesting for network filesystems and similar.
445 * Introduced in version 2.6
447 int (*lock
) (const char *, struct fuse_file_info
*, int cmd
,
451 * Change the access and modification times of a file with
452 * nanosecond resolution
454 * This supersedes the old utime() interface. New applications
457 * See the utimensat(2) man page for details.
459 * Introduced in version 2.6
461 int (*utimens
) (const char *, const struct timespec tv
[2]);
464 * Map block index within file to block index within device
466 * Note: This makes sense only for block device backed filesystems
467 * mounted with the 'blkdev' option
469 * Introduced in version 2.6
471 int (*bmap
) (const char *, size_t blocksize
, uint64_t *idx
);
476 * flags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in
477 * 64bit environment. The size and direction of data is
478 * determined by _IOC_*() decoding of cmd. For _IOC_NONE,
479 * data will be NULL, for _IOC_WRITE data is out area, for
480 * _IOC_READ in area and if both are set in/out area. In all
481 * non-NULL cases, the area is of _IOC_SIZE(cmd) bytes.
483 * Introduced in version 2.8
485 int (*ioctl
) (const char *, int cmd
, void *arg
,
486 struct fuse_file_info
*, unsigned int flags
, void *data
);
489 * Poll for IO readiness events
491 * Note: If ph is non-NULL, the client should notify
492 * when IO readiness events occur by calling
493 * fuse_notify_poll() with the specified ph.
495 * Regardless of the number of times poll with a non-NULL ph
496 * is received, single notification is enough to clear all.
497 * Notifying more times incurs overhead but doesn't harm
500 * The callee is responsible for destroying ph with
501 * fuse_pollhandle_destroy() when no longer in use.
503 * Introduced in version 2.8
505 int (*poll
) (const char *, struct fuse_file_info
*,
506 struct fuse_pollhandle
*ph
, unsigned *reventsp
);
508 /** Write contents of buffer to an open file
510 * Similar to the write() method, but data is supplied in a
511 * generic buffer. Use fuse_buf_copy() to transfer data to
514 * Introduced in version 2.9
516 int (*write_buf
) (const char *, struct fuse_bufvec
*buf
, off_t off
,
517 struct fuse_file_info
*);
519 /** Store data from an open file in a buffer
521 * Similar to the read() method, but data is stored and
522 * returned in a generic buffer.
524 * No actual copying of data has to take place, the source
525 * file descriptor may simply be stored in the buffer for
526 * later data transfer.
528 * The buffer must be allocated dynamically and stored at the
529 * location pointed to by bufp. If the buffer contains memory
530 * regions, they too must be allocated using malloc(). The
531 * allocated memory will be freed by the caller.
533 * Introduced in version 2.9
535 int (*read_buf
) (const char *, struct fuse_bufvec
**bufp
,
536 size_t size
, off_t off
, struct fuse_file_info
*);
538 * Perform BSD file locking operation
540 * The op argument will be either LOCK_SH, LOCK_EX or LOCK_UN
542 * Nonblocking requests will be indicated by ORing LOCK_NB to
543 * the above operations
545 * For more information see the flock(2) manual page.
547 * Additionally fi->owner will be set to a value unique to
548 * this open file. This same value will be supplied to
549 * ->release() when the file is released.
551 * Note: if this method is not implemented, the kernel will still
552 * allow file locking to work locally. Hence it is only
553 * interesting for network filesystems and similar.
555 * Introduced in version 2.9
557 int (*flock
) (const char *, struct fuse_file_info
*, int op
);
560 * Allocates space for an open file
562 * This function ensures that required space is allocated for specified
563 * file. If this function returns success then any subsequent write
564 * request to specified range is guaranteed not to fail because of lack
565 * of space on the file system media.
567 * Introduced in version 2.9.1
569 int (*fallocate
) (const char *, int, off_t
, off_t
,
570 struct fuse_file_info
*);
573 /** Extra context that may be needed by some filesystems
575 * The uid, gid and pid fields are not filled in case of a writepage
578 struct fuse_context
{
579 /** Pointer to the fuse object */
582 /** User ID of the calling process */
585 /** Group ID of the calling process */
588 /** Thread ID of the calling process */
591 /** Private filesystem data */
594 /** Umask of the calling process (introduced in version 2.8) */
599 * Main function of FUSE.
601 * This is for the lazy. This is all that has to be called from the
604 * This function does the following:
605 * - parses command line options (-d -s and -h)
606 * - passes relevant mount options to the fuse_mount()
607 * - installs signal handlers for INT, HUP, TERM and PIPE
608 * - registers an exit handler to unmount the filesystem on program exit
609 * - creates a fuse handle
610 * - registers the operations
611 * - calls either the single-threaded or the multi-threaded event loop
613 * Note: this is currently implemented as a macro.
615 * @param argc the argument counter passed to the main() function
616 * @param argv the argument vector passed to the main() function
617 * @param op the file system operation
618 * @param user_data user data supplied in the context during the init() method
619 * @return 0 on success, nonzero on failure
622 int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
625 #define fuse_main(argc, argv, op, user_data) \
626 fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)
628 /* ----------------------------------------------------------- *
629 * More detailed API *
630 * ----------------------------------------------------------- */
633 * Create a new FUSE filesystem.
635 * @param ch the communication channel
636 * @param args argument vector
637 * @param op the filesystem operations
638 * @param op_size the size of the fuse_operations structure
639 * @param user_data user data supplied in the context during the init() method
640 * @return the created FUSE handle
642 struct fuse
*fuse_new(struct fuse_chan
*ch
, struct fuse_args
*args
,
643 const struct fuse_operations
*op
, size_t op_size
,
647 * Destroy the FUSE handle.
649 * The communication channel attached to the handle is also destroyed.
651 * NOTE: This function does not unmount the filesystem. If this is
652 * needed, call fuse_unmount() before calling this function.
654 * @param f the FUSE handle
656 void fuse_destroy(struct fuse
*f
);
661 * Requests from the kernel are processed, and the appropriate
662 * operations are called.
664 * @param f the FUSE handle
665 * @return 0 if no error occurred, -1 otherwise
667 int fuse_loop(struct fuse
*f
);
670 * Exit from event loop
672 * @param f the FUSE handle
674 void fuse_exit(struct fuse
*f
);
677 * FUSE event loop with multiple threads
679 * Requests from the kernel are processed, and the appropriate
680 * operations are called. Request are processed in parallel by
681 * distributing them between multiple threads.
683 * Calling this function requires the pthreads library to be linked to
686 * @param f the FUSE handle
687 * @return 0 if no error occurred, -1 otherwise
689 int fuse_loop_mt(struct fuse
*f
);
692 * Get the current context
694 * The context is only valid for the duration of a filesystem
695 * operation, and thus must not be stored and used later.
697 * @return the context
699 struct fuse_context
*fuse_get_context(void);
702 * Get the current supplementary group IDs for the current request
704 * Similar to the getgroups(2) system call, except the return value is
705 * always the total number of group IDs, even if it is larger than the
708 * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
709 * the group list to userspace, hence this function needs to parse
710 * "/proc/$TID/task/$TID/status" to get the group IDs.
712 * This feature may not be supported on all operating systems. In
713 * such a case this function will return -ENOSYS.
715 * @param size size of given array
716 * @param list array of group IDs to be filled in
717 * @return the total number of supplementary group IDs or -errno on failure
719 int fuse_getgroups(int size
, gid_t list
[]);
722 * Check if the current request has already been interrupted
724 * @return 1 if the request has been interrupted, 0 otherwise
726 int fuse_interrupted(void);
729 * Obsolete, doesn't do anything
733 int fuse_invalidate(struct fuse
*f
, const char *path
);
735 /* Deprecated, don't use */
736 int fuse_is_lib_option(const char *opt
);
739 * The real main function
741 * Do not call this directly, use fuse_main()
743 int fuse_main_real(int argc
, char *argv
[], const struct fuse_operations
*op
,
744 size_t op_size
, void *user_data
);
747 * Start the cleanup thread when using option "remember".
749 * This is done automatically by fuse_loop_mt()
750 * @param fuse struct fuse pointer for fuse instance
751 * @return 0 on success and -1 on error
753 int fuse_start_cleanup_thread(struct fuse
*fuse
);
756 * Stop the cleanup thread when using option "remember".
758 * This is done automatically by fuse_loop_mt()
759 * @param fuse struct fuse pointer for fuse instance
761 void fuse_stop_cleanup_thread(struct fuse
*fuse
);
764 * Iterate over cache removing stale entries
765 * use in conjunction with "-oremember"
767 * NOTE: This is already done for the standard sessions
769 * @param fuse struct fuse pointer for fuse instance
770 * @return the number of seconds until the next cleanup
772 int fuse_clean_cache(struct fuse
*fuse
);
779 * Fuse filesystem object
781 * This is opaque object represents a filesystem layer
786 * These functions call the relevant filesystem operation, and return
789 * If the operation is not defined, they return -ENOSYS, with the
790 * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir,
791 * fuse_fs_releasedir and fuse_fs_statfs, which return 0.
794 int fuse_fs_getattr(struct fuse_fs
*fs
, const char *path
, struct stat
*buf
);
795 int fuse_fs_fgetattr(struct fuse_fs
*fs
, const char *path
, struct stat
*buf
,
796 struct fuse_file_info
*fi
);
797 int fuse_fs_rename(struct fuse_fs
*fs
, const char *oldpath
,
798 const char *newpath
);
799 int fuse_fs_unlink(struct fuse_fs
*fs
, const char *path
);
800 int fuse_fs_rmdir(struct fuse_fs
*fs
, const char *path
);
801 int fuse_fs_symlink(struct fuse_fs
*fs
, const char *linkname
,
803 int fuse_fs_link(struct fuse_fs
*fs
, const char *oldpath
, const char *newpath
);
804 int fuse_fs_release(struct fuse_fs
*fs
, const char *path
,
805 struct fuse_file_info
*fi
);
806 int fuse_fs_open(struct fuse_fs
*fs
, const char *path
,
807 struct fuse_file_info
*fi
);
808 int fuse_fs_read(struct fuse_fs
*fs
, const char *path
, char *buf
, size_t size
,
809 off_t off
, struct fuse_file_info
*fi
);
810 int fuse_fs_read_buf(struct fuse_fs
*fs
, const char *path
,
811 struct fuse_bufvec
**bufp
, size_t size
, off_t off
,
812 struct fuse_file_info
*fi
);
813 int fuse_fs_write(struct fuse_fs
*fs
, const char *path
, const char *buf
,
814 size_t size
, off_t off
, struct fuse_file_info
*fi
);
815 int fuse_fs_write_buf(struct fuse_fs
*fs
, const char *path
,
816 struct fuse_bufvec
*buf
, off_t off
,
817 struct fuse_file_info
*fi
);
818 int fuse_fs_fsync(struct fuse_fs
*fs
, const char *path
, int datasync
,
819 struct fuse_file_info
*fi
);
820 int fuse_fs_flush(struct fuse_fs
*fs
, const char *path
,
821 struct fuse_file_info
*fi
);
822 int fuse_fs_statfs(struct fuse_fs
*fs
, const char *path
, struct statvfs
*buf
);
823 int fuse_fs_opendir(struct fuse_fs
*fs
, const char *path
,
824 struct fuse_file_info
*fi
);
825 int fuse_fs_readdir(struct fuse_fs
*fs
, const char *path
, void *buf
,
826 fuse_fill_dir_t filler
, off_t off
,
827 struct fuse_file_info
*fi
);
828 int fuse_fs_fsyncdir(struct fuse_fs
*fs
, const char *path
, int datasync
,
829 struct fuse_file_info
*fi
);
830 int fuse_fs_releasedir(struct fuse_fs
*fs
, const char *path
,
831 struct fuse_file_info
*fi
);
832 int fuse_fs_create(struct fuse_fs
*fs
, const char *path
, mode_t mode
,
833 struct fuse_file_info
*fi
);
834 int fuse_fs_lock(struct fuse_fs
*fs
, const char *path
,
835 struct fuse_file_info
*fi
, int cmd
, struct flock
*lock
);
836 int fuse_fs_flock(struct fuse_fs
*fs
, const char *path
,
837 struct fuse_file_info
*fi
, int op
);
838 int fuse_fs_chmod(struct fuse_fs
*fs
, const char *path
, mode_t mode
);
839 int fuse_fs_chown(struct fuse_fs
*fs
, const char *path
, uid_t uid
, gid_t gid
);
840 int fuse_fs_truncate(struct fuse_fs
*fs
, const char *path
, off_t size
);
841 int fuse_fs_ftruncate(struct fuse_fs
*fs
, const char *path
, off_t size
,
842 struct fuse_file_info
*fi
);
843 int fuse_fs_utimens(struct fuse_fs
*fs
, const char *path
,
844 const struct timespec tv
[2]);
845 int fuse_fs_access(struct fuse_fs
*fs
, const char *path
, int mask
);
846 int fuse_fs_readlink(struct fuse_fs
*fs
, const char *path
, char *buf
,
848 int fuse_fs_mknod(struct fuse_fs
*fs
, const char *path
, mode_t mode
,
850 int fuse_fs_mkdir(struct fuse_fs
*fs
, const char *path
, mode_t mode
);
851 int fuse_fs_setxattr(struct fuse_fs
*fs
, const char *path
, const char *name
,
852 const char *value
, size_t size
, int flags
);
853 int fuse_fs_getxattr(struct fuse_fs
*fs
, const char *path
, const char *name
,
854 char *value
, size_t size
);
855 int fuse_fs_listxattr(struct fuse_fs
*fs
, const char *path
, char *list
,
857 int fuse_fs_removexattr(struct fuse_fs
*fs
, const char *path
,
859 int fuse_fs_bmap(struct fuse_fs
*fs
, const char *path
, size_t blocksize
,
861 int fuse_fs_ioctl(struct fuse_fs
*fs
, const char *path
, int cmd
, void *arg
,
862 struct fuse_file_info
*fi
, unsigned int flags
, void *data
);
863 int fuse_fs_poll(struct fuse_fs
*fs
, const char *path
,
864 struct fuse_file_info
*fi
, struct fuse_pollhandle
*ph
,
866 int fuse_fs_fallocate(struct fuse_fs
*fs
, const char *path
, int mode
,
867 off_t offset
, off_t length
, struct fuse_file_info
*fi
);
868 void fuse_fs_init(struct fuse_fs
*fs
, struct fuse_conn_info
*conn
);
869 void fuse_fs_destroy(struct fuse_fs
*fs
);
871 int fuse_notify_poll(struct fuse_pollhandle
*ph
);
874 * Create a new fuse filesystem object
876 * This is usually called from the factory of a fuse module to create
877 * a new instance of a filesystem.
879 * @param op the filesystem operations
880 * @param op_size the size of the fuse_operations structure
881 * @param user_data user data supplied in the context during the init() method
882 * @return a new filesystem object
884 struct fuse_fs
*fuse_fs_new(const struct fuse_operations
*op
, size_t op_size
,
890 * Filesystem modules are registered with the FUSE_REGISTER_MODULE()
893 * If the "-omodules=modname:..." option is present, filesystem
894 * objects are created and pushed onto the stack with the 'factory'
904 * Factory for creating filesystem objects
906 * The function may use and remove options from 'args' that belong
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 struct fuse_fs
*(*factory
)(struct fuse_args
*args
,
918 struct fuse_fs
*fs
[]);
920 struct fuse_module
*next
;
921 struct fusemod_so
*so
;
926 * Register a filesystem module
928 * This function is used by FUSE_REGISTER_MODULE and there's usually
929 * no need to call it directly
931 void fuse_register_module(struct fuse_module
*mod
);
934 * Register filesystem module
936 * For the parameters, see description of the fields in 'struct
939 #define FUSE_REGISTER_MODULE(name_, factory_) \
940 static __attribute__((constructor)) void name_ ## _register(void) \
942 static struct fuse_module mod = \
943 { #name_, factory_, NULL, NULL, 0 }; \
944 fuse_register_module(&mod); \
948 /* ----------------------------------------------------------- *
949 * Advanced API for event handling, don't worry about this... *
950 * ----------------------------------------------------------- */
952 /* NOTE: the following functions are deprecated, and will be removed
953 from the 3.0 API. Use the lowlevel session functions instead */
955 /** Function type used to process commands */
956 typedef void (*fuse_processor_t
)(struct fuse
*, struct fuse_cmd
*, void *);
958 /** This is the part of fuse_main() before the event loop */
959 struct fuse
*fuse_setup(int argc
, char *argv
[],
960 const struct fuse_operations
*op
, size_t op_size
,
961 char **mountpoint
, int *multithreaded
,
964 /** This is the part of fuse_main() after the event loop */
965 void fuse_teardown(struct fuse
*fuse
, char *mountpoint
);
967 /** Read a single command. If none are read, return NULL */
968 struct fuse_cmd
*fuse_read_cmd(struct fuse
*f
);
970 /** Process a single command */
971 void fuse_process_cmd(struct fuse
*f
, struct fuse_cmd
*cmd
);
973 /** Multi threaded event loop, which calls the custom command
974 processor function */
975 int fuse_loop_mt_proc(struct fuse
*f
, fuse_processor_t proc
, void *data
);
977 /** Return the exited flag, which indicates if fuse_exit() has been
979 int fuse_exited(struct fuse
*f
);
981 /** This function is obsolete and implemented as a no-op */
982 void fuse_set_getcontext_func(struct fuse_context
*(*func
)(void));
984 /** Get session from fuse object */
985 struct fuse_session
*fuse_get_session(struct fuse
*f
);
991 #endif /* _FUSE_H_ */