Re: Diskarbitration callback
Re: Diskarbitration callback
- Subject: Re: Diskarbitration callback
- From: Philip Aker <email@hidden>
- Date: Thu, 08 May 2008 06:09:30 -0700
On 08-05-08, at 01:21, Andy Green wrote:
I've written some code which uses the diskArbitration framework to
unmount (and eject) a disk.
It works, in that the disk gets unmounted, but my callback isn't
being called, even though the operation is successful. Any chance of
spotting the mistake in this code fragment? :-
I think you'll have to schedule the session with a run loop to get any
callback actions.
8<----
struct Nothing
{
bool dummy;
};
static void AndygDiskArbCallback( DADiskRef disk, DADissenterRef
dissenter, void * context)
{
printf("If I ever see this, my problems are over\n");
Nothing * n = (Nothing *)context;
n->dummy = true;
// I want to give a semaphore here to unlock the main thread
}
int main(int argc, char *argv[])
{
const char * cStr = "disk0s2";
Nothing * n = new Nothing;
n->dummy = false;
DASessionRef diskArbSession = DASessionCreate(kCFAllocatorDefault);
assert(diskArbSession);
DADiskRef disk = DADiskCreateFromBSDName( kCFAllocatorDefault,
diskArbSession, cStr );
assert(disk);
printf("confirming %s == %s??\n", DADiskGetBSDName(disk), cStr);
DADiskRef whole = DADiskCopyWholeDisk( disk );
if ( whole )
{
printf("wholedisk == %s\n", DADiskGetBSDName(whole));
DADiskUnmount(whole, kDADiskUnmountOptionWhole |
kDADiskUnmountOptionForce, AndygDiskArbCallback, n);
CFRelease(whole);
}
printf("------Wait...");
sleep(1); // instead of sleep, I want to wait on a semaphore
here,
until the unmount is complete.
// unfortunately the callback isn't being called!
// I'll do this too, once I get the callback from Unmount...
// DADiskEject( disk, kDADiskEjectOptionDefault,
AndygDiskArbCallback, NULL );
CFRelease(disk);
CFRelease(diskArbSession);
printf("AT THE END OF IT ALL, n=%d\n", n->dummy);
delete(n);
}
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
Sent from my SE/30
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden