disk operations - mounting images I've created manually via Disk Utility
disk operations - mounting images I've created manually via Disk Utility
- Subject: disk operations - mounting images I've created manually via Disk Utility
- From: Luther Baker <email@hidden>
- Date: Sat, 15 Mar 2014 15:56:48 -0500
I'm an iOS developer talking a walk on the OSX side and have a question
about programmatically mounting sparse bundles ... or really just any dmg.
My experimental project is to write a little statusbar application to mount
and unmount disk images. I've created a few of these images in my own
"Volumes" directory as follows:
/Users/me/Volumes/me.sparsebundle
For the time being, I am hard-wiring logic in a menu selection handler to
actually mount these objects.
I've been digging into Disk Arbitration and I've come up with the following:
- (IBAction)mountMe:(id)sender {
DASessionRef sessionRef = DASessionCreate(kCFAllocatorDefault);
CFURLRef volumeURLRef = (__bridge CFURLRef)[NSURL fileURLWithPath:@
"/Users/me/Volumes/me.sparsebundle"];
DADiskRef diskRef = DADiskCreateFromVolumePath(kCFAllocatorDefault,
sessionRef, volumeURLRef);
CFURLRef mountPath = NULL;
DADiskMountOptions mountOptions = kDADiskMountOptionDefault;
DADiskMountCallback mountCallback = NULL;
void *context = NULL;
DADiskMount(diskRef, mountPath, mountOptions, mountCallback, context);
CFAllocatorDeallocate(kCFAllocatorDefault, diskRef);
CFAllocatorDeallocate(kCFAllocatorDefault, sessionRef);
}
*ANY* suggestions, even tangental (especially around memory management) are
fair game here. I'd appreciate any input as I'm just starting to read about
allocation, etc.
But more to the point, I don't think DADiskCreateFromVolumePath is what I
want. It seems that DADiskRef is NULL when I run this. Clearly, the most
intimidating method in there is DADiskCreateFromIOMedia ... and I'm afraid
that is the one I'm going to have to use.
And, am I really trying to mount a "disk" as Disk Arbitration understands
it? I'm not yet dealing with things like fstab, etc which I know very
little about -- but should I start digging that way? I did come across a
nice github project <http://tommetge.github.io/VolumeManager/> but
unfortunately I can't actually find any methods in there to mount ... only
things like umount or eject. Notably, the open source project does use
'getmntinfo' which leads me to look at the BSD mount man page ... but I
before going there I want to make sure I'm not _supposed_ to do this in
within Disk Arbitration. There is a DADiskCreateFromBSDName which seems
like it might be similar?
Anyway, any thoughts on this? And in general, is this fundamental stuff
covered in exemplary fashion anywhere? Would the OSX Internals books I've
seen dive into this? I'm assuming that if I've encryped my sparsebundle
that I'd be prompted by the OS for my password, which is fine for my first
pass but I'd eventually like to subsume that logic within my app - if for
no other reason than to simply better understand the partition management
frameworks.
Thanks in advance for even 1 brief minute of your time. I'll begin trying
the alternatives mentioned above in Disk Arbitration.
-Luther
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden