insmod: uniformize module name and lsmod output prior of comapring if module already insmodded (ehci-hcd.ko module name is ehci_hcd...)

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
Thierry Laurion 2024-02-22 16:20:14 -05:00
parent 5f8cb5a159
commit a5ab32b761
No known key found for this signature in database
GPG Key ID: 9A53E1BB3FF00461

View File

@ -23,11 +23,12 @@ if [ ! -r "$MODULE" ]; then
die "$MODULE: not found?"
fi
# Check if module is already loaded while remove trailing .ko if present
module=$(basename "$MODULE")
module=${module%.ko}
if lsmod | grep -q "^$module\\b"; then
DEBUG "$module: already loaded"
# Check if module is already loaded
# Transform module name changing _ for - and trailing .ko if present
# Unify lsmod output to use - instead of _ for comparison
module_name=$(basename "$MODULE" | sed 's/_/-/g' | sed 's/\.ko$//')
if lsmod | sed 's/_/-/g' | grep -q "^$module_name\\b"; then
DEBUG "$MODULE: already loaded"
exit 0
fi