Snap for 9033936 from e4a75e452a
to udc-release
Change-Id: Id343c685b1cf05830159416193d37b01f82a1b1a
This commit is contained in:
commit
c97db6d29a
9 changed files with 127 additions and 0 deletions
13
insmod/Android.bp
Normal file
13
insmod/Android.bp
Normal file
|
@ -0,0 +1,13 @@
|
|||
sh_binary {
|
||||
name: "insmod.sh",
|
||||
src: "insmod.sh",
|
||||
init_rc: ["init.module.rc"],
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
prebuilt_etc {
|
||||
name: "init.common.cfg",
|
||||
src: "init.common.cfg",
|
||||
vendor: true,
|
||||
}
|
||||
|
11
insmod/init.common.cfg
Normal file
11
insmod/init.common.cfg
Normal file
|
@ -0,0 +1,11 @@
|
|||
####################################################
|
||||
# init.insmod.common.cfg #
|
||||
# This file contains common kernel modules to load #
|
||||
# at init time by init.insmod.sh script #
|
||||
####################################################
|
||||
|
||||
# Load common kernel modules
|
||||
# Modules here will be loaded *before* device specific modules
|
||||
modprobe|-b *
|
||||
# All common modules loaded
|
||||
setprop|vendor.common.modules.ready
|
10
insmod/init.module.rc
Normal file
10
insmod/init.module.rc
Normal file
|
@ -0,0 +1,10 @@
|
|||
on init
|
||||
# Loading common kernel modules in background
|
||||
start insmod_sh
|
||||
|
||||
service insmod_sh /vendor/bin/insmod.sh /vendor/etc/init.common.cfg
|
||||
class main
|
||||
user root
|
||||
group root system
|
||||
disabled
|
||||
oneshot
|
4
insmod/insmod.mk
Normal file
4
insmod/insmod.mk
Normal file
|
@ -0,0 +1,4 @@
|
|||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/insmod/sepolicy
|
||||
PRODUCT_PACKAGES += \
|
||||
insmod.sh \
|
||||
init.common.cfg
|
67
insmod/insmod.sh
Executable file
67
insmod/insmod.sh
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/vendor/bin/sh
|
||||
|
||||
#############################################################
|
||||
### init.insmod.cfg format: ###
|
||||
### ----------------------------------------------------- ###
|
||||
### [insmod|setprop|enable/moprobe|wait] [path|prop name] ###
|
||||
### ... ###
|
||||
#############################################################
|
||||
|
||||
modules_dir=
|
||||
|
||||
for f in /vendor/lib/modules/*/modules.dep /vendor/lib/modules/modules.dep; do
|
||||
if [[ -f "$f" ]]; then
|
||||
modules_dir="$(dirname "$f")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${modules_dir}" ]]; then
|
||||
echo "Unable to locate kernel modules directory" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 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
|
||||
# Set property even if there is no insmod config
|
||||
# to unblock early-boot trigger
|
||||
setprop vendor.common.modules.ready
|
||||
setprop vendor.device.modules.ready
|
||||
setprop vendor.all.modules.ready
|
||||
setprop vendor.all.devices.ready
|
||||
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 --all=${modules_dir}/modules.load" ;;
|
||||
"*" | "")
|
||||
arg="--all=${modules_dir}/modules.load" ;;
|
||||
esac
|
||||
modprobe -a -d "${modules_dir}" $arg ;;
|
||||
"wait") wait_for_file $arg ;;
|
||||
esac
|
||||
done < $cfg_file
|
||||
fi
|
5
insmod/sepolicy/file_contexts
Normal file
5
insmod/sepolicy/file_contexts
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Vendor_kernel_modules
|
||||
/vendor_dlkm/lib/modules/.*\.ko u:object_r:vendor_kernel_modules:s0
|
||||
|
||||
/vendor/bin/insmod\.sh u:object_r:insmod-sh_exec:s0
|
||||
|
11
insmod/sepolicy/insmod-sh.te
Normal file
11
insmod/sepolicy/insmod-sh.te
Normal file
|
@ -0,0 +1,11 @@
|
|||
type insmod-sh, domain;
|
||||
type insmod-sh_exec, vendor_file_type, exec_type, file_type;
|
||||
init_daemon_domain(insmod-sh)
|
||||
|
||||
allow insmod-sh self:capability sys_module;
|
||||
allow insmod-sh vendor_kernel_modules:system module_load;
|
||||
allow insmod-sh vendor_toolbox_exec:file execute_no_trans;
|
||||
|
||||
set_prop(insmod-sh, vendor_device_prop)
|
||||
|
||||
dontaudit insmod-sh proc_cmdline:file r_file_perms;
|
1
insmod/sepolicy/property.te
Normal file
1
insmod/sepolicy/property.te
Normal file
|
@ -0,0 +1 @@
|
|||
vendor_internal_prop(vendor_device_prop)
|
5
insmod/sepolicy/property_contexts
Normal file
5
insmod/sepolicy/property_contexts
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Kernel modules related
|
||||
vendor.common.modules.ready u:object_r:vendor_device_prop:s0
|
||||
vendor.device.modules.ready u:object_r:vendor_device_prop:s0
|
||||
vendor.all.modules.ready u:object_r:vendor_device_prop:s0
|
||||
vendor.all.devices.ready u:object_r:vendor_device_prop:s0
|
Loading…
Add table
Add a link
Reference in a new issue