]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ata_id: Fixed getting Response Code from SCSI Sense Data (#24921)
authorAleksey Vasenev <margtu-fivt@ya.ru>
Wed, 5 Oct 2022 19:33:53 +0000 (22:33 +0300)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 6 Oct 2022 04:50:30 +0000 (13:50 +0900)
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.

src/udev/ata_id/ata_id.c

index f451c0d0e15a8b49d5833de9ac7a8ccb1873bac5..bae4d03b4f43b66fdbc0b551ca9e1b15e8ccda56 100644 (file)
@@ -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;
         }
@@ -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;
         }