Search
lxdream.org :: lxdream/src/drivers/osx_iokit.m :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/osx_iokit.m
changeset 1023:264e2fd90be8
prev964:f2f3c7612d06
next1297:7e98a164b2d9
author nkeynes
date Mon Jun 08 04:12:21 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change General cleanup of the GD-rom subsystem
- merge gdrom_image_t and gdrom_disc_t
- Abstract MMC devices using a lower-level scsi transport
- OSX: only look at the whole disc device, and ignore partitions
file annotate diff log raw
1.1 --- a/src/drivers/osx_iokit.m Thu Jan 15 04:15:11 2009 +0000
1.2 +++ b/src/drivers/osx_iokit.m Mon Jun 08 04:12:21 2009 +0000
1.3 @@ -50,6 +50,7 @@
1.4 };
1.5
1.6 static gboolean get_bsdname_for_iomedia( io_object_t iomedia, char *buf, int buflen );
1.7 +static gboolean get_boolean_property( io_object_t io, CFStringRef key, gboolean def );
1.8
1.9 /***************** IOKit Callbacks ******************/
1.10
1.11 @@ -91,7 +92,8 @@
1.12 io_string_t iopath = "";
1.13 IORegistryEntryGetPath( object, kIOServicePlane, iopath );
1.14 if( drive != NULL && g_str_has_prefix(iopath, drive->ioservice_path ) &&
1.15 - get_bsdname_for_iomedia(object, drive->media_path, sizeof(drive->media_path)) ) {
1.16 + get_boolean_property(object, CFSTR("Whole"), TRUE) &&
1.17 + get_bsdname_for_iomedia(object, drive->media_path, sizeof(drive->media_path)) ) {
1.18 // A disc was inserted within the drive of interest
1.19 if( drive->media_fh != -1 ) {
1.20 close(drive->media_fh);
1.21 @@ -143,6 +145,21 @@
1.22 return result;
1.23 }
1.24
1.25 +/**
1.26 + * Retrieve a boolean property from the io object, and return as a gboolean. If
1.27 + * the key is not present, return def instead.
1.28 + */
1.29 +static gboolean get_boolean_property( io_object_t io, CFStringRef key, gboolean def )
1.30 +{
1.31 + gboolean result = def;
1.32 + CFTypeRef ref = IORegistryEntryCreateCFProperty(io, key, kCFAllocatorDefault, 0 );
1.33 + if( ref ) {
1.34 + result = CFBooleanGetValue(ref);
1.35 + CFRelease(ref);
1.36 + }
1.37 + return result;
1.38 + }
1.39 +
1.40 static gboolean osx_cdrom_drive_get_name( io_object_t object, char *vendor, int vendor_len,
1.41 char *product, int product_len )
1.42 {
.