From b507cbc2b1aaec1931642497edcb6723a0d24dc4 Mon Sep 17 00:00:00 2001 From: Joanne Koong Date: Fri, 23 Aug 2024 13:11:09 -0700 Subject: 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 --- example/passthrough_fh.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'example/passthrough_fh.c') 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[]) -- cgit v1.2.3