]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: debugfs: Add support for callback-based files
authorMatthew Maurer <mmaurer@google.com>
Thu, 4 Sep 2025 21:13:55 +0000 (21:13 +0000)
committerDanilo Krummrich <dakr@kernel.org>
Wed, 10 Sep 2025 16:58:21 +0000 (18:58 +0200)
commit40ecc49466c8b7f9518c5fbbcfb24cb7e26c36c7
tree6cf8fe2e5cfcd1c7c4e2d93df75cfb110b44586a
parent839dc1d15b9ba5318ed145b20efffcfa91c02a3d
rust: debugfs: Add support for callback-based files

Extends the `debugfs` API to support creating files with content
generated and updated by callbacks. This is done via the
`read_callback_file`, `write_callback_file`, and
`read_write_callback_file` methods.

These methods allow for more flexible file definition, either because
the type already has a `Writer` or `Reader` method that doesn't
do what you'd like, or because you cannot implement it (e.g. because
it's a type defined in another crate or a primitive type).

Signed-off-by: Matthew Maurer <mmaurer@google.com>
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250904-debugfs-rust-v11-4-7d12a165685a@google.com
[ Fix up Result<(), Error> -> Result. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/debugfs.rs
rust/kernel/debugfs/callback_adapters.rs [new file with mode: 0644]
rust/kernel/debugfs/file_ops.rs