-dev_t IOBSDGetMediaWithUUID( const char *uuid_cstring, char *bsd_name, int bsd_name_len, int timeout)
-{
- dev_t dev = 0;
- OSDictionary *dictionary;
- OSString *uuid_string;
-
- if (bsd_name_len < 1) {
- return 0;
- }
- bsd_name[0] = '\0';
-
- dictionary = IOService::serviceMatching( "IOMedia" );
- if( dictionary ) {
- uuid_string = OSString::withCString( uuid_cstring );
- if( uuid_string ) {
- IOService *service;
- mach_timespec_t tv = { timeout, 0 }; // wait up to "timeout" seconds for the device
-
- dictionary->setObject( "UUID", uuid_string );
- dictionary->retain();
- service = IOService::waitForService( dictionary, &tv );
- if( service ) {
- OSNumber *dev_major = (OSNumber *) service->getProperty( kIOBSDMajorKey );
- OSNumber *dev_minor = (OSNumber *) service->getProperty( kIOBSDMinorKey );
- OSString *iostr = (OSString *) service->getProperty( kIOBSDNameKey );
-
- if( iostr)
- strlcpy( bsd_name, iostr->getCStringNoCopy(), bsd_name_len );
-
- if ( dev_major && dev_minor )
- dev = makedev( dev_major->unsigned32BitValue(), dev_minor->unsigned32BitValue() );
- }
- uuid_string->release();
- }
- dictionary->release();
- }
-
- return dev;
-}
-
-