[PATCH v2 0/8] Binary Large Objects for Rust DebugFS

Danilo Krummrich posted 8 patches 3 months, 2 weeks ago
There is a newer version of this series
rust/kernel/debugfs.rs              | 110 +++++++++++++++-
rust/kernel/debugfs/file_ops.rs     | 145 ++++++++++++++++++++-
rust/kernel/debugfs/traits.rs       | 190 +++++++++++++++++++++++++++-
rust/kernel/fs/file.rs              |   5 +
rust/kernel/uaccess.rs              |  49 +++++++
samples/rust/rust_debugfs.rs        |  13 ++
samples/rust/rust_debugfs_scoped.rs |  14 +-
7 files changed, 515 insertions(+), 11 deletions(-)
[PATCH v2 0/8] Binary Large Objects for Rust DebugFS
Posted by Danilo Krummrich 3 months, 2 weeks ago
This series adds support for exposing binary large objects via Rust debugfs.

The first two patches extend UserSliceReader and UserSliceWriter with partial
read/write helpers.

The series further introduces read_binary_file(), write_binary_file() and
read_write_binary_file() methods for the Dir and ScopedDir types.

It also introduces the BinaryWriter and BinaryReader traits, which are used to
read/write the implementing type's binary representation with the help of the
backing file operations from/to debugfs.

Additional to some more generic blanked implementations for the BinaryWriter and
BinaryReader traits it also provides implementations for common smart pointer
types.

Both samples (file-based and scoped) are updated with corresponding examples.

A branch containing the patches can be found in [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=debugfs_blobs

Changes in v2:
  - Add file::Offset type alias.
  - uaccess:
    - Saturate at buffer length on offset overflow.
    - Use file::Offset instead of usize.
  - debugfs:
    - Use file::Offset instead of usize.
    - Handle potential overflow when updating ppos.
    - Use &T::FILE_OPS directly if possible.
    - Fix safety comment in BinaryReaderMut::read_from_slice_mut().

Danilo Krummrich (8):
  rust: fs: add file::Offset type alias
  rust: uaccess: add UserSliceReader::read_slice_partial()
  rust: uaccess: add UserSliceWriter::write_slice_partial()
  rust: debugfs: support for binary large objects
  rust: debugfs: support blobs from smart pointers
  samples: rust: debugfs: add example for blobs
  rust: debugfs: support binary large objects for ScopedDir
  samples: rust: debugfs_scoped: add example for blobs

 rust/kernel/debugfs.rs              | 110 +++++++++++++++-
 rust/kernel/debugfs/file_ops.rs     | 145 ++++++++++++++++++++-
 rust/kernel/debugfs/traits.rs       | 190 +++++++++++++++++++++++++++-
 rust/kernel/fs/file.rs              |   5 +
 rust/kernel/uaccess.rs              |  49 +++++++
 samples/rust/rust_debugfs.rs        |  13 ++
 samples/rust/rust_debugfs_scoped.rs |  14 +-
 7 files changed, 515 insertions(+), 11 deletions(-)


base-commit: 340ccc973544a6e7e331729bc4944603085cafab
-- 
2.51.0
Re: [PATCH v2 0/8] Binary Large Objects for Rust DebugFS
Posted by Greg KH 3 months, 2 weeks ago
On Tue, Oct 21, 2025 at 12:26:12AM +0200, Danilo Krummrich wrote:
> This series adds support for exposing binary large objects via Rust debugfs.
> 
> The first two patches extend UserSliceReader and UserSliceWriter with partial
> read/write helpers.
> 
> The series further introduces read_binary_file(), write_binary_file() and
> read_write_binary_file() methods for the Dir and ScopedDir types.
> 
> It also introduces the BinaryWriter and BinaryReader traits, which are used to
> read/write the implementing type's binary representation with the help of the
> backing file operations from/to debugfs.
> 
> Additional to some more generic blanked implementations for the BinaryWriter and
> BinaryReader traits it also provides implementations for common smart pointer
> types.
> 
> Both samples (file-based and scoped) are updated with corresponding examples.
> 
> A branch containing the patches can be found in [1].
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=debugfs_blobs

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Re: [PATCH v2 0/8] Binary Large Objects for Rust DebugFS
Posted by Matthew Maurer 3 months, 2 weeks ago
On Tue, Oct 21, 2025 at 12:10 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Oct 21, 2025 at 12:26:12AM +0200, Danilo Krummrich wrote:
> > This series adds support for exposing binary large objects via Rust debugfs.
> >
> > The first two patches extend UserSliceReader and UserSliceWriter with partial
> > read/write helpers.
> >
> > The series further introduces read_binary_file(), write_binary_file() and
> > read_write_binary_file() methods for the Dir and ScopedDir types.
> >
> > It also introduces the BinaryWriter and BinaryReader traits, which are used to
> > read/write the implementing type's binary representation with the help of the
> > backing file operations from/to debugfs.
> >
> > Additional to some more generic blanked implementations for the BinaryWriter and
> > BinaryReader traits it also provides implementations for common smart pointer
> > types.
> >
> > Both samples (file-based and scoped) are updated with corresponding examples.
> >
> > A branch containing the patches can be found in [1].
> >
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=debugfs_blobs
>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: Matthew Maurer <mmaurer@google.com>