⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fuse_lowlevel.h

📁 UNIX/LINUX下面的用户文件系统
💻 H
📖 第 1 页 / 共 3 页
字号:
int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size);/** * Reply with filesystem statistics * * Possible requests: *   statfs * * @param req request handle * @param stbuf filesystem statistics * @return zero for success, -errno for failure to send reply */int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf);/** * Reply with needed buffer size * * Possible requests: *   getxattr, listxattr * * @param req request handle * @param count the buffer size needed in bytes * @return zero for success, -errno for failure to send reply */int fuse_reply_xattr(fuse_req_t req, size_t count);/* ----------------------------------------------------------- * * Filling a buffer in readdir                                 * * ----------------------------------------------------------- *//** * Calculate the number of bytes a directory entry takes up * * @param namelen the length of the entry name * @return the number of bytes needed */size_t fuse_dirent_size(size_t namelen);/** * Add a directory entry to the buffer * * Buffer needs to be large enough to hold the entry * * From the 'stbuf' argument the st_ino field and bits 12-15 of the * st_mode field are used.  The other fields are ignored. * * Note: offsets do not necessarily represent physical offsets, and * could be any marker, that enables the implementation to find a * specific point in the directory stream. * * @param buf the point where the new entry will be added to the buffer * @param the name of the entry * @param stbuf the file attributes * @param off the offset of the next entry * @return a pointer to the start of the next entry in the buffer */char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,                      off_t off);/* ----------------------------------------------------------- * * Utility functions                                           * * ----------------------------------------------------------- *//** * Get the userdata from the request * * @param req request handle * @return the user data passed to fuse_lowlevel_new() */void *fuse_req_userdata(fuse_req_t req);/** * Get the context from the request * * The pointer returned by this function will only be valid for the * request's lifetime * * @param req request handle * @return the context structure */const struct fuse_ctx *fuse_req_ctx(fuse_req_t req);/* ----------------------------------------------------------- * * Filesystem setup                                            * * ----------------------------------------------------------- *//* Deprecated, don't use */int fuse_lowlevel_is_lib_option(const char *opt);/** * Create a low level session * * @param args argument vector * @param op the low level filesystem operations * @param op_size sizeof(struct fuse_lowlevel_ops) * @param userdata user data * @return the created session object, or NULL on failure */struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,                                       const struct fuse_lowlevel_ops *op,                                       size_t op_size, void *userdata);/** * Create a kernel channel * * @param fd the file descriptor obtained from fuse_mount() * @return the created channel object, or NULL on failure */struct fuse_chan *fuse_kern_chan_new(int fd);/* ----------------------------------------------------------- * * Session interface                                           * * ----------------------------------------------------------- *//** * Session operations * * This is used in session creation */struct fuse_session_ops {    /**     * Hook to process a request (mandatory)     *     * @param data user data passed to fuse_session_new()     * @param buf buffer containing the raw request     * @param len request length     * @param ch channel on which the request was received     */    void (*process) (void *data, const char *buf, size_t len,                     struct fuse_chan *ch);    /**     * Hook for session exit and reset (optional)     *     * @param data user data passed to fuse_session_new()     * @param val exited status (1 - exited, 0 - not exited)     */    void (*exit) (void *data, int val);    /**     * Hook for querying the current exited status (optional)     *     * @param data user data passed to fuse_session_new()     * @return 1 if exited, 0 if not exited     */    int (*exited) (void *data);    /**     * Hook for cleaning up the channel on destroy (optional)     *     * @param data user data passed to fuse_session_new()     */    void (*destroy) (void *data);};/** * Create a new session * * @param op session operations * @param data user data * @return new session object, or NULL on failure */struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data);/** * Assign a channel to a session * * Note: currently only a single channel may be assigned.  This may * change in the future * * If a session is destroyed, the assigned channel is also destroyed * * @param se the session * @param ch the channel */void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);/** * Iterate over the channels assigned to a session * * The iterating function needs to start with a NULL channel, and * after that needs to pass the previously returned channel to the * function. * * @param se the session * @param ch the previous channel, or NULL * @return the next channel, or NULL if no more channels exist */struct fuse_chan *fuse_session_next_chan(struct fuse_session *se,                                         struct fuse_chan *ch);/** * Process a raw request * * @param se the session * @param buf buffer containing the raw request * @param len request length * @param ch channel on which the request was received */void fuse_session_process(struct fuse_session *se, const char *buf, size_t len,                          struct fuse_chan *ch);/** * Destroy a session * * @param se the session */void fuse_session_destroy(struct fuse_session *se);/** * Exit a session * * @param se the session */void fuse_session_exit(struct fuse_session *se);/** * Reset the exited status of a session * * @param se the session */void fuse_session_reset(struct fuse_session *se);/** * Query the exited status of a session * * @param se the session * @return 1 if exited, 0 if not exited */int fuse_session_exited(struct fuse_session *se);/** * Enter a single threaded event loop * * @param se the session * @return 0 on success, -1 on error */int fuse_session_loop(struct fuse_session *se);/** * Enter a multi-threaded event loop * * @param se the session * @return 0 on success, -1 on error */int fuse_session_loop_mt(struct fuse_session *se);/* ----------------------------------------------------------- * * Channel interface                                           * * ----------------------------------------------------------- *//** * Channel operations * * This is used in channel creation */struct fuse_chan_ops {    /**     * Hook for receiving a raw request     *     * @param ch the channel     * @param buf the buffer to store the request in     * @param size the size of the buffer     * @return the actual size of the raw request, or -1 on error     */    int (*receive)(struct fuse_chan *ch, char *buf, size_t size);    /**     * Hook for sending a raw reply     *     * A return value of -ENOENT means, that the request was     * interrupted, and the reply was discarded     *     * @param ch the channel     * @param iov vector of blocks     * @param count the number of blocks in vector     * @return zero on success, -errno on failure     */    int (*send)(struct fuse_chan *ch, const struct iovec iov[],                size_t count);    /**     * Destroy the channel     *     * @param ch the channel     */    void (*destroy)(struct fuse_chan *ch);};/** * Create a new channel * * @param op channel operations * @param fd file descriptor of the channel * @param bufsize the minimal receive buffer size * @param data user data * @return the new channel object, or NULL on failure */struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd,                                size_t bufsize, void *data);/** * Query the file descriptor of the channel * * @param ch the channel * @return the file descriptor passed to fuse_chan_new() */int fuse_chan_fd(struct fuse_chan *ch);/** * Query the minimal receive buffer size * * @param ch the channel * @return the buffer size passed to fuse_chan_new() */size_t fuse_chan_bufsize(struct fuse_chan *ch);/** * Query the user data * * @param ch the channel * @return the user data passed to fuse_chan_new() */void *fuse_chan_data(struct fuse_chan *ch);/** * Query the session to which this channel is assigned * * @param ch the channel * @return the session, or NULL if the channel is not assigned */struct fuse_session *fuse_chan_session(struct fuse_chan *ch);/** * Receive a raw request * * @param ch the channel * @param buf the buffer to store the request in * @param size the size of the buffer * @return the actual size of the raw request, or -1 on error */int fuse_chan_receive(struct fuse_chan *ch, char *buf, size_t size);/** * Send a raw reply * * A return value of -ENOENT means, that the request was * interrupted, and the reply was discarded * * @param ch the channel * @param iov vector of blocks * @param count the number of blocks in vector * @return zero on success, -errno on failure */int fuse_chan_send(struct fuse_chan *ch, const struct iovec iov[],                   size_t count);/** * Destroy a channel * * @param ch the channel */void fuse_chan_destroy(struct fuse_chan *ch);/* ----------------------------------------------------------- * * Signal handling                                             * * ----------------------------------------------------------- *//** * Exit session on HUP, TERM and INT signals and ignore PIPE signal * * Stores session in a global variable.  May only be called once per * process until fuse_remove_signal_handlers() is called. * * @param se the session to exit * @return 0 on success, -1 on failure */int fuse_set_signal_handlers(struct fuse_session *se);/** * Restore default signal handlers * * Resets global session.  After this fuse_set_signal_handlers() may * be called again. * * @param se the same session as given in fuse_set_signal_handlers() */void fuse_remove_signal_handlers(struct fuse_session *se);/* ----------------------------------------------------------- * * Compatibility stuff                                         * * ----------------------------------------------------------- */#ifndef __FreeBSD__#if FUSE_USE_VERSION == 24#  include "fuse_lowlevel_compat.h"#  undef FUSE_MINOR_VERSION#  define FUSE_MINOR_VERSION 4#  define fuse_file_info fuse_file_info_compat#  define fuse_reply_statfs fuse_reply_statfs_compat#  define fuse_reply_open fuse_reply_open_compat#elif FUSE_USE_VERSION < 25#  error Compatibility with low level API version other than 24 not supported#endif#else /* __FreeBSD__ */#if FUSE_USE_VERSION < 25#  error On FreeBSD API version 25 or greater must be used#endif#endif /* __FreeBSD__ */#ifdef __cplusplus}#endif#endif /* _FUSE_LOWLEVEL_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -