FS#10972 - rc.conf blacklist behaves unintuitively
Attached to Project:
Arch Linux
Opened by Thomas Bächler (brain0) - Monday, 21 July 2008, 21:42 GMT
Last edited by Thomas Bächler (brain0) - Friday, 12 September 2008, 21:30 GMT
Opened by Thomas Bächler (brain0) - Monday, 21 July 2008, 21:42 GMT
Last edited by Thomas Bächler (brain0) - Friday, 12 September 2008, 21:30 GMT
|
Details
Sometimes, there is more than one module for a specific
device and one wants to blacklist one and load the other.
When you blacklist a module, not only the module, but
instead the whole device is blacklisted, meaning that the
module loading is aborted. This is undesirable.
|
This task depends upon
Closed by Thomas Bächler (brain0)
Friday, 12 September 2008, 21:30 GMT
Reason for closing: Implemented
Friday, 12 September 2008, 21:30 GMT
Reason for closing: Implemented
A correct way would be to first resolve an alias to all its modules (no dependencies). Then for each module resolve the dependencies and check against the blacklist.
A popular example would be: blacklisting 8139cp will blacklist 8139too as well. Blacklisting piix will blacklist ata_piix as well.
If I blacklist 8139cp, there is no way that will match 8139too, because they are not dependencies of each other.
$ modprobe --show-depends 8139cp
insmod /lib/modules/2.6.20-15-server/kernel/drivers/net/mii.ko
insmod /lib/modules/2.6.20-15-server/kernel/drivers/net/8139cp.ko
$ modprobe --show-depends 8139too
insmod /lib/modules/2.6.20-15-server/kernel/drivers/net/mii.ko
insmod /lib/modules/2.6.20-15-server/kernel/drivers/net/8139too.ko
In this case, if I were to blacklist mii, then it would blacklist both. But blacklisting one will not blacklist the other.
if [ -n "$BLACKLIST" ]; then
#
# In this line, all matches for a certain alias are found including dependencies.
# There may be more than one match for a certain alias if the alias is listed
# in more than one driver. So this may, for example, include 8139too, 8139cp
# and all of their dependencies. One only wants to load exactly one of those two
# including only the dependencies of this module.
#
depmods="$(/sbin/modprobe -i --show-depends $1)"
if [ $? -ne 0 ]; then
/usr/bin/logger -p info "cannot find module $1"
exit 1
fi
#sanitize our module names
depmods="$(echo "$depmods" | sed \
-e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \
-e 's|-|_|g')"
#
# Here we iterate over all modules we found above. If only one of them is blacklisted,
# we exit immediately, and thus don't load any modules. This was originally intended to
# blacklist a module completely, so it isn't autoloaded as a dependency of another module.
# In our above example, this list contains both 8139too and 8139cp, so if either of them
# are blacklisted, we exit and load nothing. This means that the other module is effectively
# blacklisted as well.
#
for mod in $depmods; do
if echo $BLACKLIST | /bin/grep "\<$mod\>" 2>&1 >/dev/null; then
/usr/bin/logger -p info "udev load-modules: $1 is blacklisted"
exit 1
fi
done
fi
/sbin/modprobe $1
Resolving an alias is not possible at the moment with m-i-t. If you'd like to rip out the code that does the alias lookup, you're welcome to, but in that case I'd recommend rewriting the whole load-modules chunk as part of that.
In pseudo-code:
all-modules = resolve-alias $1
for module in $all-modules:
...if is-blacklisted $module:
......remove-from-list $module $all-modules
modprobe $all-modules #remaining modules should be blacklisted
In pseudo-code:
all-modules = resolve-alias $1
for module in $all-modules:
...module-depends = depends $module
...for m in $module-depends:
......if is-blacklisted $module:
.........remove-from-list $module $all-modules
.........break
modprobe $all-modules #remaining modules should be blacklisted
I wrote some C++ code that would find the aliases (basically, m-i-t uses fnmatch on each line in modules.dep). I could make it C code easily, either standalone or as a patch to modprobe. Any preference?
Personally, I think modprobe's blacklisting sucks hard, so maybe we can replace the way it works, convince the lead dev, AND do away with load-modules.sh in one fell swoop.
This way we can create a working blacklist like in my last pseudocode example. The problem is still that modules.dep only contains module with their full paths. I shall hack this together tomorrow evening.