我已经在 stackoverflow.com 和 google 上搜索了答案,但找不到任何东西。
我获得了属于外部 USB HDD (disk1) 的分区 (disk1s1) 的 bsdName。
我需要找出该外部硬盘的序列号。
我已经尝试过以下操作(查找具有 bsd 名称的服务):
io_service_t io_service = IOServiceGetMatchingService(kIOMasterPortDefault,IOBSDNameMatching(kIOMasterPortDefault, 0, [@"disk1" cStringUsingEncoding:NSUTF8StringEncoding]));
问题是:返回的服务类型是IOMedia
没有字段USB Serial Number
。如果我使用,我最终会遇到同样的问题DiskArbitration
框架(这是一个抽象IOMedia
)
所以我尝试了另一种方式:获取全部IOUSBDevice
服务迭代它们并只查找 bsdName 或分区IOUSBDevice
。不幸的是,没有存储有关任何分区或 bsd 名称的信息IOUSBDevice
.
有人可以帮我解决这个问题吗?
更多信息:
- 代码 4.3.2
- Mac OS X Lion (10.7.3)
EDIT:如果我迭代所有 IOUSBDevice 或 AppleUSBEHCI io_services ,这是输出中有趣的部分:
Child props: {
"Bus Power Available" = 250;
"Device Speed" = 2;
IOCFPlugInTypes = {
"9dc7b780-9ec0-11d4-a54f-000a27052861" = "IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle";
};
IOGeneralInterest = "IOCommand is not serializable";
IOUserClientClass = IOUSBDeviceUserClientV2;
"Low Power Displayed" = 0;
PortNum = 3;
"Requested Power" = 250;
"USB Address" = 6;
"USB Product Name" = "Mass Storage Device";
"USB Serial Number" = 09021000000000003740385375;
"USB Vendor Name" = JetFlash;
bDeviceClass = 0;
bDeviceProtocol = 0;
bDeviceSubClass = 0;
bMaxPacketSize0 = 64;
bNumConfigurations = 1;
bcdDevice = 2560;
iManufacturer = 1;
iProduct = 2;
iSerialNumber = 3;
idProduct = 4096;
idVendor = 34148;
kHasMSCInterface = 1;
locationID = "-99418112";
sessionID = 209792844564562;
uid = "USB:85641000003740385375";
}
正如你所看到的,我得到了序列号,但我无法知道这个设备有哪个 bsd 名称。