Skip to content

Conversation

@mwilck
Copy link

@mwilck mwilck commented Feb 13, 2024

This PR fixes missing output fields from sg_inq.

  1. with --export, the SCSI_MODEL, SCSI_MODEL_ENC, SCSI_REVISION, and other fields are missing.
  2. without --export, the "Unit serial number:" field is missing.

Fixes: 0f1230a ("sg_readcap+sg_luns: add --inhex= and json")
Signed-off-by: Martin Wilck mwilck@suse.com

The SCSI_MODEL, SCSI_MODEL_ENC, SCSI_REVISION, and other fields are
missing in the output of sg_inq with --export:

$ sg_inq /dev/sda
standard INQUIRY:
  PQual=0  PDT=0  RMB=0  LU_CONG=0  hot_pluggable=0  version=0x05  [SPC-3]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  [Linked=0]  [TranDis=0]  CmdQue=1
  [SPI: Clocking=0x0  QAS=0  IUS=0]
    length=96 (0x60)   Peripheral device type: disk
 Vendor identification: ATA
 Product identification: SK hynix SC300 M
 Product revision level: 0P00

$ sg_inq --export /dev/sda
SCSI_TPGS=0
SCSI_TYPE=disk
SCSI_VENDOR=ATA
SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20

The reason is that the parameter "len" is overwritten in std_inq_decode().
Fix it by using block-local variables for calculating field lengths.

Output after applying this patch:

$ sg_inq --export /dev/sda
SCSI_TPGS=0
SCSI_TYPE=disk
SCSI_VENDOR=ATA
SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20
SCSI_MODEL=SK_hynix_SC300_M
SCSI_MODEL_ENC=SK\x20hynix\x20SC300\x20M
SCSI_REVISION=0P00

Fixes: 0f1230a ("sg_readcap+sg_luns: add --inhex= and json")
Signed-off-by: Martin Wilck <mwilck@suse.com>
After 0f1230a ("sg_readcap+sg_luns: add --inhex= and json"), the
"Unit serial number" output field is missing from sg_inq output:

> ./sg_inq /dev/sda
standard INQUIRY:
  PQual=0  PDT=0  RMB=0  LU_CONG=0  hot_pluggable=0  version=0x05  [SPC-3]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  [Linked=0]  [TranDis=0]  CmdQue=1
  [SPI: Clocking=0x0  QAS=0  IUS=0]
    length=96 (0x60)   Peripheral device type: disk
  Vendor identification: ATA
  Product identification: SK hynix SC300 M
  Product revision level: 0P00

Previously, the command would also print

  Unit serial number: FJ63N456110303C1E

The problem is caused by checking "len" rather than op->maxlen
in the condition that's evaluated for printing the unit serial numnber.

Fixes: 0f1230a ("sg_readcap+sg_luns: add --inhex= and json")
Signed-off-by: Martin Wilck <mwilck@suse.com>
@mwilck mwilck changed the title sg_inq: fix missing output fields in --export format sg_inq: fix missing output fields Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant