Skip to contentSkip to conversation

rust: configfs abstractions

PATCH Superseded Andreas Hindborg 4 participants 12 messages Feb 27, 2025 – May 1, 2025

Subsystems (4)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Andreas Hindborg

author maintainer
#0 lore raw

v5 cover rust: configfs abstractions

Add a safe Rust API that allows Rust modules to interface the configfs machinery.

Add an example for the samples folder to demonstrate usage of the API.

Add a maintainer entry for the Rust configfs abstractions in the last patch, to make it absolutely clear that I will commit to maintain these abstractions, if required.

The series is a dependency of rnull, the Rust null block driver. Please see [1] for initial configfs support in rnull.

[1] https://github.com/metaspace/linux/tree/9ac53130f5fb05b9b3074fa261b445b8fde547dd/drivers/block/rnull

---
Changes in v5:
- Remove as _ casts.
- Document ID type parameter of AttributeOperations.
- Add documentation at macro call sites in example.
- Add example expansion of configfs_attrs!.
- Move trait bound in AttributeList::add
- Improve safety requirement for AttributeList::new.
- Fix a copy/paste error in print in sample.
- Clarify use of {} for empty struct in sample.
- Improve documentation for AttributeList.
- Remove kernel:: prefix from container_of! invocation.
- Reword safety comment in get_group_data.
- Correct commit message in relation to unstable feature additions.
- Use imperative language in commit messages.
- Consistently capitalize the word "Rust" in commit messages.
- Explain that "drop" in GroupOperations::drop_item is not related to Rust drop.
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Fix a build issue by depending on v18 of "rust: types: add ForeignOwnable::PointedTo"
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Allow trailing commas in invocation of configfs_attrs!.
- Use a more suitable C initialization function when initializing Subsystem.
- Split sample into separate patch.
- Add an inline example.

The remaining changes in this version are style fixes, documentation improvements and typo fixes. They are enumerated below:
- Consolidate paste macro calls.
- Do not hard code page size in example.
- Remove prefix of c_str! in sample.
- Use a more descriptive variable name in into_foreign.
- Improve code formatting in macros invocations.
- Add comment related to null terminator in configfs_attrs!
- Move attributes below docstrings.
- Remove a rogue todo.
- Remove trait bound from struct definition GroupOperationsVTable.
- Remove as _ casts.
- Remove GroupOprations::Parent associated type.
- General documentation improvements.
- Explicitly use ArcBorrow for drop_item parameter type.
- Add a comment describing expansion to a call to Attribute::add.
- Add a comment explaining bound check in Attribute::add.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Remove generalization over pointer type and enforce use of Arc.
- Use type system to enforce connection between ItemType and Subsystem or Group. Differentiate construction of vtables on this type difference.
- Move drop logic of child nodes from parent to child.
- Pick ForeignOwnable::PointedTo patch as dependency instead of including it here.
- Fix some rustdoc warnings.
- Use CamelCase for generic type parameter declaration.
- Destroy mutex in Subsystem::drop.
- Move GroupOperationsVTable struct definition next to implementation.
- Rebase on v6.14-rc1.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Andreas Hindborg (4):
rust: sync: change <Arc<T> as ForeignOwnable>::PointedTo to T
rust: configfs: introduce rust support for configfs
rust: configfs: add a sample demonstrating configfs usage
MAINTAINERS: add entry for configfs Rust abstractions

 MAINTAINERS                     |    7 +
 rust/bindings/bindings_helper.h |    1 +
 rust/helpers/mutex.c            |    5 +
 rust/kernel/configfs.rs         | 1054 +++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs              |    2 +
 rust/kernel/sync/arc.rs         |   21 +-
 samples/rust/Kconfig            |   11 +
 samples/rust/Makefile           |    1 +
 samples/rust/rust_configfs.rs   |  192 +++++++
 9 files changed, 1289 insertions(+), 5 deletions(-)

---
base-commit: 379487e17ca406b47392e7ab6cf35d1c3bacb371
change-id: 20250131-configfs-b888cd82d84a
prerequisite-patch-id: 03c1bff48fd24e83d1383e98f8668300e665ebae

Best regards,

Signature · 1 line
Andreas Hindborg <[email protected]>
author maintainer
#1 lore raw

PATCH v5 1/4 rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

Using ArcInner as PoinedTo in the ForeignOwnable implementation for Arc is a bit unfortunate. Using T as PointedTo does not remove any functionality, but allows ArcInner to be private. Further, it allows downstream users to write code that is generic over Box and Arc, when downstream users need access to T after calling into_foreign.

---

This patch is a dependency for Rust configfs abstractions. It allows both Box and Arc to be used as pointer types in the configfs hierarchy.

---
 rust/kernel/sync/arc.rs | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
rust/kernel/sync/arc.rs +16 -5
index dfe4abf82c25..3d77a31e116f 100644
@@ -143,7 +143,7 @@ pub struct Arc<T: ?Sized> {
 #[doc(hidden)]
 #[pin_data]
 #[repr(C)]
-pub struct ArcInner<T: ?Sized> {
+struct ArcInner<T: ?Sized> {
     refcount: Opaque<bindings::refcount_t>,
     data: T,
 }
@@ -345,18 +345,25 @@ pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> {
 
 // SAFETY: The `into_foreign` function returns a pointer that is well-aligned.
 unsafe impl<T: 'static> ForeignOwnable for Arc<T> {
-    type PointedTo = ArcInner<T>;
+    type PointedTo = T;
     type Borrowed<'a> = ArcBorrow<'a, T>;
     type BorrowedMut<'a> = Self::Borrowed<'a>;
 
     fn into_foreign(self) -> *mut Self::PointedTo {
-        ManuallyDrop::new(self).ptr.as_ptr()
+        let this = ManuallyDrop::new(self).ptr.as_ptr();
+        // SAFETY: `x` is a valid pointer to `Self` so the projection below is
+        // in bounds of the allocation.
+        unsafe { core::ptr::addr_of_mut!((*this).data) }
     }
 
     unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self {
+        // SAFETY: We did the reverse offset calculation in `into_foreign`, so
+        // the offset calculation below is in bounds of the allocation.
+        let inner_ptr = unsafe { kernel::container_of!(ptr, ArcInner<T>, data).cast_mut() };
+
         // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
         // call to `Self::into_foreign`.
-        let inner = unsafe { NonNull::new_unchecked(ptr) };
+        let inner = unsafe { NonNull::new_unchecked(inner_ptr) };
 
         // SAFETY: By the safety requirement of this function, we know that `ptr` came from
         // a previous call to `Arc::into_foreign`, which guarantees that `ptr` is valid and
@@ -365,9 +372,13 @@ unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self {
     }
 
     unsafe fn borrow<'a>(ptr: *mut Self::PointedTo) -> ArcBorrow<'a, T> {
+        // SAFETY: We did the reverse offset calculation in `into_foreign`, so
+        // the offset calculation below is in bounds of the allocation.
+        let inner_ptr = unsafe { kernel::container_of!(ptr, ArcInner<T>, data).cast_mut() };
+
         // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
         // call to `Self::into_foreign`.
-        let inner = unsafe { NonNull::new_unchecked(ptr) };
+        let inner = unsafe { NonNull::new_unchecked(inner_ptr) };
 
         // SAFETY: The safety requirements of `from_foreign` ensure that the object remains alive
         // for the lifetime of the returned value.
Signature · 1 line
2.47.0
Reviewed-by on v5 1/4
#2 lore raw

Re: [PATCH v5 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

Quoted 36 lines · Andreas Hindborg

Using ArcInner as PoinedTo in the ForeignOwnable implementation for Arc is a bit unfortunate. Using T as PointedTo does not remove any functionality, but allows ArcInner to be private. Further, it allows downstream users to write code that is generic over Box and Arc, when downstream users need access to T after calling into_foreign.

---

This patch is a dependency for Rust configfs abstractions. It allows both Box and Arc to be used as pointer types in the configfs hierarchy.

---
 rust/kernel/sync/arc.rs | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
rust/kernel/sync/arc.rs +1 -1
index dfe4abf82c25..3d77a31e116f 100644
@@ -143,7 +143,7 @@ pub struct Arc<T: ?Sized> {
 #[doc(hidden)]
 #[pin_data]
 #[repr(C)]
-pub struct ArcInner<T: ?Sized> {
+struct ArcInner<T: ?Sized> {
     refcount: Opaque<bindings::refcount_t>,
     data: T,
 }
@@ -345,18 +345,25 @@ pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> {
 
 // SAFETY: The `into_foreign` function returns a pointer that is well-aligned.
 unsafe impl<T: 'static> ForeignOwnable for Arc<T> {

rust/kernel/sync/arc.rs pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> { · line 355

Quoted 10 lines
rust/kernel/sync/arc.rs +4 -2
-    type PointedTo = ArcInner<T>;
+    type PointedTo = T;
     type Borrowed<'a> = ArcBorrow<'a, T>;
     type BorrowedMut<'a> = Self::Borrowed<'a>;
 
     fn into_foreign(self) -> *mut Self::PointedTo {
-        ManuallyDrop::new(self).ptr.as_ptr()
+        let this = ManuallyDrop::new(self).ptr.as_ptr();
+        // SAFETY: `x` is a valid pointer to `Self` so the projection below is
+        // in bounds of the allocation.

Isn't the unsafe bit *this, which is what this comment should justify? In Rust 1.82+ addr_of_mut! isn't unsafe I believe. Also x is likely meant to be this.

Quoted 20 lines
rust/kernel/sync/arc.rs +7 -1
+        unsafe { core::ptr::addr_of_mut!((*this).data) }
     }
 
     unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self {
+        // SAFETY: We did the reverse offset calculation in `into_foreign`, so
+        // the offset calculation below is in bounds of the allocation.
+        let inner_ptr = unsafe { kernel::container_of!(ptr, ArcInner<T>, data).cast_mut() };
+
         // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
         // call to `Self::into_foreign`.
-        let inner = unsafe { NonNull::new_unchecked(ptr) };
+        let inner = unsafe { NonNull::new_unchecked(inner_ptr) };
 
         // SAFETY: By the safety requirement of this function, we know that `ptr` came from
         // a previous call to `Arc::into_foreign`, which guarantees that `ptr` is valid and
@@ -365,9 +372,13 @@ unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self {
     }
 
     unsafe fn borrow<'a>(ptr: *mut Self::PointedTo) -> ArcBorrow<'a, T> {
+        // SAFETY: We did the reverse offset calculation in `into_foreign`, so

rust/kernel/sync/arc.rs unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self { · line 384

Quoted 10 lines
rust/kernel/sync/arc.rs +4 -1
+        // the offset calculation below is in bounds of the allocation.
+        let inner_ptr = unsafe { kernel::container_of!(ptr, ArcInner<T>, data).cast_mut() };
+
         // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
         // call to `Self::into_foreign`.
-        let inner = unsafe { NonNull::new_unchecked(ptr) };
+        let inner = unsafe { NonNull::new_unchecked(inner_ptr) };
 
         // SAFETY: The safety requirements of `from_foreign` ensure that the object remains alive
         // for the lifetime of the returned value.

It might be good to extract a shared helper from from_foreign and borrow, though the duplication isn't new in this patch. Either way:

#3 lore raw

Re: [PATCH v5 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

Quoted 4 lines · Tamir Duberstein

Isn't the unsafe bit *this, which is what this comment should justify? In Rust 1.82+ addr_of_mut! isn't unsafe I believe. Also x is likely meant to be this.

addr_of_mut! could also be called safely in many cases even before 1.82, i.e. it depends on the expression (and that is still true in 1.82+). The change in that version was about referring to static muts and extern statics.

Cheers,
Miguel

#4 lore raw

Re: [PATCH v5 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

Quoted 11 lines · Miguel Ojeda
Quoted 4 lines · Tamir Duberstein

Isn't the unsafe bit *this, which is what this comment should justify? In Rust 1.82+ addr_of_mut! isn't unsafe I believe. Also x is likely meant to be this.

addr_of_mut! could also be called safely in many cases even before 1.82, i.e. it depends on the expression (and that is still true in 1.82+). The change in that version was about referring to static muts and extern statics.

Thanks for explaining! Was I correct about the unsafe operation here being the dereference?

author maintainer
#5 lore raw

Re: [PATCH v5 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

In reply to Tamir Duberstein
Quoted 42 lines · Tamir Duberstein
Quoted 41 lines · Andreas Hindborg

Using ArcInner as PoinedTo in the ForeignOwnable implementation for Arc is a bit unfortunate. Using T as PointedTo does not remove any functionality, but allows ArcInner to be private. Further, it allows downstream users to write code that is generic over Box and Arc, when downstream users need access to T after calling into_foreign.

---

This patch is a dependency for Rust configfs abstractions. It allows both Box and Arc to be used as pointer types in the configfs hierarchy.

---
 rust/kernel/sync/arc.rs | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
rust/kernel/sync/arc.rs +2 -2
index dfe4abf82c25..3d77a31e116f 100644
@@ -143,7 +143,7 @@ pub struct Arc<T: ?Sized> {
 #[doc(hidden)]
 #[pin_data]
 #[repr(C)]
-pub struct ArcInner<T: ?Sized> {
+struct ArcInner<T: ?Sized> {
     refcount: Opaque<bindings::refcount_t>,
     data: T,
 }
@@ -345,18 +345,25 @@ pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> {
 
 // SAFETY: The `into_foreign` function returns a pointer that is well-aligned.
 unsafe impl<T: 'static> ForeignOwnable for Arc<T> {
-    type PointedTo = ArcInner<T>;
+    type PointedTo = T;
     type Borrowed<'a> = ArcBorrow<'a, T>;
     type BorrowedMut<'a> = Self::Borrowed<'a>;
 
Quoted 8 lines

rust/kernel/sync/arc.rs pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> { · line 355

Quoted 5 lines
rust/kernel/sync/arc.rs +3 -1
     fn into_foreign(self) -> *mut Self::PointedTo {
-        ManuallyDrop::new(self).ptr.as_ptr()
+        let this = ManuallyDrop::new(self).ptr.as_ptr();
+        // SAFETY: `x` is a valid pointer to `Self` so the projection below is
+        // in bounds of the allocation.

Isn't the unsafe bit *this, which is what this comment should justify?

Yes, not sure what the origin of that name is. Good catch.

Quoted 2 lines

In Rust 1.82+ addr_of_mut! isn't unsafe I believe. Also x is likely meant to be this.

The field projection (*this).data is still unsafe, as far as I know.

Actually the macro is not required any longer, the underlying raw reference syntax has been stabilized. But since our minimum rust version is 1.78, we have to keep the macro.

Quoted 29 lines
Quoted 29 lines
rust/kernel/sync/arc.rs +11 -2
+        unsafe { core::ptr::addr_of_mut!((*this).data) }
     }
 
     unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self {
+        // SAFETY: We did the reverse offset calculation in `into_foreign`, so
+        // the offset calculation below is in bounds of the allocation.
+        let inner_ptr = unsafe { kernel::container_of!(ptr, ArcInner<T>, data).cast_mut() };
+
         // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
         // call to `Self::into_foreign`.
-        let inner = unsafe { NonNull::new_unchecked(ptr) };
+        let inner = unsafe { NonNull::new_unchecked(inner_ptr) };
 
         // SAFETY: By the safety requirement of this function, we know that `ptr` came from
         // a previous call to `Arc::into_foreign`, which guarantees that `ptr` is valid and
@@ -365,9 +372,13 @@ unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self {
     }
 
     unsafe fn borrow<'a>(ptr: *mut Self::PointedTo) -> ArcBorrow<'a, T> {
+        // SAFETY: We did the reverse offset calculation in `into_foreign`, so
+        // the offset calculation below is in bounds of the allocation.
+        let inner_ptr = unsafe { kernel::container_of!(ptr, ArcInner<T>, data).cast_mut() };
+
         // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous
         // call to `Self::into_foreign`.
-        let inner = unsafe { NonNull::new_unchecked(ptr) };
+        let inner = unsafe { NonNull::new_unchecked(inner_ptr) };
 
Quoted 5 lines

rust/kernel/sync/arc.rs unsafe fn from_foreign(ptr: *mut Self::PointedTo) -> Self { · line 384

Quoted 2 lines
rust/kernel/sync/arc.rs +0 -0
         // SAFETY: The safety requirements of `from_foreign` ensure that the object remains alive
         // for the lifetime of the returned value.

It might be good to extract a shared helper from from_foreign and borrow, though the duplication isn't new in this patch. Either way:

I would encourage a follow-up patch :)

Quoted 2 lines

Thanks!

Best regards,
Andreas Hindborg

author maintainer
#6 lore raw

Re: [PATCH v5 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

Quoted 53 lines · Andreas Hindborg
Quoted 42 lines · Tamir Duberstein
Quoted 41 lines · Andreas Hindborg

Using ArcInner as PoinedTo in the ForeignOwnable implementation for Arc is a bit unfortunate. Using T as PointedTo does not remove any functionality, but allows ArcInner to be private. Further, it allows downstream users to write code that is generic over Box and Arc, when downstream users need access to T after calling into_foreign.

---

This patch is a dependency for Rust configfs abstractions. It allows both Box and Arc to be used as pointer types in the configfs hierarchy.

---
 rust/kernel/sync/arc.rs | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
rust/kernel/sync/arc.rs +2 -2
index dfe4abf82c25..3d77a31e116f 100644
@@ -143,7 +143,7 @@ pub struct Arc<T: ?Sized> {
 #[doc(hidden)]
 #[pin_data]
 #[repr(C)]
-pub struct ArcInner<T: ?Sized> {
+struct ArcInner<T: ?Sized> {
     refcount: Opaque<bindings::refcount_t>,
     data: T,
 }
@@ -345,18 +345,25 @@ pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> {
 
 // SAFETY: The `into_foreign` function returns a pointer that is well-aligned.
 unsafe impl<T: 'static> ForeignOwnable for Arc<T> {
-    type PointedTo = ArcInner<T>;
+    type PointedTo = T;
     type Borrowed<'a> = ArcBorrow<'a, T>;
     type BorrowedMut<'a> = Self::Borrowed<'a>;
 
Quoted 8 lines

rust/kernel/sync/arc.rs pub fn into_unique_or_drop(self) -> Option<Pin<UniqueArc<T>>> { · line 355

Quoted 5 lines
rust/kernel/sync/arc.rs +3 -1
     fn into_foreign(self) -> *mut Self::PointedTo {
-        ManuallyDrop::new(self).ptr.as_ptr()
+        let this = ManuallyDrop::new(self).ptr.as_ptr();
+        // SAFETY: `x` is a valid pointer to `Self` so the projection below is
+        // in bounds of the allocation.

Isn't the unsafe bit *this, which is what this comment should justify?

Quoted 1 line

Yes, not sure what the origin of that name is. Good catch.

Referring to the x part here.

Best regards,
Andreas Hindborg

maintainer
#7 lore raw

Re: [PATCH v5 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T`

In reply to Andreas Hindborg
Quoted 11 lines · Andreas Hindborg

Using ArcInner as PoinedTo in the ForeignOwnable implementation for Arc is a bit unfortunate. Using T as PointedTo does not remove any functionality, but allows ArcInner to be private. Further, it allows downstream users to write code that is generic over Box and Arc, when downstream users need access to T after calling into_foreign.

We discussed this in the meeting yesterday, but just to summarize:

This isn't correct use of the trait. The trait is intended for cases where you pass a void pointer into C code, and the C code treats that void pointer entirely opaquely. That's why the docs for into_foreign say this:

The foreign representation is a pointer to void. There are no guarantees for this pointer. For example, it might be invalid, dangling or pointing to uninitialized memory. Using it in any way except for [from_foreign], [try_from_foreign], [borrow], or [borrow_mut] can result in undefined behavior.

In this case, you want to make this change because the C code in configfs will dereference the void pointer and read from it. But that's not allowed with the ForeignOwnable trait. You need a new trait if you want pointers that are not opaque.

Alice

author maintainer
#8 lore raw

PATCH v5 2/4 rust: configfs: introduce rust support for configfs

In reply to Andreas Hindborg

Add a Rust API for configfs, thus allowing Rust modules to use configfs for configuration. Make the implementation a shim on top of the C configfs implementation, allowing safe use of the C infrastructure from Rust.

---

This patch is a direct dependency for rnull, the rust null block driver.

---
 rust/bindings/bindings_helper.h |    1 +
 rust/helpers/mutex.c            |    5 +
 rust/kernel/configfs.rs         | 1054 +++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs              |    2 +
 4 files changed, 1062 insertions(+)
rust/bindings/bindings_helper.h +1 -0
index 55354e4dec14..d115a770306f 100644
@@ -10,6 +10,7 @@
 #include <linux/blk-mq.h>
 #include <linux/blk_types.h>
 #include <linux/blkdev.h>
+#include <linux/configfs.h>
 #include <linux/cred.h>
 #include <linux/errname.h>
 #include <linux/ethtool.h>
rust/helpers/mutex.c +5 -0
index 06575553eda5..3e9b910a88e9 100644
@@ -17,3 +17,8 @@ void rust_helper_mutex_assert_is_held(struct mutex *mutex)
 {
 	lockdep_assert_held(mutex);
 }
+
+void rust_helper_mutex_destroy(struct mutex *lock)
+{
+	mutex_destroy(lock);
+}
rust/kernel/configfs.rs new file +1054 -0

1,054 lines not on this page · raw message

rust/kernel/lib.rs +2 -0
index 496ed32b0911..ec84653ab8c7 100644
@@ -40,6 +40,8 @@
 pub mod block;
 #[doc(hidden)]
 pub mod build_assert;
+#[cfg(CONFIG_CONFIGFS_FS)]
+pub mod configfs;
 pub mod cred;
 pub mod device;
 pub mod device_id;
Signature · 1 line
2.47.0
author maintainer
#9 lore raw

PATCH v5 3/4 rust: configfs: add a sample demonstrating configfs usage

In reply to Andreas Hindborg

Add a sample to the samples folder, demonstrating the intended use of the Rust configfs API.

---
 samples/rust/Kconfig          |  11 +++
 samples/rust/Makefile         |   1 +
 samples/rust/rust_configfs.rs | 192 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 204 insertions(+)
samples/rust/Kconfig +11 -0
index 918dbead2c0b..2f97bf9a7b4c 100644
@@ -10,6 +10,17 @@ menuconfig SAMPLES_RUST
 
 if SAMPLES_RUST
 
+config SAMPLE_RUST_CONFIGFS
+	tristate "Configfs sample"
+	depends on CONFIGFS_FS
+	help
+	  This option builds the Rust configfs sample.
+
+	  To compile this as a module, choose M here:
+	  the module will be called rust_configfs.
+
+	  If unsure, say N.
+
 config SAMPLE_RUST_MINIMAL
 	tristate "Minimal"
 	help
samples/rust/Makefile +1 -0
index 5a8ab0df0567..72122f010caf 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_SAMPLE_RUST_MISC_DEVICE)		+= rust_misc_device.o
 obj-$(CONFIG_SAMPLE_RUST_PRINT)			+= rust_print.o
 obj-$(CONFIG_SAMPLE_RUST_DRIVER_PCI)		+= rust_driver_pci.o
 obj-$(CONFIG_SAMPLE_RUST_DRIVER_PLATFORM)	+= rust_driver_platform.o
+obj-$(CONFIG_SAMPLE_RUST_CONFIGFS)		+= rust_configfs.o
 
 rust_print-y := rust_print_main.o rust_print_events.o
 
samples/rust/rust_configfs.rs new file +192 -0

192 lines not on this page · raw message

Signature · 1 line
2.47.0
author maintainer
#10 lore raw

PATCH v5 4/4 MAINTAINERS: add entry for configfs Rust abstractions

In reply to Andreas Hindborg

Update MAINTAINERS with entry for Rust configfs abstractions.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 896a307fa065..9b4d5c12eb43 100644
@@ -5870,6 +5870,13 @@ F:	fs/configfs/
 F:	include/linux/configfs.h
 F:	samples/configfs/
 
+CONFIGFS [RUST]
+M:	Andreas Hindborg <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	rust/kernel/configfs.rs
+F:	samples/rust/rust_configfs.rs
+
 CONGATEC BOARD CONTROLLER MFD DRIVER
 M:	Thomas Richard <[email protected]>
 S:	Maintained
Signature · 1 line
2.47.0
author maintainer
#11 lore raw
In reply to Andreas Hindborg

Hi Joel,

Quoted 9 lines · Andreas Hindborg

Add a safe Rust API that allows Rust modules to interface the configfs machinery.

Add an example for the samples folder to demonstrate usage of the API.

Add a maintainer entry for the Rust configfs abstractions in the last patch, to make it absolutely clear that I will commit to maintain these abstractions, if required.

Quoted 6 lines

The series is a dependency of rnull, the Rust null block driver. Please see [1] for initial configfs support in rnull.

[1] https://github.com/metaspace/linux/tree/9ac53130f5fb05b9b3074fa261b445b8fde547dd/drivers/block/rnull

Since you are not responding to my emails, I must assume that either you did not see them, you are too busy to respond, or you are ignoring them.

Please note that if the lack of response is due to you being busy, my offer to help out with C configfs still stands [1].

If I do not hear anything back from you, I will have to ask for these patches to be routed through the rust subsystem tree instead of the configfs tree.

Best regards,
Andreas Hindborg

[1] https://lore.kernel.org/all/[email protected]/