os_darwin.cpp: implement APM set feature, based on hdparm macOS sources

git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@5209 4ea69e1a-61f1-4043-bf83-b5c94c648137
pull/91/head
samm-git 2 years ago
parent 26fedfcc07
commit 6ed6b1a031
  1. 4
      smartmontools/ChangeLog
  2. 27
      smartmontools/os_darwin.cpp

@ -1,5 +1,9 @@
$Id$
2021-02-14 Alex Samorukov <samm@os2.kiev.ua>
os_darwin.cpp: implement APM set feature, based on hdparm macOS sources
2021-02-09 Christian Franke <franke@computer.org>
configure.ac: Include required library functions in check for

@ -398,6 +398,7 @@ bool darwin_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & ou
int fd = get_fd();
IOATASMARTInterface **ifp = devices[fd].smartIf;
IOATASMARTInterface *smartIf;
io_object_t disk = devices[fd].ioob;
IOReturn err;
int timeoutCount = 5;
int rc = 0;
@ -429,6 +430,32 @@ bool darwin_ata_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & ou
errno = ENOTSUP;
err = -1;
break;
case ATA_SET_FEATURES:
switch(in.in_regs.features) {
case ATA_ENABLE_APM:
if (in.in_regs.sector_count) {
int l = (int) in.in_regs.sector_count;
CFNumberRef cfLevel = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &l);
kern_return_t r = IORegistryEntrySetCFProperty(disk, CFSTR("APM Level"), cfLevel);
CFRelease(cfLevel);
if (r) {
switch(r) {
case kIOReturnNotPrivileged:
return set_err(ENOSYS, "Use superuser to manage APM");
break;
case kIOReturnUnsupported:
return set_err(ENOSYS, "APM not supported");
break;
default:
return set_err(ENOSYS, "APM error: %u", r);
}
}
break;
}
default:
return set_err(ENOSYS, "Unsupported ATA feature");
}
break;
case ATA_SMART_CMD:
switch (in.in_regs.features) {
case ATA_SMART_READ_VALUES:

Loading…
Cancel
Save