On Apr 28, 2010, at 8:28 PM, Charles Davis wrote:
On 4/28/10 5:48 PM, Ken Thomases wrote:
On Apr 28, 2010, at 6:18 PM, Charles Davis wrote:
Besides, to use it, we'd have to call DADiskMount() directly instead of going through diskutil.
Huh? Who goes through diskutil?
NTDLL, when it gets a FSCTL_DISMOUNT_VOLUME.
Huh. Weird. I did not know that.
I can't speak for Alexandre, but I suspect he would be fine using the appropriate Mac-native framework, whether that would be DiskArbitration or CoreServices (FSUnmountVolumeSync()), over invoking a Mac-specific command via system(). (So long as it's a C API, of course. ;)
But, anyway, there's no barrier to registering such an approval callback.
Like I said, it will work when ejection and unmount requests go through DA, but not for raw umount(2) or ioctl(2) with DKIOCEJECT.
Is this something you've tested? I have not, but I would not be at all surprised if DiskArbitration had a kernel component.
For example, if I mount a disk image via the Finder and then use umount(8) to unmount it, I get the relevant NSWorkspaceDidUnmountNotification. NSWorkspace is built on DiskArbitration's callbacks but umount(8) is not. It just uses the unmount(2) system call.
(The above test was the quickest to hand. I didn't take the time to write a direct DiskArbitration test case, with or without an unmount approval callback.)
-Ken