Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 使用IOServiceGetMatchingServices获取OS X存储设备列表_Macos_Iokit - Fatal编程技术网

Macos 使用IOServiceGetMatchingServices获取OS X存储设备列表

Macos 使用IOServiceGetMatchingServices获取OS X存储设备列表,macos,iokit,Macos,Iokit,我需要得到OSX系统上物理存储设备的列表。IOServiceGetMatchingServices使用kIOStorageClass键为我提供了所有卷的列表,而不是所有硬件存储设备的列表。如何做到这一点?问题有点模棱两可(您想要整个驱动器、分区,以上所有的吗?),我建议启动IORegistryExplorer实用程序(随XCode提供)并确定您想要哪一类设备。我可以告诉您,每个驱动器通常都对应于一个IOBlockStorageDriver,所以这可能就是您想要匹配的类。然后它将有一个代表整个设备

我需要得到OSX系统上物理存储设备的列表。IOServiceGetMatchingServices使用kIOStorageClass键为我提供了所有卷的列表,而不是所有硬件存储设备的列表。如何做到这一点?

问题有点模棱两可(您想要整个驱动器、分区,以上所有的吗?),我建议启动IORegistryExplorer实用程序(随XCode提供)并确定您想要哪一类设备。我可以告诉您,每个驱动器通常都对应于一个
IOBlockStorageDriver
,所以这可能就是您想要匹配的类。然后它将有一个代表整个设备的
IOMedia
客户端。反过来,它将有一个分区方案客户机,每个分区都有一个
IOMedia
客户机,除非它没有分区。

要获取物理存储设备列表,您可以为kIOATABlockStorageDeviceClass匹配。下面的代码获取块存储设备的迭代器

IOReturn        error       = kIOReturnSuccess;
io_iterator_t   iter        = MACH_PORT_NULL;
error = IOServiceGetMatchingServices (  kIOMasterPortDefault,
                                      IOServiceMatching ( kIOATABlockStorageDeviceClass ),
                                      &iter );

什么是不是卷的存储设备,您是否也在寻找未安装的存储?或者像块设备。。。等