• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
DiskArb DiskChangedCallback bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DiskArb DiskChangedCallback bug?


  • Subject: DiskArb DiskChangedCallback bug?
  • From: Brian Bergstrand <email@hidden>
  • Date: Mon, 12 Jun 2006 12:31:47 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

With the new 10.4 DiskArb API, the explicit mount/unmount callbacks were removed and instead you are supposed to use DARegisterDiskDescriptionChangedCallback():

/*!
* @constant kDADiskDescriptionWatchVolumePath
* Predefined CFArray object containing a set of disk description keys appropriate for
* watching volume mount changes using DARegisterDiskDescriptionChangedCallback().
*/


extern CFArrayRef kDADiskDescriptionWatchVolumePath;

However, there's seems to be a bug with this on 10.4.6 (PPC, haven't tried Intel) in that the callback is never called for volume mounts, only for volume unmounts.

Here's a test case. If you set a break point on DiskArbCallback_ChangeNotification(), and then insert a disk (I tried an AudioCD and a USB FAT flash drive), the breakpoint is not hit when the volume mounts, but when you eject it, gdb stops.

I've opened a bug report: rdar://4582301, but I wanted to see if perhaps I'm missing something or if there is an actual bug, is there some kind of workaround to detect a mount?

Thanks.

// cc -g -O0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -framework Foundation -framework DiskArbitration -o datest datest.m
#import <DiskArbitration/DiskArbitration.h>
#import <Foundation/Foundation.h>


static DASessionRef daSession = NULL;

static void DiskArbCallback_ChangeNotification(DADiskRef disk,
CFArrayRef keys, void * context)
{
NSDictionary *d = (NSDictionary*)DADiskCopyDescription(disk);
NSURL *path;
if (d && (path = [d objectForKey:(NSString*) kDADiskDescriptionVolumePathKey])
&& [[NSFileManager defaultManager] fileExistsAtPath:[path path]]) {
printf("Volume mounted on: %s\n", [[path path] fileSystemRepresentation]);
} else if (d && (!path || NO == [[NSFileManager defaultManager] fileExistsAtPath:[path path]])) {
printf("Volume unmounted");
}
[d release];
}


int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    if (NULL == (daSession = DASessionCreate(kCFAllocatorDefault)))
      return (ENOMEM);

DASessionScheduleWithRunLoop(daSession, [[NSRunLoop currentRunLoop] getCFRunLoop], kCFRunLoopDefaultMode);
// Since there is no explicit mount callback, the Change callback is how we detect a mount.
DARegisterDiskDescriptionChangedCallback(daSession, NULL, kDADiskDescriptionWatchVolumePath,
DiskArbCallback_ChangeNotification, NULL);



[[NSRunLoop currentRunLoop] run]; return (0); } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin)

iD8DBQFEjaUIedHYW7bHtqIRAlOWAKCD6piZOd8pCmlL0Up3wV5gBd+FuACcDxa4
RnR8Zbu1Sea7TFxZcYHfEXg=
=CE3t
-----END PGP SIGNATURE-----
_______________________________________________
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


  • Follow-Ups:
    • Re: DiskArb DiskChangedCallback bug?
      • From: Chris Sarcone <email@hidden>
  • Prev by Date: Re: kqueue - supported filesystems?
  • Next by Date: Re: DiskArb DiskChangedCallback bug?
  • Previous by thread: mod_auth_apple
  • Next by thread: Re: DiskArb DiskChangedCallback bug?
  • Index(es):
    • Date
    • Thread