macos 如何在 Mac OS X 上创建虚拟光驱
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/232524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create virtual CD drive on Mac OS X
提问by Brian Webster
How does one go about creating a virtual CD driver on Mac OS X programatically?
如何以编程方式在 Mac OS X 上创建虚拟 CD 驱动程序?
I can't find any relevant Cocoa APIs or any pure C BSD solutions.
我找不到任何相关的 Cocoa API 或任何纯 C BSD 解决方案。
Any help or information is appreciated.
任何帮助或信息表示赞赏。
回答by Brian Webster
You would need to use the I/O Kit framework to develop your own device driver that would emulate a virtual CD drive. Here are some links to the relevant APIs to get you started.
您需要使用 I/O Kit 框架来开发您自己的设备驱动程序来模拟虚拟 CD 驱动器。以下是相关 API 的一些链接,可帮助您入门。
I/O Kit Device Driver Guidelines
回答by Louis Gerbarg
There are several different answers people have proposed here. The issue at hand is what are you trying to accomplish. If you really want to emulate a CD ROM (down to the commandset) you will need to write a device driver. If your goal is merely to emulate a block device with contents similiar to a CD you can create a disk image using disk utility and let the builtin disk image driver handle it for you.
人们在这里提出了几种不同的答案。手头的问题是你想要完成什么。如果您真的想模拟 CD ROM(直到命令集),您将需要编写一个设备驱动程序。如果您的目标只是模拟内容类似于 CD 的块设备,您可以使用磁盘实用程序创建磁盘映像,并让内置的磁盘映像驱动程序为您处理。
MacFUSE is useful if you want to present some sort of custom filesystem functionality, but if what you are looking for is something that has the same semantics as an optical disc (whether that is and block or command set level) it is the wrong tool.
如果您想展示某种自定义文件系统功能,MacFUSE 很有用,但如果您正在寻找与光盘具有相同语义的东西(无论是块级别还是命令集级别),那么它就是错误的工具。
回答by Timothy Walters
If you're simply looking to mount an ISO or something then it's done through the Disk Utility, simply drag it into the side-bar and then select it and choose mount.
如果您只是想挂载 ISO 或其他东西,那么可以通过磁盘工具完成,只需将其拖到侧栏中,然后选择它并选择挂载即可。
If you want to do it from code you can issue the hdiutil command, as shown here. I'm not sure if there's an API call to do it, but getting that command to do the work is quite painless.
如果你想从代码做到这一点,你可以发出hdiutil命令,如图所示这里。我不确定是否有 API 调用来执行此操作,但使用该命令来执行此工作非常轻松。
回答by Jens Ayton
The simplest way to mount a custom volume is MacFUSE. It handles the IOKit details for you and lets you write the implementation in user space. However, I don't think you can make a MacFUSE “look like” a CD; you'd have to modify FUSE to achieve that.
挂载自定义卷的最简单方法是MacFUSE。它为您处理 IOKit 详细信息,并让您在用户空间中编写实现。但是,我认为您无法将 MacFUSE 制作成“看起来像”CD;您必须修改 FUSE 才能实现这一点。