Skip to content

Commit

Permalink
ANDROID: fuse-bpf: Add /sys/fs flags for fuse-bpf version
Browse files Browse the repository at this point in the history
Note that this is specific for the non-upstreamed version

Bug: 202785178
Test: cat /sys/fs/fuse/fuse_bpf_major_version
Change-Id: I68f9ca56778874975428839dfc1fd8f48b11bd75
Signed-off-by: Paul Lawrence <[email protected]>
  • Loading branch information
PaulLawrenceGoogle authored and bengris32 committed Jun 22, 2024
1 parent 9d94dd4 commit 2a83701
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Documentation/ABI/testing/sysfs-fs-fuse
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
What: /sys/fs/fuse/features/fuse_bpf
Date: December 2022
Contact: Paul Lawrence <[email protected]>
Description:
Read-only file that contains the word 'supported' if fuse-bpf is
supported, does not exist otherwise

What: /sys/fs/fuse/bpf_prog_type_fuse
Date: December 2022
Contact: Paul Lawrence <[email protected]>
Description:
bpf_prog_type_fuse defines the program type of bpf programs that
may be passed to fuse-bpf. For upstream bpf program types, this
is a constant defined in a contiguous array of constants.
bpf_prog_type_fuse is appended to the end of the list, so it may
change and therefore its value must be read from this file.

Contents is ASCII decimal representation of bpf_prog_type_fuse

36 changes: 34 additions & 2 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,31 @@ static void fuse_fs_cleanup(void)

static struct kobject *fuse_kobj;

/* TODO Remove this once BPF_PROG_TYPE_FUSE is upstreamed */
static ssize_t fuse_bpf_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buff)
{
return sysfs_emit(buff, "supported\n");
}

static struct kobj_attribute fuse_bpf_attr =
__ATTR_RO(fuse_bpf);

static struct attribute *bpf_features[] = {
&fuse_bpf_attr.attr,
NULL,
};

static const struct attribute_group bpf_features_group = {
.name = "features",
.attrs = bpf_features,
};

/*
* TODO Remove this once fuse-bpf is upstreamed
*
* bpf_prog_type_fuse exports the bpf_prog_type_fuse 'constant', which cannot be
* constant until the code is upstreamed
*/
static ssize_t bpf_prog_type_fuse_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buff)
{
Expand All @@ -1873,6 +1897,13 @@ static struct attribute *bpf_attributes[] = {
static const struct attribute_group bpf_attr_group = {
.attrs = bpf_attributes,
};

static const struct attribute_group *attribute_groups[] = {
&bpf_features_group,
&bpf_attr_group,
NULL
};

/* TODO remove to here */

static int fuse_sysfs_init(void)
Expand All @@ -1890,7 +1921,7 @@ static int fuse_sysfs_init(void)
goto out_fuse_unregister;

/* TODO Remove when BPF_PROG_TYPE_FUSE is upstreamed */
err = sysfs_create_group(fuse_kobj, &bpf_attr_group);
err = sysfs_create_groups(fuse_kobj, attribute_groups);
if (err)
goto out_fuse_remove_mount_point;

Expand All @@ -1906,6 +1937,7 @@ static int fuse_sysfs_init(void)

static void fuse_sysfs_cleanup(void)
{
sysfs_remove_groups(fuse_kobj, attribute_groups);
sysfs_remove_mount_point(fuse_kobj, "connections");
kobject_put(fuse_kobj);
}
Expand Down

0 comments on commit 2a83701

Please sign in to comment.