insmod: Add support to load kernel modules from /system/lib/modules

Bug: 267429528
Change-Id: I15a375cf1adeab12b969b2e3185ea6f55317d886
Signed-off-by: Robin Peng <robinpeng@google.com>
This commit is contained in:
Robin Peng 2023-03-15 01:22:07 +00:00
parent f938468e2e
commit dbf355ee8b
2 changed files with 38 additions and 13 deletions

View File

@ -6,6 +6,7 @@
# Load common kernel modules # Load common kernel modules
# Modules here will be loaded *before* device specific modules # Modules here will be loaded *before* device specific modules
modprobe|-b * modprobe|system -b *
modprobe|vendor -b *
# All common modules loaded # All common modules loaded
setprop|vendor.common.modules.ready setprop|vendor.common.modules.ready

View File

@ -8,16 +8,29 @@
############################################################# #############################################################
modules_dir= modules_dir=
system_modules_dir=
vendor_modules_dir=
for f in /vendor/lib/modules/*/modules.dep /vendor/lib/modules/modules.dep; do for dir in system vendor; do
for f in /${dir}/lib/modules/*/modules.dep /${dir}/lib/modules/modules.dep; do
if [[ -f "$f" ]]; then if [[ -f "$f" ]]; then
modules_dir="$(dirname "$f")" if [[ "${dir}" == "system" ]]; then
system_modules_dir="$(dirname "$f")"
else
vendor_modules_dir="$(dirname "$f")"
modules_dir=${vendor_modules_dir}
fi
break break
fi fi
done done
done
if [[ -z "${modules_dir}" ]]; then if [[ -z "${system_modules_dir}" ]]; then
echo "Unable to locate kernel modules directory" 2>&1 echo "Unable to locate system kernel modules directory" 2>&1
fi
if [[ -z "${vendor_modules_dir}" ]]; then
echo "Unable to locate vendor kernel modules directory" 2>&1
exit 1 exit 1
fi fi
@ -55,12 +68,23 @@ if [ -f $cfg_file ]; then
"enable") echo 1 > $arg ;; "enable") echo 1 > $arg ;;
"modprobe") "modprobe")
case ${arg} in case ${arg} in
"-b *" | "-b") "system -b *" | "system -b")
arg="-b --all=${modules_dir}/modules.load" ;; modules_dir=${system_modules_dir}
"*" | "") arg="-b --all=${system_modules_dir}/modules.load" ;;
arg="--all=${modules_dir}/modules.load" ;; "system *" | "system")
modules_dir=${system_modules_dir}
arg="--all=${system_modules_dir}/modules.load" ;;
"-b *" | "-b" | "vendor -b *" | "vendor -b")
modules_dir=${vendor_modules_dir}
arg="-b --all=${vendor_modules_dir}/modules.load" ;;
"*" | "" | "vendor *" | "vendor")
modules_dir=${vendor_modules_dir}
arg="--all=${vendor_modules_dir}/modules.load" ;;
esac esac
modprobe -a -d "${modules_dir}" $arg ;; if [[ -d "${modules_dir}" ]]; then
modprobe -a -d "${modules_dir}" $arg
fi
;;
"wait") wait_for_file $arg ;; "wait") wait_for_file $arg ;;
esac esac
done < $cfg_file done < $cfg_file