Skip to content

Commit

Permalink
insmod: uniformize module name and lsmod output prior of comapring if…
Browse files Browse the repository at this point in the history
… module already insmodded (ehci-hcd.ko module name is ehci_hcd...)

Signed-off-by: Thierry Laurion <[email protected]>
  • Loading branch information
tlaurion committed Feb 23, 2024
1 parent 14727e0 commit c065fb7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions initrd/sbin/insmod
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c065fb7

Please sign in to comment.