I am trying to use usb_modeswitch via libusb to switch a Huawei HiLink USB LTE modem to Ethernet mode from mass storage mode. It fails with the following error.
libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
In previous macOS versions, an available solution was to unload the relevant kext, but
com.apple.iokit.IOUSBMassStorageDriver is now linked by
com.apple.driver.AppleUSBTDM which is linked by
com.apple.driver.AppleKeyStore, and unloading the latter causes a kernel panic. (Ask me how I know.)
I am looking for another way to get the Mass Storage driver to let go of the device, so that it can be claimed by libusb. That can be both by disabling the driver, or by instructing it not to interact with this device.
There are similar questions like How to disable USB Mass Storage Device in macOS Mojave which are looking for a way to stop USB storage from mounting, but that's not sufficient for my use case, if it does not enable libusb to claim the interface.