aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJoanne Koong <joannelkoong@gmail.com>2024-08-23 13:11:09 -0700
committerBernd Schubert <bernd@bsbernd.com>2025-07-16 01:46:09 +0200
commitb507cbc2b1aaec1931642497edcb6723a0d24dc4 (patch)
tree9b7556bbd548d3bee38d2f624876dba977014d45 /include
parent3be844147764b96496bcae6d92fa4b0e43ebff42 (diff)
downloadlibfuse-b507cbc2b1aaec1931642497edcb6723a0d24dc4.tar.gz
Add statx support
This commit adds libfuse support for FUSE_STATX requests on linux distributions. Currently, statx is only supported on linux. To make the interface a ergonomic as possible (eg using native 'struct statx' vs 'struct fuse_statx'), this implementation gates the 'struct statx' changes by #ifdef linux. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/fuse.h18
-rw-r--r--include/fuse_lowlevel.h35
2 files changed, 52 insertions, 1 deletions
diff --git a/include/fuse.h b/include/fuse.h
index b990043..06feacb 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -33,6 +33,9 @@ extern "C" {
* Basic FUSE API *
* ----------------------------------------------------------- */
+/* Forward declaration */
+struct statx;
+
/** Handle for a FUSE filesystem */
struct fuse;
@@ -850,6 +853,19 @@ struct fuse_operations {
* Find next data or hole after the specified offset
*/
off_t (*lseek) (const char *, off_t off, int whence, struct fuse_file_info *);
+
+#ifdef HAVE_STATX
+ /**
+ * Get extended file attributes.
+ *
+ * fi may be NULL.
+ *
+ * If path is NULL, then the AT_EMPTY_PATH bit in flags will be
+ * already set.
+ */
+ int (*statx)(const char *path, int flags, int mask, struct statx *stxbuf,
+ struct fuse_file_info *fi);
+#endif
};
/** Extra context that may be needed by some filesystems
@@ -1344,6 +1360,8 @@ ssize_t fuse_fs_copy_file_range(struct fuse_fs *fs, const char *path_in,
size_t len, int flags);
off_t fuse_fs_lseek(struct fuse_fs *fs, const char *path, off_t off, int whence,
struct fuse_file_info *fi);
+int fuse_fs_statx(struct fuse_fs *fs, const char *path, int flags, int mask,
+ struct statx *stxbuf, struct fuse_file_info *fi);
void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn,
struct fuse_config *cfg);
void fuse_fs_destroy(struct fuse_fs *fs);
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index 75e084d..844ee71 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -49,6 +49,9 @@ typedef uint64_t fuse_ino_t;
/** Request pointer type */
typedef struct fuse_req *fuse_req_t;
+/* Forward declaration */
+struct statx;
+
/**
* Session
*
@@ -1303,7 +1306,6 @@ struct fuse_lowlevel_ops {
void (*lseek) (fuse_req_t req, fuse_ino_t ino, off_t off, int whence,
struct fuse_file_info *fi);
-
/**
* Create a tempfile
*
@@ -1325,6 +1327,23 @@ struct fuse_lowlevel_ops {
void (*tmpfile) (fuse_req_t req, fuse_ino_t parent,
mode_t mode, struct fuse_file_info *fi);
+#ifdef HAVE_STATX
+ /**
+ * Get extended file attributes.
+ *
+ * Valid replies:
+ * fuse_reply_statx
+ * fuse_reply_err
+ *
+ * @param req request handle
+ * @param ino the inode number
+ * @param flags bitmask of requested flags
+ * @param mask bitmask of requested fields
+ * @param fi file information (may be NULL)
+ */
+ void (*statx)(fuse_req_t req, fuse_ino_t ino, int flags, int mask,
+ struct fuse_file_info *fi);
+#endif
};
/**
@@ -1705,6 +1724,20 @@ int fuse_reply_poll(fuse_req_t req, unsigned revents);
*/
int fuse_reply_lseek(fuse_req_t req, off_t off);
+/**
+ * Reply with extended file attributes.
+ *
+ * Possible requests:
+ * statx
+ *
+ * @param req request handle
+ * @param flags statx flags
+ * @param statx the attributes
+ * @param attr_timeout validity timeout (in seconds) for the attributes
+ * @return zero for success, -errno for failure to send reply
+ */
+int fuse_reply_statx(fuse_req_t req, int flags, struct statx *statx, double attr_timeout);
+
/* ----------------------------------------------------------- *
* Notification *
* ----------------------------------------------------------- */