📄 fuse.h
字号:
/** * 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 supplied in the context during the 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 filesystem operations * @param op_size the size of the fuse_operations structure * @param user_data user data supplied in the context during the 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);/* * Stacking API *//** * Fuse filesystem object * * This is opaque object represents a filesystem layer */struct fuse_fs;/* * These functions call the relevant filesystem operation, and return * the result. * * If the operation is not defined, they return -ENOSYS, with the * exception of fuse_fs_open, fuse_fs_release, fuse_fs_opendir, * fuse_fs_releasedir and fuse_fs_statfs, which return 0. */int fuse_fs_getattr(struct fuse_fs *fs, const char *path, struct stat *buf);int fuse_fs_fgetattr(struct fuse_fs *fs, const char *path, struct stat *buf, struct fuse_file_info *fi);int fuse_fs_rename(struct fuse_fs *fs, const char *oldpath, const char *newpath);int fuse_fs_unlink(struct fuse_fs *fs, const char *path);int fuse_fs_rmdir(struct fuse_fs *fs, const char *path);int fuse_fs_symlink(struct fuse_fs *fs, const char *linkname, const char *path);int fuse_fs_link(struct fuse_fs *fs, const char *oldpath, const char *newpath);int fuse_fs_release(struct fuse_fs *fs, const char *path, struct fuse_file_info *fi);int fuse_fs_open(struct fuse_fs *fs, const char *path, struct fuse_file_info *fi);int fuse_fs_read(struct fuse_fs *fs, const char *path, char *buf, size_t size, off_t off, struct fuse_file_info *fi);int fuse_fs_write(struct fuse_fs *fs, const char *path, const char *buf, size_t size, off_t off, struct fuse_file_info *fi);int fuse_fs_fsync(struct fuse_fs *fs, const char *path, int datasync, struct fuse_file_info *fi);int fuse_fs_flush(struct fuse_fs *fs, const char *path, struct fuse_file_info *fi);int fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf);int fuse_fs_opendir(struct fuse_fs *fs, const char *path, struct fuse_file_info *fi);int fuse_fs_readdir(struct fuse_fs *fs, const char *path, void *buf, fuse_fill_dir_t filler, off_t off, struct fuse_file_info *fi);int fuse_fs_fsyncdir(struct fuse_fs *fs, const char *path, int datasync, struct fuse_file_info *fi);int fuse_fs_releasedir(struct fuse_fs *fs, const char *path, struct fuse_file_info *fi);int fuse_fs_create(struct fuse_fs *fs, const char *path, mode_t mode, struct fuse_file_info *fi);int fuse_fs_lock(struct fuse_fs *fs, const char *path, struct fuse_file_info *fi, int cmd, struct flock *lock);int fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode);int fuse_fs_chown(struct fuse_fs *fs, const char *path, uid_t uid, gid_t gid);int fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size);int fuse_fs_ftruncate(struct fuse_fs *fs, const char *path, off_t size, struct fuse_file_info *fi);int fuse_fs_utimens(struct fuse_fs *fs, const char *path, const struct timespec tv[2]);int fuse_fs_access(struct fuse_fs *fs, const char *path, int mask);int fuse_fs_readlink(struct fuse_fs *fs, const char *path, char *buf, size_t len);int fuse_fs_mknod(struct fuse_fs *fs, const char *path, mode_t mode, dev_t rdev);int fuse_fs_mkdir(struct fuse_fs *fs, const char *path, mode_t mode);int fuse_fs_setxattr(struct fuse_fs *fs, const char *path, const char *name, const char *value, size_t size, int flags);int fuse_fs_getxattr(struct fuse_fs *fs, const char *path, const char *name, char *value, size_t size);int fuse_fs_listxattr(struct fuse_fs *fs, const char *path, char *list, size_t size);int fuse_fs_removexattr(struct fuse_fs *fs, const char *path, const char *name);int fuse_fs_bmap(struct fuse_fs *fs, const char *path, size_t blocksize, uint64_t *idx);void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn);void fuse_fs_destroy(struct fuse_fs *fs);/** * Create a new fuse filesystem object * * This is usually called from the factory of a fuse module to create * a new instance of a filesystem. * * @param op the filesystem operations * @param op_size the size of the fuse_operations structure * @param user_data user data supplied in the context during the init() method * @return a new filesystem object */struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size, void *user_data);/** * Filesystem module * * Filesystem modules are registered with the FUSE_REGISTER_MODULE() * macro. * * If the "-omodules=modname:..." option is present, filesystem * objects are created and pushed onto the stack with the 'factory' * function. */struct fuse_module { /** * Name of filesystem */ const char *name; /** * Factory for creating filesystem objects * * The function may use and remove options from 'args' that belong * to this module. * * For now the 'fs' vector always contains exactly one filesystem. * This is the filesystem which will be below the newly created * filesystem in the stack. * * @param args the command line arguments * @param fs NULL terminated filesystem object vector * @return the new filesystem object */ struct fuse_fs *(*factory)(struct fuse_args *args, struct fuse_fs *fs[]); struct fuse_module *next; struct fusemod_so *so; int ctr;};/** * Register a filesystem module * * This function is used by FUSE_REGISTER_MODULE and there's usually * no need to call it directly */void fuse_register_module(struct fuse_module *mod);/** * Register filesystem module * * For the parameters, see description of the fields in 'struct * fuse_module' */#define FUSE_REGISTER_MODULE(name_, factory_) \static __attribute__((constructor)) void name_ ## _register(void) \{ \ static struct fuse_module mod = { #name_, factory_, NULL, NULL, 0 }; \ fuse_register_module(&mod); \}/* ----------------------------------------------------------- * * 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 + -