Re: [PATCH v4 2/4] rust: debugfs: Bind file creation for long-lived Display
From: Danilo Krummrich
Date: Sat May 03 2025 - 08:44:52 EST
On Fri, May 02, 2025 at 07:49:31PM +0000, Matthew Maurer wrote:
> +/// Handle to a DebugFS file.
> +#[repr(transparent)]
> +pub struct File<'a>(Dir<'a, true>);
As mentioned in [1], please create a base type Entry. While it's an improvement
to not expose things like subdir() from File directly, it's still odd to base
File on a type that has invalid methods its purpose.
[1] https://lore.kernel.org/lkml/aBRrniLfCzWX7nbR@pollux/
> +impl<'a> File<'a> {
> + /// Remove the file from DebugFS.
> + ///
> + /// # Examples
> + /// ```
> + /// # use kernel::c_str;
> + /// # use kernel::debugfs::Dir;
> + /// let dir = Dir::new(c_str!("foo"));
> + /// let file = dir.display_file(c_str!("bar"), &0);
> + /// // "foo/bar" is created.
> + /// file.remove()
> + /// // "foo/bar" is removed"
> + pub fn remove(self) {
> + drop(self.0.owning())
> + }
Same as with Dir, please make it the other way around.