From 176df1505a2ebbb2437669295d1422c8af6157fe Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Mon, 28 Sep 2020 11:04:39 +0800 Subject: [PATCH] Move init.insmod.sh back to devices Its permission is related to the module it loads, and they vary from device to device Bug: 168440095 Test: boot with no SELinux error log Change-Id: Idf058b54bfc8250cf2c574ade285ab479af59cb3 --- device.mk | 1 + init.insmod.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 init.insmod.sh diff --git a/device.mk b/device.mk index 814be034..bfa9b576 100644 --- a/device.mk +++ b/device.mk @@ -132,6 +132,7 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/uinput-fpc.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/uinput-fpc.kl \ $(LOCAL_PATH)/uinput-fpc.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/uinput-fpc.idc \ $(LOCAL_PATH)/init.hardware.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.$(PRODUCT_PLATFORM).usb.rc \ + $(LOCAL_PATH)/init.insmod.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.insmod.sh \ $(LOCAL_PATH)/init.sensors.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.sensors.sh \ $(LOCAL_PATH)/thermal-engine-$(PRODUCT_HARDWARE).conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine-$(PRODUCT_HARDWARE).conf \ $(LOCAL_PATH)/ueventd.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \ diff --git a/init.insmod.sh b/init.insmod.sh new file mode 100644 index 00000000..a222838c --- /dev/null +++ b/init.insmod.sh @@ -0,0 +1,53 @@ +#!/vendor/bin/sh + +############################################################# +### init.insmod.cfg format: ### +### ----------------------------------------------------- ### +### [insmod|setprop|enable/moprobe|wait] [path|prop name] ### +### ... ### +############################################################# + +# imitates wait_for_file() in init +wait_for_file() +{ + filename="${1}" + timeout="${2:-5}" + + expiry=$(($(date "+%s")+timeout)) + while [[ ! -e "${filename}" ]] && [[ "$(date "+%s")" -le "${expiry}" ]] + do + sleep 0.01 + done +} + +if [ $# -eq 1 ]; then + cfg_file=$1 +else + exit 1 +fi + + +if [ -f $cfg_file ]; then + while IFS="|" read -r action arg + do + case $action in + "insmod") insmod $arg ;; + "setprop") setprop $arg 1 ;; + "enable") echo 1 > $arg ;; + "modprobe") + case ${arg} in + "-b *" | "-b") + arg="-b $(cat /vendor/lib/modules/modules.load)" ;; + "*" | "") + arg="$(cat /vendor/lib/modules/modules.load)" ;; + esac + modprobe -a -d /vendor/lib/modules $arg ;; + "wait") wait_for_file $arg ;; + esac + done < $cfg_file +fi + +# set property even if there is no insmod config +# as property value "1" is expected in early-boot trigger +setprop vendor.all.modules.ready 1 +setprop vendor.all.devices.ready 1