开发者

Is there a way to get the BSD number of a device in Mac OS X?

My program reads device paths like /dev/rdisk0 from input and then it looks in IOKit for a disk with the BSD name disk0. For this I have to remove /dev/r from the path.

Hard coding this path can break in future versions of Mac OS X. Therefore I though of another way: I could match the IOService using the BSD Major and Minor version of the device.

Here's my question: Is it possible to extract the B开发者_Python百科SD minor and major numbers from a path?


Yes. Use the stat syscall. The member of struct stat you are looking for is st_dev, which I believe is an OR of major and minor after a bit shift.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜