Hi,

As i took a peek at misc@, i've noticed that there was a
smartmontools fix for big endian archs [0] proposed by Marek on
upstream's GitHub [1].

Note that i'm only backporting that, the switch to the new interface
for OpenBSD requires way more patching.

It builds and works fine on macppc (M.2 SSD with PATA adapter), and
i tested it on amd64 as well.

Comments/feedback are welcome,

Charlène. 


[0] https://marc.info/?l=openbsd-misc&m=159138099215533&w=2
[1] https://github.com/smartmontools/smartmontools/pull/56


Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/smartmontools/Makefile,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 Makefile
--- Makefile    19 Feb 2020 17:46:52 -0000      1.43
+++ Makefile    14 Jun 2020 14:13:59 -0000
@@ -4,6 +4,7 @@ COMMENT=                control and monitor storage sy
 
 # XXX at update time check whether C++11 is actually needed
 DISTNAME=              smartmontools-7.1
+REVISION=              0
 CATEGORIES=            sysutils
 
 HOMEPAGE=              https://www.smartmontools.org/
Index: patches/patch-os_openbsd_cpp
===================================================================
RCS file: patches/patch-os_openbsd_cpp
diff -N patches/patch-os_openbsd_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-os_openbsd_cpp        14 Jun 2020 14:13:59 -0000
@@ -0,0 +1,123 @@
+$OpenBSD$
+
+From 61c49a66d6ee9df516fb9757c7fcce18ea508f6a Mon Sep 17 00:00:00 2001
+From: Marek Benc
+Date: Thu, 4 Jun 2020 16:49:48 +0200
+Subject: [PATCH] Fix runtime problems on big-engian OpenBSD platforms.
+Can be removed for smarmontools>7.1
+
+Index: os_openbsd.cpp
+--- os_openbsd.cpp.orig
++++ os_openbsd.cpp
+@@ -184,7 +184,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.command = ATAPI_SMART;
+     req.databuf = (caddr_t) inbuf;
+     req.datalen = sizeof(inbuf);
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.timeout = 1000;
+     copydata = 1;
+     break;
+@@ -194,7 +194,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.command = ATAPI_SMART;
+     req.databuf = (caddr_t) inbuf;
+     req.datalen = sizeof(inbuf);
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.timeout = 1000;
+     copydata = 1;
+     break;
+@@ -204,7 +204,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.command = ATAPI_SMART;
+     req.databuf = (caddr_t) inbuf;
+     req.datalen = sizeof(inbuf);
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.sec_num = select;
+     req.sec_count = 1;
+     req.timeout = 1000;
+@@ -217,7 +217,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.command = ATAPI_SMART;
+     req.databuf = (caddr_t) inbuf;
+     req.datalen = sizeof(inbuf);
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.sec_num = select;
+     req.sec_count = 1;
+     req.timeout = 1000;
+@@ -242,14 +242,14 @@ ata_command_interface(int fd, smart_command_set comman
+     req.flags = ATACMD_READ;
+     req.features = ATA_SMART_ENABLE;
+     req.command = ATAPI_SMART;
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.timeout = 1000;
+     break;
+   case DISABLE:
+     req.flags = ATACMD_READ;
+     req.features = ATA_SMART_DISABLE;
+     req.command = ATAPI_SMART;
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.timeout = 1000;
+     break;
+   case AUTO_OFFLINE:
+@@ -259,7 +259,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.command = ATAPI_SMART;
+     req.databuf = (caddr_t) inbuf;
+     req.datalen = sizeof(inbuf);
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.sec_num = select;
+     req.sec_count = 1;
+     req.timeout = 1000;
+@@ -268,7 +268,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.flags = ATACMD_READ;
+     req.features = ATA_SMART_AUTOSAVE;        /* XXX missing from wdcreg.h */
+     req.command = ATAPI_SMART;
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.sec_count = 0xf1;
+     /* to enable autosave */
+     req.timeout = 1000;
+@@ -280,7 +280,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.command = ATAPI_SMART;
+     req.databuf = (caddr_t) inbuf;
+     req.datalen = sizeof(inbuf);
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.sec_num = select;
+     req.sec_count = 1;
+     req.timeout = 1000;
+@@ -291,7 +291,7 @@ ata_command_interface(int fd, smart_command_set comman
+     req.flags = ATACMD_READ;
+     req.features = ATA_SMART_STATUS;
+     req.command = ATAPI_SMART;
+-    req.cylinder = htole16(WDSMART_CYL);
++    req.cylinder = WDSMART_CYL;
+     req.timeout = 1000;
+     break;
+   case CHECK_POWER_MODE:
+@@ -316,11 +316,11 @@ ata_command_interface(int fd, smart_command_set comman
+       return -1;
+     }
+     /* Cyl low and Cyl high unchanged means "Good SMART status" */
+-    if (letoh16(req.cylinder) == normal)
++    if (req.cylinder == normal)
+       return 0;
+ 
+     /* These values mean "Bad SMART status" */
+-    if (letoh16(req.cylinder) == failed)
++    if (req.cylinder == failed)
+       return 1;
+ 
+     /* We haven't gotten output that makes sense; 
+@@ -328,7 +328,7 @@ ata_command_interface(int fd, smart_command_set comman
+     snprintf(buf, sizeof(buf),
+       "CMD=0x%02x\nFR =0x%02x\nNS =0x%02x\nSC =0x%02x\nCL =0x%02x\nCH 
=0x%02x\nRETURN =0x%04x\n",
+       (int) req.command, (int) req.features, (int) req.sec_count, (int) 
req.sec_num,
+-      (int) (letoh16(req.cylinder) & 0xff), (int) ((letoh16(req.cylinder) >> 
8) & 0xff),
++      (int) (req.cylinder & 0xff), (int) ((req.cylinder >> 8) & 0xff),
+       (int) req.error);
+     printwarning(BAD_SMART, buf);
+     return 0;

Reply via email to