hardcoded usb1 modules in certain binaries

Alexander Best alexbestms at math.uni-muenster.de
Wed Dec 10 03:17:56 PST 2008


hi there,

i talked to Petter a while ago, because binaries like moused have certain usb1
modules hardcoded into them. moused e.g. relies on ums.ko. if it is unable to
detect the module it will load it, thus also loading usb.ko (even if we're
running the usb2 stack). this line in moused is responsible for loading ums.ko
and usb.ko:

return (kld_isloaded("uhub/ums") || kld_load("ums") != -1);

changing the line to

return (kld_isloaded("ushub/ums") || kld_load("usb2_input_ms") !=
-1 || kld_isloaded("uhub/ums") || kld_load("ums") != -1);

fixes the issue where ums.ko and usb.ko get loaded although usb2 with input_ms
is present, but isn't more that a quick hack.

how about this:

let's introduce a new sysctl variable. if the kernel gets compiled with usb1
support we set the variable to 0. it it is compiled with the usb2 stack we set
the variable to 1. that way we could check to see which stack the user is
running. if he's running the usb1 stack we check for "uhub/ums" and in case
we're running the usb2 stack we rely on "ushub/ums".

if the kernel doesn't include any of the usb stacks we set to variable to 0 so
the usb1 stack gets loaded as kernel module. if at some point we want usb2 to
become the standard usb stack we can change the default settings from 0 to 1
so that usb2.ko get's loaded if no usb stack got compiled into the kernel.

what are your thoughts on this one?

another way of taking care of the problem would be to adjust kld_isloaded so
that it includes aliases for all the usb2 modules. calling kld_isloaded with
"uhub/ums" would first check for "ushub/ums" and then for "uhub/ums". this
solution wouldn't require any changes to the actual binaries that have usb1
modules hardcoded into them. imo this is the best solution.

a third way would be to get rid of all the kld_isloaded calls and instead
check to see if /dev/ums0 exists, but that's far from being a clean solution.

cheers.


More information about the freebsd-usb mailing list