[PATCH v2 0/2] rust: debugfs: migrate debugfs traits requirements to zerocopy
Josef Ippisch via B4 Relay <[email protected]> Tue, 28 Jul 2026 19:31:18 +0200
| Newsgroups | dev.linux.lists.driver-core,org.kernel.feeds.b4-sent,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <20260728-migrate-binarywriter-to-zerocopy-intobytes-v2-0-0a4ec1d3ead4@mailbox.org> |
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 <[email protected]> Suggested-by: Miguel Ojeda <[email protected]> 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 <[email protected]> --- 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@mailbox.org --- 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(-) --- base-commit: 7059bdf4f04a3e14f4fafb3ac35fdca913e3e21a change-id: 20260719-migrate-binarywriter-to-zerocopy-intobytes-1e8f4ef93a60 Best regards, -- Josef Ippisch <[email protected]>