Add statx support

This commit is contained in:
Antonio SJ Musumeci 2025-03-30 18:06:30 -05:00
parent b85cc8c370
commit 80085c9844
11 changed files with 446 additions and 3 deletions

View file

@ -549,6 +549,16 @@ struct fuse_operations
int (*removemapping)();
int (*syncfs)();
int (*tmpfile)(const char *, mode_t, fuse_file_info_t *);
int (*statx)(const char *fusepath,
const uint32_t flags,
const uint32_t mask,
struct fuse_statx *st,
fuse_timeouts_t *timeout);
int (*statx_fh)(const uint64_t fh,
const uint32_t flags,
const uint32_t mask,
struct fuse_statx *st,
fuse_timeouts_t *timeout);
};
/** Extra context that may be needed by some filesystems

View file

@ -257,6 +257,12 @@ int fuse_reply_attr(fuse_req_t req,
const struct stat *attr,
const uint64_t timeout);
int fuse_reply_statx(fuse_req_t req,
int flags,
struct fuse_statx *st,
const uint64_t timeout);
/**
* Reply with the contents of a symbolic link
*

View file

@ -1718,6 +1718,78 @@ fuse_lib_getattr(fuse_req_t req,
}
}
static
void
fuse_lib_statx_path(fuse_req_t req_,
struct fuse_in_header *hdr_,
struct fuse *f_,
fuse_statx_in *inarg_)
{
int err;
char *fusepath;
struct fuse_statx st{};
fuse_timeouts_t timeouts{};
err = get_path(f_,hdr_->nodeid,&fusepath);
if(err)
{
fuse_reply_err(req_,err);
return;
}
err = f_->fs->op.statx(fusepath,
inarg_->sx_flags,
inarg_->sx_mask,
&st,
&timeouts);
free_path(f_,hdr_->nodeid,fusepath);
if(err)
fuse_reply_err(req_,err);
else
fuse_reply_statx(req_,0,&st,timeouts.attr);
}
static
void
fuse_lib_statx_fh(fuse_req_t req_,
struct fuse_in_header *hdr_,
struct fuse *f_,
fuse_statx_in *inarg_)
{
int err;
struct fuse_statx st{};
fuse_timeouts_t timeouts{};
err = f_->fs->op.statx_fh(inarg_->fh,
inarg_->sx_flags,
inarg_->sx_mask,
&st,
&timeouts);
if(err)
fuse_reply_err(req_,err);
else
fuse_reply_statx(req_,0,&st,timeouts.attr);
}
static
void
fuse_lib_statx(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
struct fuse *f = req_fuse_prepare(req_);
fuse_statx_in *inarg;
inarg = (fuse_statx_in*)fuse_hdr_arg(hdr_);
if(inarg->getattr_flags & FUSE_GETATTR_FH)
fuse_lib_statx_fh(req_,hdr_,f,inarg);
else
fuse_lib_statx_path(req_,hdr_,f,inarg);
}
static
void
fuse_lib_setattr(fuse_req_t req,
@ -3643,6 +3715,7 @@ static struct fuse_lowlevel_ops fuse_path_ops =
.setupmapping = fuse_lib_setupmapping,
.setxattr = fuse_lib_setxattr,
.statfs = fuse_lib_statfs,
.statx = fuse_lib_statx,
.symlink = fuse_lib_symlink,
.syncfs = fuse_lib_syncfs,
.tmpfile = fuse_lib_tmpfile,

View file

@ -343,6 +343,22 @@ fuse_reply_attr(fuse_req_t req,
return send_reply_ok(req,&arg,size);
}
int
fuse_reply_statx(fuse_req_t req_,
int flags_,
struct fuse_statx *st_,
uint64_t timeout_)
{
struct fuse_statx_out outarg{};
outarg.flags = flags_;
outarg.attr_valid = timeout_;
outarg.attr_valid_nsec = 0;
outarg.stat = *(struct fuse_statx*)st_;
return send_reply_ok(req_,&outarg,sizeof(outarg));
}
int
fuse_reply_readlink(fuse_req_t req,
const char *linkname)