aboutsummaryrefslogtreecommitdiffstats
path: root/example/passthrough_fh.c
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 /example/passthrough_fh.c
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 'example/passthrough_fh.c')
-rw-r--r--example/passthrough_fh.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/example/passthrough_fh.c b/example/passthrough_fh.c
index 6764554..0d4fb5b 100644
--- a/example/passthrough_fh.c
+++ b/example/passthrough_fh.c
@@ -616,6 +616,24 @@ static off_t xmp_lseek(const char *path, off_t off, int whence, struct fuse_file
return res;
}
+#ifdef HAVE_STATX
+static int xmp_statx(const char *path, int flags, int mask, struct statx *stxbuf,
+ struct fuse_file_info *fi)
+{
+ int fd = -1;
+ int res;
+
+ if (fi)
+ fd = fi->fh;
+
+ res = statx(fd, path, flags | AT_SYMLINK_NOFOLLOW, mask, stxbuf);
+ if (res == -1)
+ return -errno;
+
+ return 0;
+}
+#endif
+
static const struct fuse_operations xmp_oper = {
.init = xmp_init,
.getattr = xmp_getattr,
@@ -662,6 +680,9 @@ static const struct fuse_operations xmp_oper = {
.copy_file_range = xmp_copy_file_range,
#endif
.lseek = xmp_lseek,
+#ifdef HAVE_STATX
+ .statx = xmp_statx,
+#endif
};
int main(int argc, char *argv[])