]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - os_darwin.cpp
import smartmontools 7.0
[mirror_smartmontools-debian.git] / os_darwin.cpp
index 134f510efa9467ccad01d8ddbe36a2430a58d998..e2638c791b150b109bed5e9a9492898370c59550 100644 (file)
@@ -6,14 +6,7 @@
  * Copyright (C) 2004-8 Geoffrey Keating <geoffk@geoffk.org>
  * Copyright (C) 2014 Alex Samorukov <samm@os2.kiev.ua>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with smartmontools.  If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include <stdbool.h>
@@ -35,7 +28,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 
 #include "config.h"
-#include "int64.h"
+
 #include "atacmds.h"
 #include "scsicmds.h"
 #include "nvmecmds.h"
 
 #define ARGUSED(x) ((void)(x))
 // Needed by '-V' option (CVS versioning) of smartd/smartctl
-const char *os_darwin_cpp_cvsid="$Id: os_darwin.cpp 4552 2017-10-11 10:11:35Z samm2 $" \
-ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_DARWIN_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
+const char *os_darwin_cpp_cvsid="$Id: os_darwin.cpp 4831 2018-11-09 07:18:23Z samm2 $" \
+ATACMDS_H_CVSID CONFIG_H_CVSID OS_DARWIN_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 // examples for smartctl
 static const char  smartctl_examples[] =
          "=================================================== SMARTCTL EXAMPLES =====\n\n"
          "  smartctl -a disk0                            (Prints all SMART information)\n\n"
          "  smartctl -t long /dev/disk0              (Executes extended disk self-test)\n\n"
-#ifdef HAVE_GETOPT_LONG
          "  smartctl --smart=on --saveauto=on /dev/rdisk0 (Enables SMART on first disk)\n\n"
          "  smartctl --attributes --log=selftest --quietmode=errorsonly /dev/disk0\n"
          "                                        (Prints Self-Test & Attribute errors)\n\n"
-#else
-         "  smartctl -s on -S on /dev/rdisk0              (Enables SMART on first disk)\n\n"
-         "  smartctl -A -l selftest -q errorsonly /dev/disk0\n"
-         "                                        (Prints Self-Test & Attribute errors)\n\n"
-#endif
          "  smartctl -a IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/ata-6@D/AppleKauaiATA/ATADeviceNub@0/IOATABlockStorageDriver/IOATABlockStorageDevice\n"
          "                                                 (You can use IOService: ...)\n\n"
          "  smartctl -c IODeviceTree:/pci@f4000000/ata-6@D/@0:0\n"
@@ -78,7 +65,7 @@ static struct {
   IONVMeSMARTInterface **smartIfNVMe;
 } devices[20];
 
-const char * dev_darwin_cpp_cvsid = "$Id: os_darwin.cpp 4552 2017-10-11 10:11:35Z samm2 $"
+const char * dev_darwin_cpp_cvsid = "$Id: os_darwin.cpp 4831 2018-11-09 07:18:23Z samm2 $"
   DEV_INTERFACE_H_CVSID;
 
 /////////////////////////////////////////////////////////////////////////////
@@ -367,9 +354,9 @@ static int make_device_names (char*** devlist, const char* name) {
   {
     for (index = 0; index < result; index++)
       if ((*devlist)[index])
-      free ((*devlist)[index]);
-      free (*devlist);
-    }
+        free ((*devlist)[index]);
+    free (*devlist);
+  }
   if(!result) // no devs found
     return 0;
 
@@ -416,7 +403,7 @@ bool darwin_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & ou
   int rc = 0;
   
   if (! ifp)
-    return -1;
+    return false;
   smartIf = *ifp;
   clear_err(); errno = 0;
   do {
@@ -470,8 +457,9 @@ bool darwin_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & ou
             err = -1; // thresholds exceeded condition
             out.out_regs.lba_high = 0x2c; out.out_regs.lba_mid = 0xf4;
           }
-          else
+          else {
             out.out_regs.lba_high = 0xc2; out.out_regs.lba_mid = 0x4f;
+          }
           break;
         }
         else err = 0;
@@ -570,7 +558,7 @@ bool darwin_nvme_device::nvme_pass_through(const nvme_cmd_in & in, nvme_cmd_out
   unsigned int page = in.cdw10 & 0xff;
 
   if (! ifp)
-    return -1;
+    return false;
   smartIfNVMe = *ifp;
   // currently only GetIdentifyData and SMARTReadData are supported
   switch (in.opcode) {