diff options
author | Joanne Koong <joannelkoong@gmail.com> | 2024-08-23 13:11:09 -0700 |
---|---|---|
committer | Bernd Schubert <bernd@bsbernd.com> | 2025-07-16 01:46:09 +0200 |
commit | b507cbc2b1aaec1931642497edcb6723a0d24dc4 (patch) | |
tree | 9b7556bbd548d3bee38d2f624876dba977014d45 /lib/modules | |
parent | 3be844147764b96496bcae6d92fa4b0e43ebff42 (diff) | |
download | libfuse-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 'lib/modules')
-rw-r--r-- | lib/modules/iconv.c | 19 | ||||
-rw-r--r-- | lib/modules/subdir.c | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c index 599b8df..417c904 100644 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -568,6 +568,22 @@ static off_t iconv_lseek(const char *path, off_t off, int whence, return res; } +#ifdef HAVE_STATX +static int iconv_statx(const char *path, int flags, int mask, struct statx *stxbuf, + struct fuse_file_info *fi) +{ + struct iconv *ic = iconv_get(); + char *newpath; + int res = iconv_convpath(ic, path, &newpath, 0); + + if (!res) { + res = fuse_fs_statx(ic->next, newpath, flags, mask, stxbuf, fi); + free(newpath); + } + return res; +} +#endif + static void *iconv_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { @@ -627,6 +643,9 @@ static const struct fuse_operations iconv_oper = { .flock = iconv_flock, .bmap = iconv_bmap, .lseek = iconv_lseek, +#ifdef HAVE_STATX + .statx = iconv_statx, +#endif }; static const struct fuse_opt iconv_opts[] = { diff --git a/lib/modules/subdir.c b/lib/modules/subdir.c index dd2d49d..67c4697 100644 --- a/lib/modules/subdir.c +++ b/lib/modules/subdir.c @@ -553,6 +553,22 @@ static off_t subdir_lseek(const char *path, off_t off, int whence, return res; } +#ifdef HAVE_STATX +static int subdir_statx(const char *path, int flags, int mask, struct statx *stxbuf, + struct fuse_file_info *fi) +{ + struct subdir *ic = subdir_get(); + char *newpath; + int res = subdir_addpath(ic, path, &newpath); + + if (!res) { + res = fuse_fs_statx(ic->next, newpath, flags, mask, stxbuf, fi); + free(newpath); + } + return res; +} +#endif + static void *subdir_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { @@ -608,6 +624,9 @@ static const struct fuse_operations subdir_oper = { .flock = subdir_flock, .bmap = subdir_bmap, .lseek = subdir_lseek, +#ifdef HAVE_STATX + .statx = subdir_statx, +#endif }; static const struct fuse_opt subdir_opts[] = { |