Update sysutils/smartmontools to version 7.0
[dports.git] / sysutils / smartmontools / files / patch-os__freebsd.cpp
1 Index: os_freebsd.cpp
2 ===================================================================
3 --- os_freebsd.cpp.orig 2018-12-05 18:30:46 UTC
4 +++ os_freebsd.cpp
5 @@ -9,6 +9,7 @@
6   */
7  
8  #include <sys/param.h>
9 +#include <sys/endian.h>
10  #include <stdio.h>
11  #include <sys/types.h>
12  #include <dirent.h>
13 @@ -522,29 +523,29 @@ bool freebsd_nvme_device::nvme_pass_through(const nvme
14    pt.cmd.opc = in.opcode;
15  #endif
16    pt.cmd.opc = in.opcode;
17 -  pt.cmd.nsid = in.nsid;
18 +  pt.cmd.nsid = htole32(in.nsid);
19    pt.buf = in.buffer;
20    pt.len = in.size;
21 -  pt.cmd.cdw10 = in.cdw10;
22 -  pt.cmd.cdw11 = in.cdw11;
23 -  pt.cmd.cdw12 = in.cdw12;
24 -  pt.cmd.cdw13 = in.cdw13;
25 -  pt.cmd.cdw14 = in.cdw14;
26 -  pt.cmd.cdw15 = in.cdw15;
27 +  pt.cmd.cdw10 = htole32(in.cdw10);
28 +  pt.cmd.cdw11 = htole32(in.cdw11);
29 +  pt.cmd.cdw12 = htole32(in.cdw12);
30 +  pt.cmd.cdw13 = htole32(in.cdw13);
31 +  pt.cmd.cdw14 = htole32(in.cdw14);
32 +  pt.cmd.cdw15 = htole32(in.cdw15);
33    pt.is_read = 1; // should we use in.direction()?
34    
35    int status = ioctl(get_fd(), NVME_PASSTHROUGH_CMD, &pt);
36  
37    if (status < 0)
38      return set_err(errno, "NVME_PASSTHROUGH_CMD: %s", strerror(errno));
39 -
40 +#if __FreeBSD_version >= 1200058
41 +  nvme_completion_swapbytes(&pt.cpl);
42 +#endif
43    cp_p = &pt.cpl;
44    out.result=cp_p->cdw0; // Command specific result (DW0)
45  
46    if (nvme_completion_is_error(cp_p)) {  /* ignore DNR and More bits */
47 -    uint16_t nvme_status = ((cp_p->status.sct << 8) | cp_p->status.sc) & 0x3ff;
48 -
49 -    return set_nvme_err(out, nvme_status);
50 +    return set_nvme_err(out, nvme_completion_is_error(&pt.cpl));
51    }
52  
53    return true;