aboutsummaryrefslogtreecommitdiff
path: root/include/fuse_lowlevel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/fuse_lowlevel.h')
-rw-r--r--include/fuse_lowlevel.h307
1 files changed, 89 insertions, 218 deletions
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index 2036717..595f061 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -44,7 +44,7 @@ extern "C" {
#define FUSE_ROOT_ID 1
/** Inode number type */
-typedef unsigned long fuse_ino_t;
+typedef uint64_t fuse_ino_t;
/** Request pointer type */
typedef struct fuse_req *fuse_req_t;
@@ -88,7 +88,7 @@ struct fuse_entry_param {
* it as an error.
*
*/
- unsigned long generation;
+ uint64_t generation;
/** Inode attributes.
*
@@ -122,7 +122,7 @@ struct fuse_ctx {
};
struct fuse_forget_data {
- uint64_t ino;
+ fuse_ino_t ino;
uint64_t nlookup;
};
@@ -233,7 +233,7 @@ struct fuse_lowlevel_ops {
* @param ino the inode number
* @param nlookup the number of lookups to forget
*/
- void (*forget) (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup);
+ void (*forget) (fuse_req_t req, fuse_ino_t ino, uint64_t nlookup);
/**
* Get file attributes
@@ -600,6 +600,9 @@ struct fuse_lowlevel_ops {
*
* fi->fh will contain the value set by the opendir method, or
* will be undefined if the opendir method didn't set any value.
+ *
+ * Returning a directory entry from readdir() does not affect
+ * its lookup count.
*
* Valid replies:
* fuse_reply_buf
@@ -1016,6 +1019,36 @@ struct fuse_lowlevel_ops {
*/
void (*fallocate) (fuse_req_t req, fuse_ino_t ino, int mode,
off_t offset, off_t length, struct fuse_file_info *fi);
+
+ /**
+ * Read directory with attributes
+ *
+ * Send a buffer filled using fuse_add_direntry_plus(), with size not
+ * exceeding the requested size. Send an empty buffer on end of
+ * stream.
+ *
+ * fi->fh will contain the value set by the opendir method, or
+ * will be undefined if the opendir method didn't set any value.
+ *
+ * In contrast to readdir() (which does not affect the lookup
+ * counts), the lookup count of every entry returned by
+ * readdirplus() is increased by one.
+ *
+ * Introduced in version 3.0
+ *
+ * Valid replies:
+ * fuse_reply_buf
+ * fuse_reply_data
+ * fuse_reply_err
+ *
+ * @param req request handle
+ * @param ino the inode number
+ * @param size maximum number of bytes to send
+ * @param off offset to continue reading the directory stream
+ * @param fi file information
+ */
+ void (*readdirplus) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
+ struct fuse_file_info *fi);
};
/**
@@ -1150,6 +1183,11 @@ int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size);
* Possible requests:
* read, readdir, getxattr, listxattr
*
+ * Side effects:
+ * when used to return data from a readdirplus() (but not readdir())
+ * call, increments the lookup count of each returned entry by one
+ * on success.
+ *
* @param req request handle
* @param bufv buffer vector
* @param flags flags controlling the copy
@@ -1252,6 +1290,34 @@ size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize,
off_t off);
/**
+ * Add a directory entry to the buffer with the attributes
+ *
+ * Buffer needs to be large enough to hold the entry. If it's not,
+ * then the entry is not filled in but the size of the entry is still
+ * returned. The caller can check this by comparing the bufsize
+ * parameter with the returned entry size. If the entry size is
+ * larger than the buffer size, the operation failed.
+ *
+ * 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 req request handle
+ * @param buf the point where the new entry will be added to the buffer
+ * @param bufsize remaining size of the buffer
+ * @param name the name of the entry
+ * @param e the directory entry
+ * @param off the offset of the next entry
+ * @return the space needed for the entry
+ */
+size_t fuse_add_direntry_plus(fuse_req_t req, char *buf, size_t bufsize,
+ const char *name,
+ const struct fuse_entry_param *e, off_t off);
+
+/**
* Reply to ask for data fetch and output buffer preparation. ioctl
* will be retried with the specified input data fetched and output
* buffer prepared.
@@ -1491,9 +1557,6 @@ int fuse_req_interrupted(fuse_req_t req);
* Filesystem setup *
* ----------------------------------------------------------- */
-/* Deprecated, don't use */
-int fuse_lowlevel_is_lib_option(const char *opt);
-
/**
* Create a low level session
*
@@ -1502,6 +1565,9 @@ int fuse_lowlevel_is_lib_option(const char *opt);
* @param op_size sizeof(struct fuse_lowlevel_ops)
* @param userdata user data
* @return the created session object, or NULL on failure
+ *
+ * Example: See hello_ll.c:
+ * \snippet hello_ll.c doxygen_fuse_lowlevel_usage
*/
struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
const struct fuse_lowlevel_ops *op,
@@ -1512,61 +1578,8 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
* ----------------------------------------------------------- */
/**
- * 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
@@ -1575,7 +1588,7 @@ struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data);
void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);
/**
- * Remove a channel from a session
+ * Remove the channel from a session
*
* If the channel is not assigned to a session, then this is a no-op
*
@@ -1584,35 +1597,17 @@ void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);
void fuse_session_remove_chan(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
+ * Return channel assigned to the session
*
* @param se the session
- * @param buf buffer containing the raw request
- * @param len request length
- * @param ch channel on which the request was received
+ * @return the channel
*/
-void fuse_session_process(struct fuse_session *se, const char *buf, size_t len,
- struct fuse_chan *ch);
+struct fuse_chan *fuse_session_chan(struct fuse_session *se);
/**
* Process a raw request supplied in a generic buffer
*
- * This is a more generic version of fuse_session_process(). The
- * fuse_buf may contain a memory buffer or a pipe file descriptor.
+ * The fuse_buf may contain a memory buffer or a pipe file descriptor.
*
* @param se the session
* @param buf the fuse_buf containing the request
@@ -1624,17 +1619,16 @@ void fuse_session_process_buf(struct fuse_session *se,
/**
* Receive a raw request supplied in a generic buffer
*
- * This is a more generic version of fuse_chan_recv(). The fuse_buf
- * supplied to this function contains a suitably allocated memory
+ * The fuse_buf supplied to this function contains a suitably allocated memory
* buffer. This may be overwritten with a file descriptor buffer.
*
* @param se the session
* @param buf the fuse_buf to store the request in
- * @param chp pointer to the channel
+ * @param ch the channel
* @return the actual size of the raw request, or -errno on error
*/
int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf,
- struct fuse_chan **chp);
+ struct fuse_chan *ch);
/**
* Destroy a session
@@ -1644,7 +1638,10 @@ int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf,
void fuse_session_destroy(struct fuse_session *se);
/**
- * Exit a session
+ * Exit a session.
+ *
+ * This function is invoked by the POSIX signal handlers, when registered using:
+ * * fuse_set_signal_handlers()
*
* @param se the session
*/
@@ -1666,15 +1663,11 @@ void fuse_session_reset(struct fuse_session *se);
int fuse_session_exited(struct fuse_session *se);
/**
- * Get the user data provided to the session
+ * Enter a single threaded, blocking event loop.
*
- * @param se the session
- * @return the user data
- */
-void *fuse_session_data(struct fuse_session *se);
-
-/**
- * Enter a single threaded event loop
+ * Using POSIX signals this event loop can be exited but the session
+ * needs to be configued by issuing:
+ * fuse_set_signal_handlers() first.
*
* @param se the session
* @return 0 on success, -1 on error
@@ -1694,56 +1687,6 @@ int fuse_session_loop_mt(struct fuse_session *se);
* ----------------------------------------------------------- */
/**
- * Channel operations
- *
- * This is used in channel creation
- */
-struct fuse_chan_ops {
- /**
- * Hook for receiving a raw request
- *
- * @param ch pointer to 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 **chp, 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
@@ -1752,84 +1695,12 @@ struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd,
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
- *
- * A return value of -ENODEV means, that the filesystem was unmounted
- *
- * @param ch pointer to 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 -errno on error
- */
-int fuse_chan_recv(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);
-/* ----------------------------------------------------------- *
- * Compatibility stuff *
- * ----------------------------------------------------------- */
-
-#if FUSE_USE_VERSION < 26
-# include "fuse_lowlevel_compat.h"
-# define fuse_chan_ops fuse_chan_ops_compat24
-# define fuse_chan_new fuse_chan_new_compat24
-# if FUSE_USE_VERSION == 25
-# define fuse_lowlevel_ops fuse_lowlevel_ops_compat25
-# define fuse_lowlevel_new fuse_lowlevel_new_compat25
-# elif FUSE_USE_VERSION == 24
-# define fuse_lowlevel_ops fuse_lowlevel_ops_compat
-# define fuse_lowlevel_new fuse_lowlevel_new_compat
-# define fuse_file_info fuse_file_info_compat
-# define fuse_reply_statfs fuse_reply_statfs_compat
-# define fuse_reply_open fuse_reply_open_compat
-# else
-# error Compatibility with low-level API version < 24 not supported
-# endif
-#endif
-
#ifdef __cplusplus
}
#endif