UPSTREAM: ANDROID: fuse: add bpf support for removexattr

Bug: 218393120
Test: fuse_test#bpf_test_xattr
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: Idf69b5b70c5dc5f09270146fe8c574ac1bde7be6
This commit is contained in:
Daniel Rosenberg 2022-02-07 16:01:56 -08:00 • committed by Alexander Martinz
commit 37966b8d24
No known key found for this signature in database
GPG key ID: CF15BDD9A321A9B2
3 changed files with 49 additions and 1 deletions

View file

@ -661,6 +661,39 @@ void *fuse_setxattr_finalize(struct fuse_args *fa, struct dentry *dentry,
return NULL;
}
int fuse_removexattr_initialize(struct fuse_args *fa,
struct fuse_dummy_io *unused,
struct dentry *dentry, const char *name)
{
*fa = (struct fuse_args) {
.nodeid = get_fuse_inode(dentry->d_inode)->nodeid,
.opcode = FUSE_REMOVEXATTR,
.in_numargs = 1,
.in_args[0] = (struct fuse_in_arg) {
.size = strlen(name) + 1,
.value = name,
},
};
return 0;
}
int fuse_removexattr_backing(struct fuse_args *fa,
struct dentry *dentry, const char *name)
{
struct path *backing_path =
&get_fuse_dentry(dentry)->backing_path;
/* TODO account for changes of the name by prefilter */
return vfs_removexattr(backing_path->dentry, name);
}
void *fuse_removexattr_finalize(struct fuse_args *fa,
struct dentry *dentry, const char *name)
{
return NULL;
}
int fuse_file_read_iter_initialize(
struct fuse_args *fa, struct fuse_read_in *fri,
struct kiocb *iocb, struct iov_iter *to)

View file

@ -1474,6 +1474,14 @@ void *fuse_setxattr_finalize(struct fuse_args *fa, struct dentry *dentry,
const char *name, const void *value, size_t size,
int flags);
int fuse_removexattr_initialize(struct fuse_args *fa,
struct fuse_dummy_io *unused,
struct dentry *dentry, const char *name);
int fuse_removexattr_backing(struct fuse_args *fa,
struct dentry *dentry, const char *name);
void *fuse_removexattr_finalize(struct fuse_args *fa,
struct dentry *dentry, const char *name);
int fuse_file_read_iter_initialize(
struct fuse_args *fa, struct fuse_read_in *fri,
struct kiocb *iocb, struct iov_iter *to);

View file

@ -217,10 +217,17 @@ static int fuse_xattr_set(const struct xattr_handler *handler,
#ifdef CONFIG_FUSE_BPF
struct fuse_err_ret fer;
fer = fuse_bpf_backing(inode, struct fuse_setxattr_in,
if (value)
fer = fuse_bpf_backing(inode, struct fuse_setxattr_in,
fuse_setxattr_initialize, fuse_setxattr_backing,
fuse_setxattr_finalize, dentry, name, value,
size, flags);
else
fer = fuse_bpf_backing(inode, struct fuse_dummy_io,
fuse_removexattr_initialize,
fuse_removexattr_backing,
fuse_removexattr_finalize,
dentry, name);
if (fer.ret)
return PTR_ERR(fer.result);
#endif