Re: [PATCH WIP 1/2] rust: debugfs: Add interface to build debugfs off pinned objects
From: Danilo Krummrich
Date: Sun May 04 2025 - 12:58:46 EST
On Sat, May 03, 2025 at 12:43:59AM +0000, Matthew Maurer wrote:
> +/// A DebugFS directory combined with a backing store for data to implement it.
> +#[pin_data]
> +pub struct Values<T> {
> + dir: Dir<'static, false>,
> + // The order here is load-bearing - `dir` must be dropped before `backing`, as files under
> + // `dir` may point into `backing`.
> + #[pin]
> + backing: T,
> + // Since the files present under our directory may point into `backing`, we are `!Unpin`.
> + #[pin]
> + _pin: PhantomPinned,
> +}
This only ever allows attaching data to the root directory, correct? What if I
want to remove (or replace) a file or a subdir? Then I'd be left with the data
for this specific file (or subdir) until the root is finally removed.
It would also require Option<V> (where V is the type of a field in T), if I
don't have an instance of V yet, when the root directory is created.
I think we should store the data per file, rather than per root directory.