Can't find bsd name of usb device

Hi all,I have an app that searches for a specific usb device.I observe the usb plugin notification and tried to find its BSD name.

    CFMutableDictionaryRef  matchingDict;
    CFRunLoopSourceRef      runLoopSource;

    matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
    if (!matchingDict)
    {
        printf("Couldn’t create a USB matching dictionary\n");
        return NO;
    }
    IONotificationPortRef    gNotifyPort;
    io_iterator_t            gRawAddedIter;
    io_iterator_t            gRawRemovedIter;

    gNotifyPort = IONotificationPortCreate(kIOMasterPortDefault);

    runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort);

    CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource,
                       kCFRunLoopDefaultMode);

    matchingDict = (CFMutableDictionaryRef) CFRetain(matchingDict);

    /
    IOServiceAddMatchingNotification(gNotifyPort,
                                     kIOFirstMatchNotification,
                                     matchingDict,
                                     onDeviceAdd,
                                     NULL,
                                     &gRawAddedIter);


In onDeviceAdd function ,


//some code here

while ((usbDevice = IOIteratorNext(iterator)))
{
     //some code here

     CFStringRef deviceBSDName_cf = ( CFStringRef ) IORegistryEntrySearchCFProperty (usbDevice,
                                                                                     kIOServicePlane,
                                                                                     CFSTR (kIOBSDNameKey ),
                                                                                     kCFAllocatorDefault,
                                                                                     kIORegistryIterateRecursively );
                NSString *deviceBSDName = (NSString *)deviceBSDName_cf;
     //some code here
}


This function IORegistryEntrySearchCFProperty works fine in OSX 10.10.4 with XCode 6.3 SDK 10.10(and older OSX versions ).

And it fails in OSX 10.11 beta1 and beta2 with Xcode 7.0 and SDK 10.11.It returns 0x0.

I don't find any changes about this function.

Can anyone help?

Thanks in advance!!

Replies

I'm running into the same issue- i've lost user-space access to USB devices in El Capitan.


Everything worked fine beforehand.


Have you found an answer yet?

Same problem here. This time on OS X 10.11 beta 8 and Xcode 6.4

Same setup - same problem. Code works fine on 10.10.5 but fails on 10.11 Beta 8 (XCode version 6.4).

I've filed Radar: Rdar://22503089 in case you want to dupe.

I am seeing the same issue trying to retrieve the path to a USB device.


I use the query:


IORegistryEntryCreateCFProperty(usbDevice,

CFSTR(kIOCalloutDeviceKey),

kCFAllocatorDefault,

0);


10.10.x works perfectly giving me the path to my device ('/dev/cu.usbmodem1A121' fyi)


But when I call this in 10.11 then I get a result of 0


Secondly I am new to the Developer Forums


How do I access the Radar to look at known issues? When I do a search I get know issues for 10.6 :-)


Thanks

You can report bugs at http://bugreport.apple.com.

You cannot see other issues there (probably for confidential reasons).

I tried working around the problem by manually traversing the I/O registry (Apple has a source code example - iodisplayregistry - see below). Use this application on 10.11 (GM) and the BSD name is there. Using the command line utility ioreg (ioreg -l) - same result. I adapted iodisplayregistry and included it in my application but that didn't work. Seems like the defining difference is that I traversed the I/O registry from the my device object and not from the root. If I change my application to search the I/O registry from the root I find the BSD name without problem. Feels like a real duct tape solution to the problem but it might be the way to go until Apple fixes this bug.


http://www.opensource.apple.com/source/IOKitUser/IOKitUser-755.42.1/iodisplayregistry.c

My rdar was closed as a duplicate of rdar://21852745 which still seems to be open. Anyone heard any details of how / when etc?