On Thu Jul 30, 2026 at 7:05 PM CEST, Alvin Sun wrote:
> +/// Renders `data` into a seq_file.
> +///
> +/// `data` is the value stashed as the debugfs file's `i_private` at creation
> +/// time. `show` is invoked on each read to produce the file's contents.
> +///
> +/// `open` and `release` are optional lifecycle hooks called during file open
> +/// and release. They can be used to manage the lifetime of `data` (e.g.,
> +/// reference counting). Default implementations are no-ops.
The open() and release() callbacks shouldn't be needed. The existing C (proxy
file ops) and Rust code already ensures to wait for in-flight file operations,
so show() can't run after debugfs_remove().
Both the existing Rust debugfs code and the DRM code use the full proxy fops.
> +pub trait SeqShow<T> {
> + /// Writes debugfs output for the file.
> + fn show(data: &T, m: &SeqFile) -> Result;
> +
> + /// Called during file open, before `single_open`.
> + fn open(_data: &T) -> Result {
> + Ok(())
> + }
> +
> + /// Called during file release, before `single_release`.
> + ///
> + /// # Safety
> + ///
> + /// `data` must point to valid memory, kept alive by actions taken in
> + /// [`Self::open`] (e.g., incrementing a reference count).
> + unsafe fn release(_data: NonNull<T>) {}
> +}