rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Maurer <mmaurer@google.com>
To: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Timur Tabi" <ttabi@nvidia.com>
Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	 Matthew Maurer <mmaurer@google.com>
Subject: [PATCH v2 0/4] rust: DebugFS Bindings
Date: Wed, 30 Apr 2025 23:31:55 +0000	[thread overview]
Message-ID: <20250430-debugfs-rust-v2-0-2e8d3985812b@google.com> (raw)

This series provides safe DebugFS bindings for Rust, with a sample
driver using them.

This series currently only supports referencing `'static` lifetime
objects, because we need to know the objects outlive the DebugFS files.
A subsequent series may be able to relax this.

A few points that might be worth discussing on the API here:

1. The handles returned by directory and file creation currently remove
   themselves when they go out of scope. This behavior can be suppressed
   via `.keep()`. We could flip it to the other sense, and require that
   a returned handle be *explicitly* upconverted to get removed on drop.
   If we did this, we could consider making a different default for
   `subdir` vs `Dir::new`. The downside of doing this would be more
   complex types in the interface.
2. File creation currently returns a handle to preserve expressiveness
   (the ability to delete a file without deleting the directory it's
   in). I see (e.g. in ceph) explicit deletion of files, but this
   appears to be legacy code from before `recursive_remove` as opposed
   to wanting manual deletion. We could choose not to provide a handle
   here.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
---
Changes in v2:
- Drop support for builder / pinned bindings in initial series
- Remove `ARef` usage to abstract the dentry nature of handles
- Remove error handling to discourage users from caring whether DebugFS
  is enabled.
- Support CONFIG_DEBUG_FS=n while leaving the API available
- Fixed mistaken decimal/octal mixup
- Doc/comment cleanup
- Link to v1: https://lore.kernel.org/r/20250429-debugfs-rust-v1-0-6b6e7cb7929f@google.com

---
Matthew Maurer (4):
      rust: debugfs: Bind DebugFS directory creation
      rust: debugfs: Bind file creation for long-lived Display
      rust: debugfs: Support format hooks
      rust: samples: Add debugfs sample

 MAINTAINERS                     |   2 +
 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/debugfs.rs          | 345 ++++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs              |   1 +
 samples/rust/Kconfig            |  11 ++
 samples/rust/Makefile           |   1 +
 samples/rust/rust_debugfs.rs    |  37 +++++
 7 files changed, 398 insertions(+)
---
base-commit: b6a7783d306baf3150ac54cd5124f6e85dd375b0
change-id: 20250428-debugfs-rust-3cd5c97eb7d1

Best regards,
-- 
Matthew Maurer <mmaurer@google.com>


             reply	other threads:[~2025-04-30 23:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30 23:31 Matthew Maurer [this message]
2025-04-30 23:31 ` [PATCH v2 1/4] rust: debugfs: Bind DebugFS directory creation Matthew Maurer
2025-05-01 10:00   ` Miguel Ojeda
2025-05-01 10:16   ` Danilo Krummrich
2025-05-01 16:02     ` Matthew Maurer
2025-05-01 16:35       ` Danilo Krummrich
2025-04-30 23:31 ` [PATCH v2 2/4] rust: debugfs: Bind file creation for long-lived Display Matthew Maurer
2025-05-01 10:37   ` Danilo Krummrich
2025-05-01 16:09     ` Matthew Maurer
2025-05-01 17:32       ` Danilo Krummrich
2025-04-30 23:31 ` [PATCH v2 3/4] rust: debugfs: Support format hooks Matthew Maurer
2025-05-01 10:00   ` Miguel Ojeda
2025-04-30 23:31 ` [PATCH v2 4/4] rust: samples: Add debugfs sample Matthew Maurer
2025-05-01  7:40   ` Greg Kroah-Hartman
2025-05-01 16:44     ` Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250430-debugfs-rust-v2-0-2e8d3985812b@google.com \
    --to=mmaurer@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).