From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 975E02F8EB0; Mon, 3 Aug 2026 15:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785770601; cv=none; b=AtBpG64Lfw7R1I6grlTvt8XJ+rWiQW/11J5ZWS4/yUgn8zk5SHmYFHFDgR14eh0F4UN7V8vdx9FEj5bynlvhOuto42JNlscb1Y8SttZMBnKg1CQifX118xNV+HX/zeOzOcVj9ldJ5iCZqjKzL6Tk0hMU8seoWZQQo4mSFTf2Ebg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785770601; c=relaxed/simple; bh=EP/91TNB8ZE38GEZ9jeQaJ09odZVPtG1g+tHlXxSuFM=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=pMYBuK6vjYxyPhsCjmcZIMUqLHYogpf6LdVDS0OjErGmN7827Spy7HS2NGCuje8e5W4/n4DxwX78IYnHacRjAFuaq5xEFlz8x0I7qSPmtunzSnvWBM+FT7xYVVkaJGp5hLTERLj5FrUnXv8tWPhPPmu9ohlXkMHzxASx1Xz+b0Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=McHnZ3pC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="McHnZ3pC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 854601F000E9; Mon, 3 Aug 2026 15:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785770600; bh=dZYSC8erIMTeSh377JsLNybfBrVvBlw03e2MC63a0C8=; h=Date:Subject:Cc:To:From:References:In-Reply-To; b=McHnZ3pCySk8fLXiiGo5wXe4OJjJWo58uagpdWKQDFTAx4nQ2d/r+SnOraAkdLDB2 A1/6uqdxAYJe+ts8DdgzcmgBs1M6SsykUmM6TY8LA9NQ21G6N24VLiu09lnKjz4E8G yu54GeI9py8SIpx9PkYNtM1dStanHHKTqYhy1GVXlWRouNoq2RpzJOSu558rndcYwe JRJfuxQc+8ZpHXEc5lBNnUMabSud9oBVFOqsYcML9IQpUVvvf4lQuU97UokHm8cHxj az87oZgxYJkw2hWxktzPnQxPr353on+nyeckr/kGMTtP/IgE1sWlQkXGNgyttr0FvC 0LmxW7b/V05Lg== Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 03 Aug 2026 17:23:12 +0200 Message-Id: Subject: Re: [PATCH v2 2/9] rust: debugfs: add SeqShow trait and seq_file file operations Cc: "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Daniel Almeida" , "Tamir Duberstein" , "Alexandre Courbot" , =?utf-8?q?Onur_=C3=96zkan?= , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Alexander Viro" , "Christian Brauner" , "Jan Kara" , "Matthew Brost" , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , =?utf-8?q?Ma=C3=ADra_Canal?= , "Melissa Wen" , "Wambui Karuga" , "Eric Anholt" , "Ben Gamari" , , , To: "Alvin Sun" From: "Danilo Krummrich" References: <20260731-tyr-debugfs-v2-v2-0-aea19eccb996@linux.dev> <20260731-tyr-debugfs-v2-v2-2-aea19eccb996@linux.dev> In-Reply-To: <20260731-tyr-debugfs-v2-v2-2-aea19eccb996@linux.dev> 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 cre= ation > +/// 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 (pro= xy file ops) and Rust code already ensures to wait for in-flight file operatio= ns, so show() can't run after debugfs_remove(). Both the existing Rust debugfs code and the DRM code use the full proxy fop= s. > +pub trait SeqShow { > + /// 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 i= n > + /// [`Self::open`] (e.g., incrementing a reference count). > + unsafe fn release(_data: NonNull) {} > +}