blob: 87901220e100641cec407c0fa63dc292ed377a40 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#!/bin/ash
# Apparently, this is required for proper functionality with busybox 1.1.3
# Check out bug #197730 for more details.
. /etc/initrd.defaults
usage() {
echo 'Usage:'
echo ' modprobe moduleprefix'
echo
echo 'Example:'
echo ' modprobe eepro100'
echo
echo 'Note: Do not pass the suffix to modprobe!'
exit 1
}
# Pass module name to this function
modules_dep_list() {
if [ "$#" -lt '1' ]
then
echo 'modules_dep_list(): Improper usage!'
exit 1
fi
cat /lib/modules/${KV}/modules.dep | grep /"${1}${KSUFF}:" | cut -d':' -f2
}
# Pass module deps list
strip_mod_paths() {
local x
local ret
local myret
[ "$#" -lt '1' ] && return
for x in ${*}
do
ret=`basename ${x} | cut -d. -f1`
myret="${myret} ${ret}"
done
echo "${myret}"
}
LOADED_MODULES=''
is_module_already_loaded() {
local x
if [ "$#" != '1' ]
then
echo 'is_module_already_loaded(): Improper usage!'
fi
for x in ${LOADED_MODULES}
do
if [ "${x}" = "${1}" ]
then
# Yep, module is loaded
return 0
fi
done
return 1
}
real_mod_path() {
# Find -name is no good since the return status is always zero
find "/lib/modules/${KV}" | grep /"${1}${KSUFF}"
}
modprobe2() {
local x
local deps
local real_path
local modlist
local ret
local echoAppend
local echoFlags
if [ "$#" -lt '1' ]
then
usage
exit 1
fi
real_path=`real_mod_path ${1}`
if [ "${real_path}" = '' -o "${real_path}" = ' ' ]
then
[ "${2}" = '-n' ] && echo -n " -> $1"
echo ' module not found.'
exit 2
fi
modlist=`modules_dep_list ${1}`
if [ "${modlist}" != '' -a "${modlist}" != ' ' ]
then
deps=`strip_mod_paths ${modlist}`
else
deps=''
fi
# Make sure we don't do any endless loops!
LOADED_MODULES="${LOADED_MODULES} ${1}"
for x in ${deps}
do
if ! is_module_already_loaded ${x}
then
if [ "${x}" != '' -a "${x}" != ' ' ]
then
modprobe2 "${x}" -n
fi
else
filler=1
fi
done
${INSMOD} ${real_path} > /dev/null 2>&1
ret=$?
if [ "$ret" -eq '0' ]
then
echoAppend=' loaded.'
[ "${2}" = '-n' ] && echoFlags='-n' && echoAppend=', '
echo ${echoFlags} "${1}${echoAppend}"
fi
return $ret
}
if [ "$#" -lt '1' ]
then
usage
fi
[ -f '/modules.cache' ] || touch /modules.cache
for x in `cat /modules.cache`
do
LOADED_MODULES="${LOADED_MODULES} ${x}"
done
modprobe2 ${1}
modprobe_ret=$?
[ -f '/modules.cache' ] && rm -f /modules.cache > /dev/null 2>&1
for x in ${LOADED_MODULES}
do
echo $x >> /modules.cache
done
exit $modprobe_ret
|