blob: d43f22c6c4c8976cc4b6564300dc0328b39c922b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/system/bin/sh
path=/lib/modules
# $1: name of the module
modprobe_with_depen()
{
OIFS=$IFS
IFS=','
local mod=$1
local _mod=$(echo $mod | sed 's/-/_/g')
# $mod not present in $path
[[ -f $path/$mod.ko ]] || return
# Return if $mod is already inserted
[[ $(lsmod | cut -d ' ' -f 1 | grep "^$_mod$") ]] && return
# Find and insert all modules on which $mod depend
dependencies=$(modinfo $path/$mod.ko | grep depends\: | sed 's/^depends\:\ *//')
for dep in $dependencies
do
modprobe_with_depen $dep
done
insmod $path/$mod.ko
IFS=$OIFS;
}
# Inserts all modules present in /lib/modules/ and named as g*.ko
insert_modules()
{
# Get name of the module
for mod in $(ls $path/g*.ko)
do
modprobe_with_depen $(echo $(basename $mod) | sed 's/\.ko//')
done
}
# For testing only
remove_modules()
{
for mod in $(lsmod | sed 1d | sed 's/\ .*//')
do
rmmod -f $mod
done
}
# Uncomment below for testing
remove_modules
|