--- a/src/drivers/osx_iokit.m Thu Jan 15 04:15:11 2009 +0000 +++ b/src/drivers/osx_iokit.m Sun Jun 28 01:34:55 2009 +0000 @@ -50,6 +50,7 @@ }; static gboolean get_bsdname_for_iomedia( io_object_t iomedia, char *buf, int buflen ); +static gboolean get_boolean_property( io_object_t io, CFStringRef key, gboolean def ); /***************** IOKit Callbacks ******************/ @@ -91,7 +92,8 @@ io_string_t iopath = ""; IORegistryEntryGetPath( object, kIOServicePlane, iopath ); if( drive != NULL && g_str_has_prefix(iopath, drive->ioservice_path ) && - get_bsdname_for_iomedia(object, drive->media_path, sizeof(drive->media_path)) ) { + get_boolean_property(object, CFSTR("Whole"), TRUE) && + get_bsdname_for_iomedia(object, drive->media_path, sizeof(drive->media_path)) ) { // A disc was inserted within the drive of interest if( drive->media_fh != -1 ) { close(drive->media_fh); @@ -143,6 +145,21 @@ return result; } +/** + * Retrieve a boolean property from the io object, and return as a gboolean. If + * the key is not present, return def instead. + */ +static gboolean get_boolean_property( io_object_t io, CFStringRef key, gboolean def ) +{ + gboolean result = def; + CFTypeRef ref = IORegistryEntryCreateCFProperty(io, key, kCFAllocatorDefault, 0 ); + if( ref ) { + result = CFBooleanGetValue(ref); + CFRelease(ref); + } + return result; + } + static gboolean osx_cdrom_drive_get_name( io_object_t object, char *vendor, int vendor_len, char *product, int product_len ) {