configfs: rust: add an API for adding default groups from C
Subsystems (4)
Andreas Hindborg
maintainerPATCH v2 1/1 configfs: rust: add an API for adding default groups from C
Some C subsystems provide a feature to add configfs default groups to the configfs hierarchy of other drivers or subsystems. Rust abstractions for these subsystems will want a way to add these default groups via the configfs Rust API. So add infrastructure to make this possible.
---
Changes in v2:
- Drop the spurious __ prefix on the symbol name of the configfs_remove_default_groups Rust helper (Alice).
- Wrap the body of Group::new in pin_init::pin_init_scope so that
allocation failure from KVec::push is propagated with ? instead
of panicking via unwrap (Danilo).
- Only build configfs rust helpers when configfs is enabled.
- Link to v1: https://msgid.link/[email protected]
To: Andreas Hindborg <[email protected]>
To: Boqun Feng <[email protected]>
To: Jens Axboe <[email protected]>
To: Miguel Ojeda <[email protected]>
To: Gary Guo <[email protected]>
To: Björn Roy Baron <[email protected]>
To: Benno Lossin <[email protected]>
To: Alice Ryhl <[email protected]>
To: Trevor Gross <[email protected]>
To: Danilo Krummrich <[email protected]>
To: Breno Leitao <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/block/rnull/configfs.rs | 1 + rust/helpers/configfs.c | 20 +++++++++++++ rust/helpers/helpers.c | 1 + rust/kernel/configfs.rs | 63 +++++++++++++++++++++++++++++++++-------- samples/rust/rust_configfs.rs | 8 +++++- 5 files changed, 80 insertions(+), 13 deletions(-)
drivers/block/rnull/configfs.rs +1 -0
@@ -76,6 +76,7 @@ fn make_group( name: name.try_into()?, }), }), + core::iter::empty(), )) } }
rust/helpers/configfs.c new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/configfs.h> + +#ifdef CONFIG_CONFIGFS_FS + +__rust_helper void +rust_helper_configfs_add_default_group (struct config_group *new_group, +struct config_group *group) +{ +configfs_add_default_group (new_group, group); +} + +__rust_helper void +rust_helper_configfs_remove_default_groups (struct config_group *group) +{ +configfs_remove_default_groups (group); +} + +#endif
rust/helpers/helpers.c +1 -0
@@ -51,6 +51,7 @@#include "build_bug.c" #include "clk.c" #include "completion.c" +#include "configfs.c" #include "cpu.c" #include "cpufreq.c" #include "cpumask.c"
rust/kernel/configfs.rs +51 -12
85 lines not on this page · raw message
samples/rust/rust_configfs.rs +7 -1
@@ -83,7 +83,12 @@ fn make_group(&self, name: &CStr) -> Result<impl PinInit<configfs::Group<Child>, ], }; -Ok (configfs::Group ::new (name.try_into ()?, tpe,Child ::new ())) +Ok (configfs::Group ::new ( + name.try_into ()?, + tpe, +Child ::new (), + core::iter::empty (), + )) } }
@@ -152,6 +157,7 @@ fn make_group(&self, name: &CStr) -> Result<impl PinInit<configfs::Group<GrandCh name.try_into()?, tpe, GrandChild::new(), + core::iter::empty(), )) } }
---
base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
change-id: 20260215-configfs-c-default-groups-bdb0a44633a6
Best regards,
Signature · 1 line
Andreas Hindborg <[email protected]>