Re: [PATCH 2/5] common: add a _sysfs_block_integrity_path helper
Christoph Hellwig <[email protected]>
| Newsgroups | org.kernel.vger.linux-scsi,org.kernel.vger.fstests |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Aug 21, 2026 at 04:29:08PM -0700, Darrick J. Wong wrote: > On Fri, Aug 21, 2026 at 07:11:27AM +0200, Christoph Hellwig wrote: > > Add a helper function to find the sysfs integrity directory for a given > > block device. > > > > Signed-off-by: Christoph Hellwig <[email protected]> > > --- > > common/rc | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > > > diff --git a/common/rc b/common/rc > > index 02bdb31a76a6..61a899da3bd7 100644 > > --- a/common/rc > > +++ b/common/rc > > @@ -5257,6 +5257,31 @@ _sysfs_queue_path() > > fi > > } > > > > +# Get the sysfs block device integrity/ path for a block device, handling > > +# partitions correctly. > > +_sysfs_block_integrity_path() > > +{ > > + local dev parent > > + dev=$(_short_dev "$1") > > + > > + # For partitions, integrity details are in the parent device's sysfs dir > > + if [ -e "/sys/class/block/$dev/partition" ]; then > > + parent=$(basename "$(readlink -f /sys/class/block/$dev/..)") > > + else > > + parent="$dev" > > + fi > > I wonder if this part should get pulled out into a _sysfs_block_path > helper, since the code is already in _sysfs_queue_path? I guess. It's not much code, but it is identical.