Unable to get USB bsdname from macOS Monterey 12 Bate4 of Intel processor

I can’t get USB bsdname from macOS Monterey 12 Bate4 of Intel processor: I have use the "IORegistryEntrySearchCFProperty" function to get the bsdName of the io_service_t, It worked fine on macOS Big Sur's M1 and Intel MBP. Also it worked fine on macOS Monterey App M1. But it always returned nil on macOS Monterey Intel MBP. It involves the following code:

void getBsdName(io_service_t usbDevice)

{

	CFStringRef bsdName = NULL;

        for(int i = 0; i < 500; i++)

        {

            bsdName = (CFStringRef)IORegistryEntrySearchCFProperty(usbDevice,

                                                                   kIOServicePlane,

                                                                   CFSTR( kIOBSDNameKey ),

                                                                   kCFAllocatorDefault,

                                                                   kIORegistryIterateRecursively );

            if(!bsdName) {

                // If don't get a bsd name, keep waiting in 5s.

                usleep(10000);

                continue;

            }

            

            printf("[%s]: Found bsd name for device %d.\n”, __func__, usbDevice);

            break;

        }

}

Why it happened? Or is there another way to get it?

I’m not sure why this is failing on macOS 12 beta but I’d like to clarify your goals here. Can you explain more about the big picture? Why are you trying to map in this direction?

I’m curious because any algorithm that involves a usleep is suspect in my opinion.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Same problem here. It seems like kIORegistryIterateRecursively is not working as intended. I tried to dig into the IOUSBDevice entry's children using IORegistryEntryGetChildEntry recursively, but it fails to go deeper than one child (i.e. no grandchildren), so it seems like the IOSerialBSDClient child entry is no longer visible at all from that standpoint.

It seems like kIORegistryIterateRecursively is not working as intended. I tried to dig into the IOUSBDevice entry's children using IORegistryEntryGetChildEntry recursively

I’m confused by the above. IORegistryEntryGetChildEntry doesn’t work in terms of iterators. Are you saying that you tried to use it as a workaround for kIORegistryIterateRecursively? If so, what does your original code look like?

And it’d also help if you posted a description of your high-level goal. Many I/O Kit problems problems have easier solutions that don’t involve low-level I/O registry calls.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I solved this issue by other ways.

Since the device I'm looking for is an IOMedia object. I found its BSD name by enumerating the kIOMediaClass object. And I looked up IOMedia's parent device to determine the USB device I'm interested in.


CFStringRef mediaDevBsdName = NULL;

mediaDevBsdName = (CFStringRef)IORegistryEntryCreateCFProperty(mediaDevice,

                                                                 CFSTR(kIOBSDNameKey),

                                                                 kCFAllocatorDefault,0);

Hope this answer can help someone~

Here's what I ended up doing

Unfortunately I need a bit more context here. Specifically, how did you set up the io_iterator_t that’s passed in to the -serialDevicesForIOIterator: method?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Unable to get USB bsdname from macOS Monterey 12 Bate4 of Intel processor
 
 
Q