site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 08-05-08, at 01:21, Andy Green wrote: 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); } // 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 astwta@lvpc.dslh@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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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. 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! This email sent to site_archiver@lists.apple.com
participants (1)
-
Philip Aker