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?" die "$MODULE: not found?"
fi fi
# Check if module is already loaded while remove trailing .ko if present # Check if module is already loaded
module=$(basename "$MODULE") # Transform module name changing _ for - and trailing .ko if present
module=${module%.ko} # Unify lsmod output to use - instead of _ for comparison
if lsmod | grep -q "^$module\\b"; then module_name=$(basename "$MODULE" | sed 's/_/-/g' | sed 's/\.ko$//')
DEBUG "$module: already loaded" if lsmod | sed 's/_/-/g' | grep -q "^$module_name\\b"; then
DEBUG "$MODULE: already loaded"
exit 0 exit 0
fi fi