FW: Diskarbitration callback
FW: Diskarbitration callback
- Subject: FW: Diskarbitration callback
- From: "Andy Green" <email@hidden>
- Date: Thu, 8 May 2008 09:21:51 +0100
- Thread-topic: Diskarbitration callback
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? :-
Cheers,
Andy
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);
}
_______________________________________________
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