使用IOKit获取IODeviceTree路径

时间:2010-11-03 03:48:28

标签: c iokit macos

我正在尝试使用IOKit框架获取设备的IODeviceTree路径。我可以使用以下代码获取设备的IOService路径(IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SATA@B/AppleMCP79AHCI):

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);

但是,我需要在IODeviceTree平面中获取设备的路径。在IODeviceTree平面中,路径类似于IODeviceTree:/PCI0@0/SATA@B。我尝试将kIOServicePlane替换为kIODeviceTreePlane,但它没有返回任何内容。我没有IOKit的经验,所以我很确定我在这里做的很明显。

由于

1 个答案:

答案 0 :(得分:0)

想出来,我只是使用了IODeviceTree中不存在的类名。