]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - os_darwin.cpp
Updated Changelog
[mirror_smartmontools-debian.git] / os_darwin.cpp
index 867f804da9c71bad9df6f77b9cf8cdd318069338..eabdee9846eefc3a1b5f946a1d7f2fd1495aea2b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Home page of code is: http://smartmontools.sourceforge.net
  *
- * Copyright (C) 2004-6 Geoffrey Keating <geoffk@geoffk.org>
+ * Copyright (C) 2004-8 Geoffrey Keating <geoffk@geoffk.org>
  *
  * 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
  * any later version.
  *
  * You should have received a copy of the GNU General Public License
- * (for example COPYING); if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * (for example COPYING); if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <stdbool.h>
 #include <errno.h>
+#include <unistd.h>
 #include <mach/mach.h>
 #include <mach/mach_error.h>
 #include <mach/mach_init.h>
@@ -43,7 +44,7 @@
 #include "os_darwin.h"
 
 // Needed by '-V' option (CVS versioning) of smartd/smartctl
-const char *os_XXXX_c_cvsid="$Id: os_darwin.cpp,v 1.18 2006/09/20 16:17:31 shattered Exp $" \
+const char *os_XXXX_c_cvsid="$Id: os_darwin.cpp 3805 2013-03-29 19:54:18Z chrfranke $" \
 ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_DARWIN_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 // Print examples for smartctl.
@@ -71,9 +72,8 @@ void print_smartctl_examples(){
 
 // tries to guess device type given the name (a path).  See utility.h
 // for return values.
-int guess_device_type (const char* dev_name) {
+int guess_device_type (const char * /* dev_name */) {
   // Only ATA is supported right now, so that's what it'd better be.
-  dev_name = dev_name;  // suppress unused warning.
   return CONTROLLER_ATA;
 }
 
@@ -333,7 +333,7 @@ ata_command_interface(int fd, smart_command_set command,
   IOATASMARTInterface **ifp = devices[fd].smartIf;
   IOATASMARTInterface *smartIf;
   IOReturn err;
-  int timeoutCount = 2;
+  int timeoutCount = 5;
   
   if (! ifp)
     return -1;
@@ -385,8 +385,9 @@ ata_command_interface(int fd, smart_command_set command,
        {
          UInt32 dummy;
          err = smartIf->GetATAIdentifyData (ifp, data, 512, &dummy);
-         if (err != kIOReturnSuccess)
-           printf ("identify failed: %d\n", (int) err);
+         if (err != kIOReturnSuccess && err != kIOReturnTimeout
+             && err != kIOReturnNotResponding)
+           printf ("identify failed: %#x\n", (unsigned) err);
          if (err == kIOReturnSuccess && isbigendian())
            {
              int i;
@@ -409,50 +410,16 @@ ata_command_interface(int fd, smart_command_set command,
        you get a timeout, you have to try again to get the actual
        command run, but the drive is already powering up so you can't
        use this for CHECK_POWER_MODE.  */
-  } while (err == kIOReturnTimeout && timeoutCount-- > 0);
+    if (err == kIOReturnTimeout || err == kIOReturnNotResponding)
+      sleep (1);
+  } while ((err == kIOReturnTimeout || err == kIOReturnNotResponding)
+          && timeoutCount-- > 0);
   if (err == kIOReturnExclusiveAccess)
     errno = EBUSY;
   return err == kIOReturnSuccess ? 0 : -1;
 }
 
-// There's no special handling needed for hidden devices, the kernel
-// must deal with them.
-int escalade_command_interface(int fd, int escalade_port, int escalade_type,
-                              smart_command_set command, int select,
-                              char *data)
-{
-  fd = fd;
-  escalade_port = escalade_port;
-  escalade_type = escalade_type;
-  command = command;
-  select = select;
-  data = data;
-  return -1;
-}
-
-int marvell_command_interface(int fd, smart_command_set command,
-                     int select, char *data)
-{ 
-  fd = fd;
-  command = command;
-  select = select;
-  data = data;
-  return -1;
-}
-
-int highpoint_command_interface(int fd, smart_command_set command, int select, char *data)
-{
-  fd = fd;
-  command = command;
-  select = select;
-  data = data;
-  return -1;
-}
-
 // Interface to SCSI devices.  See os_linux.c
-int do_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) {
-  fd = fd;
-  iop = iop;
-  report = report;
+int do_scsi_cmnd_io(int /* fd */, struct scsi_cmnd_io * /* iop */, int /* report */) {
   return -ENOSYS;
 }