From: yasuoka Date: Sun, 30 Apr 2023 00:58:38 +0000 (+0000) Subject: Fix that atactl sd0 readattr didn't work for some disks. Change it to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5095123fcd621e1f1356d8fda42ce7aeb7e57f5b;p=openbsd Fix that atactl sd0 readattr didn't work for some disks. Change it to 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 --- diff --git a/sbin/atactl/atactl.c b/sbin/atactl/atactl.c index 85dfced8c9a..2a47fc30b3a 100644 --- a/sbin/atactl/atactl.c +++ b/sbin/atactl/atactl.c @@ -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;