Fix that atactl sd0 readattr didn't work for some disks. Change it to
authoryasuoka <yasuoka@openbsd.org>
Sun, 30 Apr 2023 00:58:38 +0000 (00:58 +0000)
committeryasuoka <yasuoka@openbsd.org>
Sun, 30 Apr 2023 00:58:38 +0000 (00:58 +0000)
check the cksums of the attribute values instead of comparing the
revisions.  diff from NetBSD through naito.yuichiro at gmail.com. test
by kolipe.c at exoticsilicon.com.

ok kevlo miod deraadt

sbin/atactl/atactl.c

index 85dfced..2a47fc3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: atactl.c,v 1.48 2023/03/06 17:39:54 miod Exp $        */
+/*     $OpenBSD: atactl.c,v 1.49 2023/04/30 00:58:38 yasuoka Exp $     */
 /*     $NetBSD: atactl.c,v 1.4 1999/02/24 18:49:14 jwise Exp $ */
 
 /*-
@@ -1657,13 +1657,11 @@ device_attr(int argc, char *argv[])
        req.datalen = sizeof(attr_thr);
        ata_command(&req);
 
-       if (attr_val.revision != attr_thr.revision) {
-               /*
-                * Non standard vendor implementation.
-                * Return, since we don't know how to use this.
-                */
-               return;
-       }
+       if (smart_cksum((u_int8_t *)&attr_val, sizeof(attr_val)) != 0)
+               errx(1, "Checksum mismatch (attr_val)");
+
+       if (smart_cksum((u_int8_t *)&attr_thr, sizeof(attr_thr)) != 0)
+               errx(1, "Checksum mismatch (attr_thr)");
 
        attr = attr_val.attribute;
        thr = attr_thr.threshold;