6

Q. How to mount an apple disk image programmatically ?

My approach is similar to use disk arbitration for mounting as shown here. I prefer not to use any command line tool.

The un-mount and eject works perfectly but the mount needs a BSD name(generally used for block file of disk). I've seen the source code for DiskArbitrator also, this tool uses hdiutil in background to create the block file for the DMG.

Is there any other method/framework to create the block file for my disk image so that i can use it to mount the DMG?

I've already seen this this

Community
  • 1
  • 1
bikram990
  • 1,085
  • 1
  • 14
  • 36
  • Hi, perhaps it's too late for an answer, but have you tried using `DADiskMount` for the mount task ? I personally looking for a way to format the dmg image in hfs+ format. do you know if there's api for that (currently i use the command-line of `newfs_hfs`. –  Feb 21 '18 at 09:47
  • @osxUser Yes, I've tried it. `DADiskMount` needs a `DADiskRef` and to create a `DADiskRef` you would need a bsd name. To create a bsd name you will need to use `hdiutil` command. – bikram990 Feb 22 '18 at 10:27
  • but does `DADiskMount` also format the volume with `HFS+` format ? Because had to use `newfs_hfs` from command line for that. –  Feb 22 '18 at 13:37
  • @osxUser `DADiskMount` will not format the volume as it is supposed to just mount the disk and its work is done. – bikram990 Feb 23 '18 at 03:59
  • @osxUser I don't think there is a direct API to format a Disk. You may want to read more about block files. File System is merely a wrapper over block files, created to provide easy access to disk write and read operations. – bikram990 Feb 23 '18 at 04:16

0 Answers0