1#!/vendor/bin/sh 2 3# Copyright (C) 2019 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18KERNEL_VERSION_NUMBER=`uname -r` 19MAINLINE_STR='mainline' 20if [[ $KERNEL_VERSION_NUMBER == *$MAINLINE_STR* ]]; then 21 IS_MAINLINE=1 22else 23 IS_MAINLINE=0 24fi 25 26KERNEL_VERSION_NUMBER=`echo $KERNEL_VERSION_NUMBER | grep -o -E '^[0-9]+\.[0-9]+'` 27# This folder on cuttlefish contains modules for multiple kernel versions. 28# Hence the need to filter them instead of relying on module.order 29VENDOR_MODULES='/vendor/lib/modules/*.ko' 30 31for f in $VENDOR_MODULES 32do 33 MOD_VERSION=`modinfo $f` 34 MOD_VERSION=`echo $MOD_VERSION | grep -o -E 'vermagic: [0-9a-zA-Z\.-]+'` 35 MOD_VERSION_NUMBER=`echo $MOD_VERSION | grep -o -E '[0-9]+\.[0-9]+'` 36 if [[ $MOD_VERSION == *$MAINLINE_STR* ]]; then 37 IS_MOD_MAINLINE=1 38 else 39 IS_MOD_MAINLINE=0 40 fi 41 42 # TODO (137683279) When we have a few more kernel modules, we'll have to do the module 43 # insertion of least dependencies. 44 if [ $IS_MOD_MAINLINE -eq $IS_MAINLINE ] && [ $MOD_VERSION_NUMBER == $KERNEL_VERSION_NUMBER ] 45 then 46 `insmod $f` 47 echo "Insmod " $f 48 fi 49done 50