Background Information In the macOS operating system environment, Program A uses libusb to access USB devices that comply with the USB Mass Storage protocol. To enable Program A to start automatically after macOS boots, its corresponding plist file has been placed in the /Library/LaunchDaemons directory. Problem and Phenomenon Description Program A works well on macOS versions prior to 15.3, and it can access USB devices normally. However, on macOS 15.3, the following abnormal situations have occurred: A. Program A launched by launchd cannot access the USB device. Checking the logs reveals that the IOCreatePlugInInterfaceForService call in the darwin_claim_interface function returns the error code e00002be. B. Program A launched from the terminal command line with sudo privileges can access the USB device normally, and the return value of the IOCreatePlugInInterfaceForService call is 0.
macOS15.3 IOCreatePlugInInterfaceForService returns e00002be.
Lots of questions on this:
-
What hardware are you actually matching against and getting this error from?
-
Have you compared the IORegistry between 15.2 and 15.3 looking for differences in the driver stack loading on this device?
-
What are you actually using the IOUSBInterface "for"? Are you sure you can't get the same information from the IORegistry itself?
-
Have you tried using the IOUSBHost framework instead? That framework was released in macOS 10.15 as the replacement for IOUSBLIb and should provide the same functionality with a far nicer API.
-
What's being logged at the time the failure occurs?
-
What happens if you retry a second or so later? Note that I mean simply calling the function again, not hotplugging the device.
-
Related to that last point, have you tested your daemon at hot plug time as well as during startup?
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware
Background Information:
We have a macOS Program A which uses libusb-1.0.27 to access USB Token that comply with the USB Mass Storage protocol. To enable Program A to start automatically after macOS boots, its corresponding plist file has been placed in the /Library/LaunchDaemons directory.
Problems:
Program A works well on macOS versions prior to 15.3, and it can access USB Token normally. However, update to macOS 15.3, same program Start in a different way,the following abnormal situations have occurred,we try many times: A. Program A launched by launchd cannot access the USB device. Checking the logs reveals that the IOCreatePlugInInterfaceForService call in the darwin_claim_interface function returns the error code e00002be. B. Program A launched from the terminal command line with sudo privileges can access the USB device normally, and the return value of the IOCreatePlugInInterfaceForService call is 0.
The simplified code is as follows:
#import <Foundation/Foundation.h>
#include "libusb.h"
#define VENDOR_ID 0x1111
#define PRODUCT_ID 0x2222
int main(int argc, const char * argv[]) {
@autoreleasepool {
libusb_device_handle *dev_handle;
libusb_context *ctx = NULL;
int r;
r = libusb_init(&ctx);
if (r < 0)
{
return r ;
}
dev_handle = libusb_open_device_with_vid_pid(ctx, VENDOR_ID, PRODUCT_ID);
if (dev_handle == NULL)
{
libusb_exit(ctx);
return -1;
}
r = libusb_kernel_driver_active(dev_handle, 0);
if (r == 1)
{
r = libusb_detach_kernel_driver(dev_handle, 0);
}
r = libusb_claim_interface(dev_handle, 0);
if (r < 0)
{
libusb_close(dev_handle);
libusb_exit(ctx);
return r;
}
libusb_release_interface(dev_handle, 0);
libusb_close(dev_handle);
libusb_exit(ctx);
}
return 0;
}
libusb logs:
darwin_capture_claim_interface dev_handle = 20008000 iface = 0 dev_handle->auto_detach_kernel_driver = 0 darwin_capture_claim_interface darwin_claim_interface darwin_claim_interface IOCreatePlugInInterfaceForService darwin_claim_interface IOCreatePlugInInterfaceForService kresult = e00002be darwin_claim_interface IOCreatePlugInInterfaceForService: out of resources darwin_capture_claim_interface darwin_claim_interface ret = -99