[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025043022-depletion-sneezing-a89c@gregkh>
Date: Wed, 30 Apr 2025 09:58:26 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Matthew Maurer <mmaurer@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH 4/8] rust: debugfs: Allow subdir creation in builder
interface
On Tue, Apr 29, 2025 at 11:15:58PM +0000, Matthew Maurer wrote:
> Allows creating subdirectories in the builder intended to be cleaned up
> by `debugfs_remove` at the same time as the root.
>
> Signed-off-by: Matthew Maurer <mmaurer@...gle.com>
> ---
> rust/kernel/debugfs.rs | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs
> index f6240fd056f8598d5ef06bdaf61c5c33eab5b734..6c7cf7e97741b98d2c0654d01fca3de0d8047e97 100644
> --- a/rust/kernel/debugfs.rs
> +++ b/rust/kernel/debugfs.rs
> @@ -347,6 +347,32 @@ pub fn display_file<T: Display + Sized>(&self, name: &CStr, data: &'a T) -> Resu
> core::mem::forget(unsafe { self.inner.display_file_raw(name, data)? });
> Ok(())
> }
> +
> + /// Creates a nested directory that may live as long as its parent
Ick, why make it complex?
> + ///
> + /// # Example
> + ///
> + /// ```
> + /// # use kernel::c_str;
> + /// # use kernel::debugfs::{Dir, Values};
> + /// let dir = Dir::new(c_str!("foo"), None)?;
Again, no checking please :)
> + /// let foo = KBox::pin_init(Values::attach(0, dir), GFP_KERNEL)?;
> + /// foo.as_ref().build(|_value, builder| {
> + /// builder.dir(c_str!("bar"))?;
> + /// Ok::<(), Error>(())
> + /// })?;
> + /// // foo/bar will still exist at this point in DebugFS
> + /// # Ok::<(), Error>(())
Again, no errors :)
thanks,
greg k-h
Powered by blists - more mailing lists