On Sat, 30 Apr 2005, Zoont Foomby wrote:
> Hello All You Wise Developer Types,
>
> I would like to implement a simple kernel hack which Involves the USB
> drivers. I would like to identify a USB device by VendorID and
> ProductID and have linux treat it as a device for which it does not
> have any driver, even though it does. Linux should not claim the
> device. I am looking to do this so that I can use the device with
> VMWare which depends on Linux never claiming the device. I tried
> forcing linux to disconnect/drop the device through IOCtl calls, some
> libusb calls, etc., and it did not work - the necessary sequence of
> events will only fire, I believe, if I can stop Linux from ever
> thinking it knows what to do with the device. I have seen this work
> with a USB Bluetooth device on my machine - I had USB support, but I
> did not compile in bluetooth support, and Linux thus never recognized
> a driver for the device and ignored it, such that VMWare could then
> take control when Linux passed over it.
> I've never hacked the kernel before. I'm not afraid to, but I don't
> know where best to start - although I already took a swing. I went and
> found a seemingly reasonable place to insert code...
> drivers/usb/storage/usb.c
That's okay if you only care about blocking usb-storage from binding to
devices. But what if you end up trying to stop other drivers too? You
should pick a more central location, like the usb_device_match routine in
drivers/usb/core/usb.c.
> In the function
>
> /* Probe to see if we can drive a newly-connected USB device */
> static int storage_probe(struct usb_interface *intf, const struct
> usb_device_id *id)
>
> I inserted the following code snippet...
>
> if ((us->vendor == "4855") && (us->product == "3288")) {
> goto BadDevice;
> }
How familiar are you with programming in C? It looks like you made an
amateur mistake here (and you made it twice). In addition to that, you
should realize that the vendor and product fields contain the string
names, like "Microtech" and "CameraMate", not the hex descriptor values.
> I then, knowing nothing else about kernel compiling, went back to the
> kernel source root and typed
> make modules
> make modules_install
>
> to rebuild my usb modules and put them in place.
>
> After doing this tiny edit, nothing seemed different.
Not surprising!
> So then I started over by first doing a make clean at the kernel root
> to clean up any precompiled kernel module object files, and did all of
> the above again. Still, no effect.
>
> How should I go about my little process here? Thanks for any info!
You should use the descriptor values, accessible through the usb_device
pointer. In the usb-storage routine, these would be
le16_to_cpu(us->pusb_dev->descriptor.idVendor)
and le16_to_cpu(us->pusb_dev->descriptor.idProduct)
(for Linux 2.6.11), and you should compare them against 0x4855 and 0x3288.
Alan Stern
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel