📄 fuse.h
字号:
* If this method is not implemented or under Linux kernel * versions earlier than 2.6.15, the mknod() and open() methods * will be called instead. * * Introduced in version 2.5 */ int (*create) (const char *, mode_t, struct fuse_file_info *); /** * Change the size of an open file * * This method is called instead of the truncate() method if the * truncation was invoked from an ftruncate() system call. * * If this method is not implemented or under Linux kernel * versions earlier than 2.6.15, the truncate() method will be * called instead. * * Introduced in version 2.5 */ int (*ftruncate) (const char *, off_t, struct fuse_file_info *); /** * Get attributes from an open file * * This method is called instead of the getattr() method if the * file information is available. * * Currently this is only called after the create() method if that * is implemented (see above). Later it may be called for * invocations of fstat() too. * * Introduced in version 2.5 */ int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); /** * Perform POSIX file locking operation * * The cmd argument will be either F_GETLK, F_SETLK or F_SETLKW. * * For the meaning of fields in 'struct flock' see the man page * for fcntl(2). The l_whence field will always be set to * SEEK_SET. * * For checking lock ownership, the 'fuse_file_info->owner' * argument must be used. * * For F_GETLK operation, the library will first check currently * held locks, and if a conflicting lock is found it will return * information without calling this method. This ensures, that * for local locks the l_pid field is correctly filled in. The * results may not be accurate in case of race conditions and in * the presence of hard links, but it's unlikly that an * application would rely on accurate GETLK results in these * cases. If a conflicting lock is not found, this method will be * called, and the filesystem may fill out l_pid by a meaningful * value, or it may leave this field zero. * * For F_SETLK and F_SETLKW the l_pid field will be set to the pid * of the process performing the locking operation. * * Note: if this method is not implemented, the kernel will still * allow file locking to work locally. Hence it is only * interesting for network filesystems and similar. * * Introduced in version 2.6 */ int (*lock) (const char *, struct fuse_file_info *, int cmd, struct flock *); /** * Change the access and modification times of a file with * nanosecond resolution * * Introduced in version 2.6 */ int (*utimens) (const char *, const struct timespec tv[2]); /** * Map block index within file to block index within device * * Note: This makes sense only for block device backed filesystems * mounted with the 'blkdev' option * * Introduced in version 2.6 */ int (*bmap) (const char *, size_t blocksize, uint64_t *idx);};/** Extra context that may be needed by some filesystems * * The uid, gid and pid fields are not filled in case of a writepage * operation. */struct fuse_context { /** Pointer to the fuse object */ struct fuse *fuse; /** User ID of the calling process */ uid_t uid; /** Group ID of the calling process */ gid_t gid; /** Thread ID of the calling process */ pid_t pid; /** Private filesystem data */ void *private_data;};/* * Main function of FUSE. * * This is for the lazy. This is all that has to be called from the * main() function. * * This function does the following: * - parses command line options (-d -s and -h) * - passes relevant mount options to the fuse_mount() * - installs signal handlers for INT, HUP, TERM and PIPE * - registers an exit handler to unmount the filesystem on program exit * - creates a fuse handle * - registers the operations * - calls either the single-threaded or the multi-threaded event loop * * Note: this is currently implemented as a macro. * * @param argc the argument counter passed to the main() function * @param argv the argument vector passed to the main() function * @param op the file system operation * @param user_data user data set in context for init() method * @return 0 on success, nonzero on failure *//*int fuse_main(int argc, char *argv[], const struct fuse_operations *op, void *user_data);*/#define fuse_main(argc, argv, op, user_data) \ fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)/* ----------------------------------------------------------- * * More detailed API * * ----------------------------------------------------------- *//** * Create a new FUSE filesystem. * * @param ch the communication channel * @param args argument vector * @param op the operations * @param op_size the size of the fuse_operations structure * @param user_data user data set in context for init() method * @return the created FUSE handle */struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data);/** * Destroy the FUSE handle. * * The communication channel attached to the handle is also destroyed. * * NOTE: This function does not unmount the filesystem. If this is * needed, call fuse_unmount() before calling this function. * * @param f the FUSE handle */void fuse_destroy(struct fuse *f);/** * FUSE event loop. * * Requests from the kernel are processed, and the appropriate * operations are called. * * @param f the FUSE handle * @return 0 if no error occurred, -1 otherwise */int fuse_loop(struct fuse *f);/** * Exit from event loop * * @param f the FUSE handle */void fuse_exit(struct fuse *f);/** * FUSE event loop with multiple threads * * Requests from the kernel are processed, and the appropriate * operations are called. Request are processed in parallel by * distributing them between multiple threads. * * Calling this function requires the pthreads library to be linked to * the application. * * @param f the FUSE handle * @return 0 if no error occurred, -1 otherwise */int fuse_loop_mt(struct fuse *f);/** * Get the current context * * The context is only valid for the duration of a filesystem * operation, and thus must not be stored and used later. * * @return the context */struct fuse_context *fuse_get_context(void);/** * Check if a request has already been interrupted * * @param req request handle * @return 1 if the request has been interrupted, 0 otherwise */int fuse_interrupted(void);/** * Obsolete, doesn't do anything * * @return -EINVAL */int fuse_invalidate(struct fuse *f, const char *path);/* Deprecated, don't use */int fuse_is_lib_option(const char *opt);/** * The real main function * * Do not call this directly, use fuse_main() */int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, void *user_data);/* ----------------------------------------------------------- * * Advanced API for event handling, don't worry about this... * * ----------------------------------------------------------- *//* NOTE: the following functions are deprecated, and will be removed from the 3.0 API. Use the lowlevel session functions instead *//** Function type used to process commands */typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);/** This is the part of fuse_main() before the event loop */struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, int *multithreaded, void *user_data);/** This is the part of fuse_main() after the event loop */void fuse_teardown(struct fuse *fuse, char *mountpoint);/** Read a single command. If none are read, return NULL */struct fuse_cmd *fuse_read_cmd(struct fuse *f);/** Process a single command */void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd);/** Multi threaded event loop, which calls the custom command processor function */int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data);/** Return the exited flag, which indicates if fuse_exit() has been called */int fuse_exited(struct fuse *f);/** This function is obsolete and implemented as a no-op */void fuse_set_getcontext_func(struct fuse_context *(*func)(void));/** Get session from fuse object */struct fuse_session *fuse_get_session(struct fuse *f);/* ----------------------------------------------------------- * * Compatibility stuff * * ----------------------------------------------------------- */#if FUSE_USE_VERSION < 26# include "fuse_compat.h"# undef fuse_main# if FUSE_USE_VERSION == 25# define fuse_main(argc, argv, op) \ fuse_main_real_compat25(argc, argv, op, sizeof(*(op)))# define fuse_new fuse_new_compat25# define fuse_setup fuse_setup_compat25# define fuse_teardown fuse_teardown_compat22# define fuse_operations fuse_operations_compat25# elif FUSE_USE_VERSION == 22# define fuse_main(argc, argv, op) \ fuse_main_real_compat22(argc, argv, op, sizeof(*(op)))# define fuse_new fuse_new_compat22# define fuse_setup fuse_setup_compat22# define fuse_teardown fuse_teardown_compat22# define fuse_operations fuse_operations_compat22# define fuse_file_info fuse_file_info_compat# elif FUSE_USE_VERSION == 24# error Compatibility with high-level API version 24 not supported# else# define fuse_dirfil_t fuse_dirfil_t_compat# define __fuse_read_cmd fuse_read_cmd# define __fuse_process_cmd fuse_process_cmd# define __fuse_loop_mt fuse_loop_mt_proc# if FUSE_USE_VERSION == 21# define fuse_operations fuse_operations_compat2# define fuse_main fuse_main_compat2# define fuse_new fuse_new_compat2# define __fuse_setup fuse_setup_compat2# define __fuse_teardown fuse_teardown_compat22# define __fuse_exited fuse_exited# define __fuse_set_getcontext_func fuse_set_getcontext_func# else# define fuse_statfs fuse_statfs_compat1# define fuse_operations fuse_operations_compat1# define fuse_main fuse_main_compat1# define fuse_new fuse_new_compat1# define FUSE_DEBUG FUSE_DEBUG_COMPAT1# endif# endif#endif#ifdef __cplusplus}#endif#endif /* _FUSE_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -