[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <168479280062ccf6e0dd45c77fea474fb1791ab2.camel@nvidia.com>
Date: Wed, 7 May 2025 19:41:25 +0000
From: Timur Tabi <ttabi@...dia.com>
To: "tmgross@...ch.edu" <tmgross@...ch.edu>, "benno.lossin@...ton.me"
<benno.lossin@...ton.me>, "gregkh@...uxfoundation.org"
<gregkh@...uxfoundation.org>, "gary@...yguo.net" <gary@...yguo.net>,
"mmaurer@...gle.com" <mmaurer@...gle.com>, "a.hindborg@...nel.org"
<a.hindborg@...nel.org>, "bjorn3_gh@...tonmail.com"
<bjorn3_gh@...tonmail.com>, "boqun.feng@...il.com" <boqun.feng@...il.com>,
"dakr@...nel.org" <dakr@...nel.org>, "alex.gaynor@...il.com"
<alex.gaynor@...il.com>, "aliceryhl@...gle.com" <aliceryhl@...gle.com>,
"ojeda@...nel.org" <ojeda@...nel.org>, "rafael@...nel.org"
<rafael@...nel.org>, "samitolvanen@...gle.com" <samitolvanen@...gle.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v5 2/4] rust: debugfs: Bind file creation for long-lived
Display
On Mon, 2025-05-05 at 23:51 +0000, Matthew Maurer wrote:
> + /// Create a file in a DebugFS directory with the provided name, and contents from invoking
> + /// [`Display::fmt`] on the provided reference.
Is there a typo in this sentence? I can't quite parse it.
> + pub fn display_file<'b, T: Display + Sized>(
> + &'b self,
> + name: &CStr,
> + data: &'static T,
> + ) -> File<'b> {
> + // SAFETY:
> + // * `name` is a NUL-terminated C string, living across the call, by `CStr` invariant.
> + // * `parent` is a live `dentry` since we have a reference to it.
> + // * `vtable` is all stock `seq_file` implementations except for `open`.
> + // `open`'s only requirement beyond what is provided to all open functions is that the
> + // inode's data pointer must point to a `T` that will outlive it, which we know because
> + // we have a static reference.
> + #[cfg(CONFIG_DEBUG_FS)]
> + let ptr = unsafe {
> + bindings::debugfs_create_file_full(
> + name.as_char_ptr(),
> + 0o444,
Can you make the mode a parameter? I get that you're not supporting writing yet, but there should
be a choice as to whether it's 0o444, 0o440, or 0o400.
Also, maybe use S_IRUSR, S_IRGRP, and S_IROTH?
Powered by blists - more mailing lists