📄 fuse.h
字号:
* 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 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);/** * 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);/* ----------------------------------------------------------- * * 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 *//** Get session from fuse object */struct fuse_session *fuse_get_session(struct fuse *f);#ifdef __cplusplus}#endif#endif /* _FUSE_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -