- matching = IOBSDNameMatching( look );
- }
- }
-
- if( !matching) {
- OSString * astring;
- // Match any HFS media
-
- matching = IOService::serviceMatching( "IOMedia" );
- astring = OSString::withCStringNoCopy("Apple_HFS");
- if ( astring ) {
- matching->setObject("Content", astring);
- astring->release();
- }
- }
-
- if( true && matching) {
- OSSerialize * s = OSSerialize::withCapacity( 5 );
-
- if( matching->serialize( s )) {
- IOLog( "Waiting on %s\n", s->text() );
- s->release();
- }
- }
-
- do {
- t.tv_sec = ROOTDEVICETIMEOUT;
- t.tv_nsec = 0;
- matching->retain();
- service = IOService::waitForService( matching, &t );
- if( (!service) || (mountAttempts == 10)) {
- PE_display_icon( 0, "noroot");
- IOLog( "Still waiting for root device\n" );
-
- if( !debugInfoPrintedOnce) {
- debugInfoPrintedOnce = true;
- if( gIOKitDebug & kIOLogDTree) {
- IOLog("\nDT plane:\n");
- IOPrintPlane( gIODTPlane );
- }
- if( gIOKitDebug & kIOLogServiceTree) {
- IOLog("\nService plane:\n");
- IOPrintPlane( gIOServicePlane );
- }
- if( gIOKitDebug & kIOLogMemory)
- IOPrintMemory();
- }
- }
- } while( !service);
- matching->release();
-
- if ( service && findHFSChild ) {
- bool waiting = true;
- uint64_t timeoutNS;
-
- // wait for children services to finish registering
- while ( waiting ) {
- timeoutNS = ROOTDEVICETIMEOUT;
- timeoutNS *= kSecondScale;
-
- if ( (service->waitQuiet(timeoutNS) ) == kIOReturnSuccess) {
- waiting = false;
- } else {
- IOLog( "Waiting for child registration\n" );
- }
- }
- // look for a subservice with an Apple_HFS child
- IOService * subservice = IOFindMatchingChild( service );
- if ( subservice ) service = subservice;
- } else if ( service && mediaProperty ) {
- service = (IOService *)service->getProperty(mediaProperty);
- }
-
- mjr = 0;
- mnr = 0;
-
- // If the IOService we matched to is a subclass of IONetworkInterface,
- // then make sure it has been registered with BSD and has a BSD name
- // assigned.
-
- if ( service
- && service->metaCast( "IONetworkInterface" )
- && !IORegisterNetworkInterface( service ) )
- {
- service = 0;
- }
-
- if( service) {
-
- len = kMaxPathBuf;
- service->getPath( str, &len, gIOServicePlane );
- IOLog( "Got boot device = %s\n", str );
-
- iostr = (OSString *) service->getProperty( kIOBSDNameKey );
- if( iostr)
- strlcpy( rootName, iostr->getCStringNoCopy(), rootNameSize );
- off = (OSNumber *) service->getProperty( kIOBSDMajorKey );
- if( off)
- mjr = off->unsigned32BitValue();
- off = (OSNumber *) service->getProperty( kIOBSDMinorKey );
- if( off)
- mnr = off->unsigned32BitValue();
-
- if( service->metaCast( "IONetworkInterface" ))
- flags |= 1;
-
- } else {
-
- IOLog( "Wait for root failed\n" );
- strlcpy( rootName, "en0", rootNameSize );
- flags |= 1;
- }
-
- IOLog( "BSD root: %s", rootName );
- if( mjr)
- IOLog(", major %d, minor %d\n", mjr, mnr );
- else
- IOLog("\n");
-
- *root = makedev( mjr, mnr );
- *oflags = flags;
-
- IOFree( str, kMaxPathBuf + kMaxBootVar );