blob: f22b3702cd747a84e87b38680fe068892a64c58c (
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
#! /bin/sh
# Autodetection script for scanning /sys for hardware
# for Archlinux by Tobias Powalowski <tpowa@archlinux.org>
usage () {
echo "$0 [options]"
echo ""
echo " This is a tool that detects/lists modules that are exported by /sys"
echo ""
echo " Options:"
echo " --load-modules load all detected modules"
echo " --unload-modules unload all detected modules"
echo " --show-modules show all detected modules"
echo " --show-modules-order shows load order of detected modules"
echo " --show-agp show AGP modules"
echo " --show-ide show IDE modules"
echo " --show-scsi show SCSI modules"
echo " --show-sata show SATA modules"
echo " --show-usb show USB modules"
echo " --show-fw show FIREWIRE modules"
echo " --show-net show NETWORK modules"
echo " --show-isdn show ISDN modules"
echo " --show-pcmcia show PCMCIA modules"
echo " --show-sound show SOUND modules"
echo " --show-video show VIDEO modules"
echo " --show-other show OTHER modules"
echo ""
echo " For /etc/mkinitrd.conf use:"
echo " --ide show detected HOSTCONTROLLER_IDE"
echo " --scsi show detected HOSTCONTROLLER_SCSI"
echo " --sata show detected HOSTCONTROLLER_SATA"
echo " --usb show detected HOSTCONTROLER_USB"
echo ""
exit 1
}
[ "$1" == "" ] && usage
if ! [ -d /sys/devices ]; then
echo "/sys/devices is not present -- mount /sys first" >&2
exit 1
fi
: >/tmp/modules-plain
: >/tmp/modules-stripped
: >/tmp/modules-sorted
: >/tmp/moduleslist
: >/tmp/modprobe
: >/tmp/modules
# find pci aliases
find /sys/devices/ -name "modalias" > /tmp/modules
# get the modaliases
for i in `cat /tmp/modules`; do
cat $i >> /tmp/modprobe
done
# generate files for the different actions
for i in `cat /tmp/modprobe`; do
modprobe -i --show-depends $i >> /tmp/modules-plain 2>/dev/null
done
# fix evdev detection
if [ "`grep 'serio:ty06pr*[id]*[ex]*' /tmp/modprobe`" ]; then
modprobe -i --show-depends evdev >> /tmp/modules-plain 2>/dev/null
fi
# fix Intel536ep detection
if [ "`grep 'pci:v00008086d00001040sv000016BEsd00001040bc07sc80i00' /tmp/modprobe`" ]; then
modprobe -i --show-depends Intel536 >> /tmp/modules-plain 2>/dev/null
fi
# find PNP devices like parports, soundcards etc.
# (workaround for rtc, pcspkr, irtty-sir and analog are included)
for i in `find /sys -name "id*" | grep pnp`; do
devid=`cat $i | grep PNP`
modprobe -i --show-depends pnp:d${devid} >> /tmp/modules-plain 2>/dev/null
[ "$devid" == "PNP0800" ] && modprobe -i --show-depends pcspkr >> /tmp/modules-plain 2>/dev/null
[ "$devid" == "PNP0b00" ] && modprobe -i --show-depends rtc >> /tmp/modules-plain 2>/dev/null
[ "$devid" == "PNP0510" ] && modprobe -i --show-depends irtty-sir >> /tmp/modules-plain 2>/dev/null
[ "$devid" == "PNP0511" ] && modprobe -i --show-depends irtty-sir >> /tmp/modules-plain 2>/dev/null
[ "$devid" == "PNPb02f" ] && modprobe -i --show-depends analog >> /tmp/modules-plain 2>/dev/null
# load ppp-generic if serial ports are detected for modems
[ "$devid" == "PNP0501" ] && modprobe -i --show-depends ppp-generic >> /tmp/modules-plain 2>/dev/null
done
# IDE disks/cdroms/floppy/tape
for i in $(cat `find /proc/ide -name "media"`); do
case $i in
cdrom) modprobe -i --show-depends ide-cd >> /tmp/modules-plain 2>/dev/null ;;
floppy) modprobe -i --show-depends ide-floppy >> /tmp/modules-plain 2>/dev/null ;;
disk) modprobe -i --show-depends ide-disk >> /tmp/modules-plain 2>/dev/null ;;
tape) modprobe -i --show-depends ide-tape >> /tmp/modules-plain 2>/dev/null ;;
esac
done
# SCSI disks/cdroms/tapes/generic devices
for i in $(cat `find /sys/devices -name "type"`); do
case $i in (3|4|5) modprobe -i --show-depends sr-mod >> /tmp/modules-plain 2>/dev/null ;; esac
case $i in (2|3|5|6|8|9) modprobe -i --show-depends sg >> /tmp/modules-plain 2>/dev/null ;; esac
case $i in (0|7|14) modprobe -i --show-depends sd-mod >> /tmp/modules-plain 2>/dev/null ;; esac
case $i in (1) modprobe -i --show-depends st >> /tmp/modules-plain 2>/dev/null ;; esac
done
# Firewire disks/cdroms/network
if [ "`grep 'ohci1394' /tmp/modules-plain`" ]; then
modprobe -i --show-depends sbp2 >> /tmp/modules-plain 2>/dev/null
modprobe -i --show-depends eth1394 >> /tmp/modules-plain 2>/dev/null
fi
# Modem devices
case $i in (Intel536|Intel537|ltmodem|ltserial|slarm|slusb) \
grep "$i" /tmp/modules-plain && modprobe -i --show-depends ppp-generic >> /tmp/modules-plain 2>/dev/null ;; esac
# Parport modules
if [ "`grep 'parport' /tmp/modules-plain`" ]; then
modprobe -i --show-depends lp >> /tmp/modules-plain 2>/dev/null
modprobe -i --show-depends ppdev >> /tmp/modules-plain 2>/dev/null
fi
# Sound OSS compat modules
if [ "`grep 'snd-pcm' /tmp/modules-plain`" ]; then
modprobe -i --show-depends snd-pcm-oss >> /tmp/modules-plain 2>/dev/null
fi
if [ "`grep 'snd-seq' /tmp/modules-plain`" ]; then
modprobe -i --show-depends snd-seq-oss >> /tmp/modules-plain 2>/dev/null
fi
sort -u /tmp/modules-plain >> /tmp/modules-stripped
# OTHER modules loading first for speedup!
grep -v "ide/" /tmp/modules-stripped | grep -v "scsi/" | grep -v "ata" | grep -v "net/" | grep -v "pcmcia/" \
| grep -v "usb/" | grep -v "ieee1394/" >> /tmp/modules-sorted
# make a correct order for the modules, internal devices have priority!
grep "ide/" /tmp/modules-stripped >> /tmp/modules-sorted
grep "scsi/" /tmp/modules-stripped | grep -v "sata" | grep -v "libata" | grep -v "ata_piix" >> /tmp/modules-sorted
grep "ata" /tmp/modules-stripped | grep -v "eata" >> /tmp/modules-sorted
grep "net/" /tmp/modules-stripped | grep -v "wireless/" | grep -v "usb/" >> /tmp/modules-sorted
grep "wireless/" /tmp/modules-stripped >> /tmp/modules-sorted
grep "pcmcia/" /tmp/modules-stripped >> /tmp/modules-sorted
# speedup usb module loading
grep "usb-storage" /tmp/modules-stripped >> /tmp/modules-sorted
grep "usblp" /tmp/modules-stripped >> /tmp/modules-sorted
grep "usbhid" /tmp/modules-stripped >> /tmp/modules-sorted
grep "usb/" /tmp/modules-stripped | grep -v "usb-storage" | grep -v "usbhid" | grep -v "usblp" >> /tmp/modules-sorted
grep "ieee1394/" /tmp/modules-stripped >> /tmp/modules-sorted
sed -ne "s#^insmod.*/\(.*\)\.ko.*#\1#p" /tmp/modules-sorted >> /tmp/moduleslist
# delete modules that are blacklisted
for i in $BLACKLIST; do
[ "$i" ] || continue
sed -i -e "/^$i$/d" /tmp/moduleslist
# since '-' and '_' are interchangeable, we have to cover both
if [ "`echo $i | grep '-'`" ]; then
i="`echo $i | sed 's|-|_|g'`"
sed -i -e "/^$i$/d" /tmp/moduleslist
elif [ "`echo $i | grep '_'`" ]; then
i="`echo $i | sed 's|_|-|g'`"
sed -i -e "/^$i$/d" /tmp/moduleslist
fi
done
listmods() {
key=$1 ; shift
ex=
while [ "$1" ]; do
[ "$ex" ] && ex="$ex|$1" || ex="$1"
shift
done
for ln in `grep "$key" /tmp/modules-sorted | sed 's|^insmod ||g'`; do
if [ "$ex" ]; then
echo $ln | egrep -v "$ex" | sed -ne "s#^/.*/\(.*\)\.ko.*#\1#p"
else
echo $ln | sed -ne "s#^/.*/\(.*\)\.ko.*#\1#p"
fi
done
}
showlist() {
cat=$1 ; shift
[ $# -gt 0 ] || return
echo -n "$cat: "
for i in $*; do echo -n "$i "; done
echo ""
}
# starting different actions
while [ $# -gt 0 ]; do
case $1 in
--load-modules)
# load all detected pci modules
for i in `cat /tmp/moduleslist`; do
modprobe $i > /dev/null 2>&1
done
;;
--unload-modules)
# load all detected pci modules
for i in `cat /tmp/moduleslist`; do
modprobe -r $i > /dev/null 2>&1
done
;;
--show-modules)
showlist "AGP " `listmods agp/`
showlist "IDE " `listmods ide/`
showlist "SCSI " `listmods scsi/ sata ata_piix libata` `listmods message/fusion/`
showlist "SATA " `listmods ata eata`
showlist "USB " `listmods usb/`
showlist "FW " `listmods ieee1394/`
showlist "NET " `listmods net/`
showlist "ISDN " `listmods isdn/`
showlist "PCMCIA " `listmods pcmcia/`
showlist "SOUND " `listmods sound/`
showlist "VIDEO " `listmods video/`
showlist "OTHER " `listmods modules/ agp/ ide/ scsi/ sata usb/ ieee1394 net/ isdn/ pcmcia/ sound/ video/`
;;
--show-modules-order)
showlist "MODULES ORDER" `listmods modules/`
;;
--show-agp) showlist "AGP " `listmods agp/` ;;
--show-ide) showlist "IDE " `listmods ide/` ;;
--show-scsi) showlist "SCSI " `listmods scsi/ sata ata_piix libata` `listmods message/fusion/` ;;
--show-sata) showlist "SATA " `listmods ata eata` ;;
--show-usb) showlist "USB " `listmods usb/` ;;
--show-fw) showlist "FW " `listmods ieee1394/` ;;
--show-net) showlist "NET " `listmods net/` ;;
--show-isdn) showlist "ISDN " `listmods isdn/` ;;
--show-pcmcia) showlist "PCMCIA " `listmods pcmcia/` ;;
--show-sound) showlist "SOUND " `listmods sound/` ;;
--show-video) showlist "VIDEO " `listmods video/` ;;
--show-other) showlist "OTHER " `listmods .ko agp/ ide/ scsi/ sata usb/ ieee1394 net/ isdn/ pcmcia/ sound/ video` ;;
--ide) showlist "HOSTCONTROLLER_IDE" `listmods ide/pci` ;;
--scsi) showlist "HOSTCONTROLLER_SCSI" `listmods scsi/ sata ata_piix libata` `listmods message/fusion/` ;;
--sata) showlist "HOSTCONTROLLER_SATA" `listmods ata eata libata` ;;
--usb) showlist "HOSTCONTROLLER_USB" `listmods usb/host` "" ;;
esac
shift
done
# cleanup
rm /tmp/{modules-plain,modules-sorted,modules-stripped,moduleslist,modprobe,modules}
# vim: set ts=2 sw=2 nowrap:
|