+ return true;
+}
+
+// makes a list of ATA or SCSI devices for the DEVICESCAN directive of
+// smartd. Returns number N of devices, or -1 if out of
+// memory. Allocates N+1 arrays: one of N pointers (devlist); the
+// other N arrays each contain null-terminated character strings. In
+// the case N==0, no arrays are allocated because the array of 0
+// pointers has zero length, equivalent to calling malloc(0).
+static int make_device_names (char*** devlist, const char* name) {
+ IOReturn err;
+ io_iterator_t i;
+ io_object_t device = MACH_PORT_NULL;
+ int result;
+ int index;
+
+ // We treat all devices as ATA so long as they support SMARTLib.
+ if (strcmp (name, "ATA") != 0)
+ return 0;
+
+ err = IOServiceGetMatchingServices
+ (kIOMasterPortDefault, IOServiceMatching (kIOBlockStorageDeviceClass), &i);
+ if (err != kIOReturnSuccess)
+ return -1;
+
+ // Count the devices.
+ result = 0;
+ while ((device = IOIteratorNext (i)) != MACH_PORT_NULL) {
+ if (is_smart_capable (device))
+ result++;
+ IOObjectRelease (device);
+ }
+
+ // Create an array of service names.
+ IOIteratorReset (i);
+ *devlist = (char**)calloc (result, sizeof (char *));
+ if (! *devlist)
+ goto error;
+ index = 0;
+ while ((device = IOIteratorNext (i)) != MACH_PORT_NULL) {
+ if (is_smart_capable (device))
+ {
+ io_string_t devName;
+ IORegistryEntryGetPath(device, kIOServicePlane, devName);
+ (*devlist)[index] = strdup (devName);
+ if (! (*devlist)[index])
+ goto error;
+ index++;
+ }
+ IOObjectRelease (device);
+ }
+
+ IOObjectRelease (i);
+ return result;
+
+ error:
+ if (device != MACH_PORT_NULL)
+ IOObjectRelease (device);
+ IOObjectRelease (i);
+ if (*devlist)
+ {
+ for (index = 0; index < result; index++)
+ if ((*devlist)[index])
+ free ((*devlist)[index]);
+ free (*devlist);
+ }
+ return -1;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/// Implement standard ATA support
+
+class darwin_ata_device
+: public /*implements*/ ata_device,
+ public /*extends*/ darwin_smart_device
+{
+public:
+ darwin_ata_device(smart_interface * intf, const char * dev_name, const char * req_type);
+ virtual bool ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out);
+
+protected:
+ // virtual int ata_command_interface(smart_command_set command, int select, char * data);
+};
+
+darwin_ata_device::darwin_ata_device(smart_interface * intf, const char * dev_name, const char * req_type)
+: smart_device(intf, dev_name, "ata", req_type),
+ darwin_smart_device("ATA")
+{