Skip to content

Commit

Permalink
ata_id: Fixed getting Response Code from SCSI Sense Data (systemd#24921)
Browse files Browse the repository at this point in the history
The Response Code is contained in the first byte of the SCSI Sense Data.
Bit number 7 is reserved or has a different meaning for some Response Codes
and is set to 1 for some drives.
  • Loading branch information
Ratio2 authored and yuwata committed Oct 6, 2022
1 parent 4163c87 commit 2be1ae5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/udev/ata_id/ata_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ static int disk_identify_command(
return ret;
}

if (!(sense[0] == 0x72 && desc[0] == 0x9 && desc[1] == 0x0c) &&
!(sense[0] == 0x70 && sense[12] == 0x00 && sense[13] == 0x1d)) {
if (!((sense[0] & 0x7f) == 0x72 && desc[0] == 0x9 && desc[1] == 0x0c) &&
!((sense[0] & 0x7f) == 0x70 && sense[12] == 0x00 && sense[13] == 0x1d)) {
errno = EIO;
return -1;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ static int disk_identify_packet_device_command(
return ret;
}

if (!(sense[0] == 0x72 && desc[0] == 0x9 && desc[1] == 0x0c)) {
if (!((sense[0] & 0x7f) == 0x72 && desc[0] == 0x9 && desc[1] == 0x0c)) {
errno = EIO;
return -1;
}
Expand Down

0 comments on commit 2be1ae5

Please sign in to comment.