Re: [PATCH v2 0/2] rust: debugfs: migrate debugfs traits requirements to zerocopy
From: Greg Kroah-Hartman
Date: Fri Jul 31 2026 - 05:24:30 EST
On Tue, Jul 28, 2026 at 07:31:18PM +0200, Josef Ippisch via B4 Relay wrote:
> Migrate `BinaryWriter` and `BinaryReaderMut`'s default implementation's
> requirements on T from `kernel::transmute` traits to `zerocopy` traits.
>
> This is part of a bigger migration from rust/kernel/transmute.rs to the
> zerocopy crate, see also [1] and [2]
>
> [1] https://github.com/Rust-for-Linux/linux/issues/975
> [2] https://github.com/Rust-for-Linux/linux/issues/1241
>
> The crate zerocopy was introduced with
>
> c37398010a05 rust: zerocopy: import crate
>
> This introduced among other things the `FromBytes` and `IntoBytes` traits
> that, when derived, do better checks on the actual requirements of the
> types they are implemented on than the existing
> `kernel::transmute::FromBytes` and `kernel::transmute::AsBytes` traits,
> respectively.
>
> This is my first kernel patch so please let me know if I do anything wrong
> process wise or regarding some other aspect!
>
> I noticed that we could probably get rid of the `BinaryWriter` and
> `BinaryReaderMut` implementations for `Vec` altogether if we implemented
> `FromBytes`, `Immutable` and `IntoBytes` for `Vec`. These are already
> implemented for [T] after all. What do you think?
>
> Suggested-by: Joshua Liebow-Feeser <joshlf@xxxxxxxxxx>
> Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
> Link: https://github.com/Rust-for-Linux/linux/issues/975
> Link: https://github.com/Rust-for-Linux/linux/issues/1241
> Signed-off-by: Josef Ippisch <josef.ippisch.dev@xxxxxxxxxxx>
> ---
> Changes in v2:
> - Addresses Sashiko AI review's comment about also migrating
> `BinaryReaderMut` to zerocopy to not bifurcate the API requirements of
> debugfs/traits.rs.
> - Do not `use zerocopy::{FromBytes, IntoBytes}` as they are part of
> `use kernel::prelude::*`.
> - For some reason sending v2 via SMTP server did not reach the mailing
> list. I apologize if some of you receive this twice now. I did not
> mark this RESEND because of the email never reaching the mailing list.
> - Link to v1: https://patch.msgid.link/20260719-migrate-binarywriter-to-zerocopy-intobytes-v1-0-27ed30512e75@xxxxxxxxxxx
>
> ---
> Josef Ippisch (2):
> rust: debugfs: migrate debugfs traits requirements to zerocopy
> rust: debugfs: remove unsafe blocks from traits impl for Vec
>
> rust/kernel/debugfs/traits.rs | 41 +++++++++++------------------------------
> 1 file changed, 11 insertions(+), 30 deletions(-)
Always nice to delete code!
now queued up, thanks.
greg k-h