]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
scsi: core: Add 'serial' sysfs attribute for SCSI/SATA
authorIgor Pylypiv <ipylypiv@google.com>
Mon, 9 Feb 2026 21:21:51 +0000 (13:21 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sun, 1 Mar 2026 01:03:00 +0000 (20:03 -0500)
commit94c125bafa00042daf6d63b4fdd78384abc121fc
treed797690008b105fcb28ab1e10fcf81932dce62c1
parent690d41fae92f0f255b1059d586bf064c63b5bfc3
scsi: core: Add 'serial' sysfs attribute for SCSI/SATA

Add a 'serial' sysfs attribute for SCSI and SATA devices. This attribute
exposes the Unit Serial Number, which is derived from the Device
Identification Vital Product Data (VPD) page 0x80.

Whitespace is stripped from the retrieved serial number to handle the
different alignment (right-aligned for SCSI, potentially left-aligned for
SATA). As noted in SAT-5 10.5.3, "Although SPC-5 defines the PRODUCT SERIAL
NUMBER field as right-aligned, ACS-5 does not require its SERIAL NUMBER
field to be right-aligned. Therefore, right-alignment of the PRODUCT SERIAL
NUMBER field for the translation is not assured."

This attribute is used by tools such as lsblk to display the serial number
of block devices.

[mkp: length adjustment]

Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://patch.msgid.link/20260209212151.342151-1-ipylypiv@google.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_sysfs.c
include/scsi/scsi_device.h