What might be interesting to look into is I think libusb can listen for the 
event sent out by USBDeviceOpenSeize. I am not entirely sure (it might only 
apply to kernel drivers). This might be useful to force one libusb app to 
detach so another can use a device. Do any other platforms have a similar event?

I should also say that the OSX situation is nothing like Windows (though I am 
probably missing some of the context for the comparison). Its trivial to deploy 
a codeless kext or (if I see a pressing need) I *could* write a small (200 or 
so lines) kernel module that would allow libusb to force a kernel driver to 
stop and detach. The only requirement for either method is the user would have 
to install the codeless kext of a libusb 1.0 driver as an admin.

It really doesn't make much sense to do either since the primary driver users 
wish to detach is IOHID. And as I have written many times: if the vendor wishes 
to abuse the HID spec to make development on Windows easier then libusb is not 
the answer. hidapi is the best way to interface with these devices from 
userspace. This disagreement is the primary reason (there are others) I will 
not contribute directly to libusbx. It would be great if the core libusbx 
developers would re-join libusb but that will probably never happen.

-Nathan

On Feb 14, 2013, at 7:59 PM, Xiaofan Chen <xiaof...@gmail.com> wrote:

> On Tue, Feb 12, 2013 at 6:29 PM, Hans de Goede <hdego...@redhat.com> wrote:
>> Note:
>> 1) I'm not claiming this is easy from an implementation pov, just that
>> the current API can handle this.
>> 
>> 2) AFAIK Mac OS X is actually in more or less a similar situation, it has
>> a call to detach the in kernel driver, but the in kernel driver can
>> refuse, and most do. A solution to this is to install a stub driver instead
>> which does allow detaching, at which point the situation is more or less
>> the same as under Windows.
>> 
>> So these event types may be useful for Mac OS X too, although I wonder if it
>> is possible to find out if detaching will work without trying? Maybe libusb's
>> Mac OS X code can contain a list of driver-names for drivers known to fail
>> detach and use that to signal the difference?
> 
> If you want to find a way to detach kernel driver under Mac OS X
> using a programmatically way, you will be disappointed to find that
> it is not possible!
> 
> Ref:
> http://libusb.6.n5.nabble.com/No-way-to-programmatically-unload-a-driver-and-grab-the-IOUSBDevice-or-IOUSBInterface-from-user-space-td5710987.html
> 
> http://lists.apple.com/archives/usb/2012/Dec/msg00003.html
> "There is no way to programmatically unload a driver to be able to
> grab the IOUSBDevice/IOUSBInterface from user space.  We are well
> aware of the desire to do that so there is no need to file another bug report.
> 
> The only solution is to create a codeless kext that will grab that
> IOUSBDevice/Interface and prevent any kernel drivers from
> loading for it.  Search for "codeless kext" in the archives.
> 
> HTH,
> 
> -  Fernando
> +++++++++
> 
> 
> -- 
> Xiaofan


------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to