Getting IODeviceTree path using IOKit
I'm trying to get the IODeviceTree path of a device using the IOKit framework. I'm able to get the IOService path (IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SATA@B/AppleMCP79AHCI
) of the device using this code:
CFMutableDictionaryRef matchingDict = NULL;
matchingDict = IOServiceMatching("AppleMCP79AHCI");
io_service_t sataService;
io_string_t path;
sataService = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
IORegistryEntryGetPath(sataService, kIOServicePlane, path);
NSLog(@"%s", path);
However, I need to get the path for the device in the IODeviceTree
plane. In the IODeviceTree
plane, the path would be something like IODeviceTree:/PC开发者_C百科I0@0/SATA@B
. I tried simply replacing kIOServicePlane
with kIODeviceTreePlane
but it returned nothing. I have no experience with IOKit
, so I'm pretty sure theres something obvious I'm doing here.
Thanks
Figured it out, I was just using a class name that didn't exist in the IODeviceTree.
精彩评论