From dd891ec481f9278b4831d542db3ca1fef2556d51 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 6 Aug 2017 12:33:08 +0000 Subject: [PATCH] Improve loading of kernel modules This does not need to call grep any more Signed-off-by: Michael Tremer --- src/functions/functions.util | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/functions/functions.util b/src/functions/functions.util index 018276cc..687d008f 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -607,10 +607,13 @@ beautify_bytes() { module_load() { local module=${1} - if ! grep -q "^${module}" /proc/modules; then - log DEBUG "Loading module '${module}'." - modprobe ${module} + # Do nothing if the module is already loaded + if [ -d "/sys/module/${module//-/_}" ]; then + return ${EXIT_OK} fi + + log DEBUG "Loading kernel module ${module}" + modprobe "${module}" } binary_exists() { -- 2.47.3