2 IDE_RCSID='$Revision$ $Date:: $'
6 PREIDEMODS="-ide-core unknown -ide-detect -ide-disk -ide-gd_mod"
7 PREIDEMODSOLD="-ide-probe -ide-probe-mod -ide-disk -ide-gd_mod"
10 ide_only_root=${ide_only_root:-no}
12 # allow forcing loading IDE modules, likely from sysconfig/geninitrd
15 # return true if node is ide device
16 # @param string $node device node to be examined
20 if [ ! -e "$node" ]; then
21 warn "is_ide(): node $node doesn't exist!"
25 # TODO: more sophisticated check, not just pathname check
26 if is_yes "$(echo "$node" | awk '/^\/dev\/(hd[a-l]|ide\/)/ { print "yes"; }')"; then
33 # find modules for $devpath
34 # @param $devpath device to be examined
38 # remove partition, if any
39 local disk=${devpath%[0-9]*}
40 # set blockdev for rootfs (hda, sdc, ...)
41 local rootblkdev=${disk#/dev/}
44 if [ "$kernel_version_long" -lt "002004021" ]; then
45 debug "Finding IDE modules for kernels <= 2.4.20"
46 for n in $PREIDEMODSOLD; do
51 for n in $PREIDEMODS; do
52 if [ "X$n" = "Xunknown" ]; then
53 debug "Finding IDE modules using ide_hostadapter"
54 local mod idemodules=$(modprobe_conf | awk '/ide_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
55 for mod in $idemodules; do
60 if [ "$tryauto" -eq 1 ]; then
62 if [ -r /usr/share/pci-database/ide.pci -a -r /proc/bus/pci/devices ]; then
63 debug "Finding IDE modules using PCI ID database"
64 # Finding IDE modules using PCI ID database {{{
65 if is_yes "${ide_only_root}"; then
66 if [ -f /sys/block/${rootblkdev}/device/../../vendor -a -f /sys/block/${rootblkdev}/device/../../device ]; then
67 vendorid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootblkdev}/device/../../vendor)"
68 deviceid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootblkdev}/device/../../device)"
69 searchpciid="${vendorid}${deviceid}"
70 elif [ -f /proc/ide/${rootblkdev}/../config ]; then
71 searchpciid="$(awk ' /pci bus/ { print $7$9 } ' /proc/ide/${rootblkdev}/../config)"
75 if [ -z "${searchpciid}" ]; then
76 searchpciid="$(awk ' { print $2 } ' /proc/bus/pci/devices)"
81 for nb in $searchpciid; do
82 eval `awk -v pciid="$nb" '{
88 compmod = $1 ""; # make sure comparison type will be string
89 # cause pci IDs are hexadecimal numeric
90 if (compmod == pciid) {
92 # min_kernel=$3; # now in ide.pci $3,$4 = vendor and device name
99 print "module=" module "\nmin_kernel=" min_kernel "\nmax_kernel=\"" max_kernel "\"\n";
100 }' /usr/share/pci-database/ide.pci`
101 [ -n "$module" ] && idemodules="$idemodules $module"
103 if is_yes "$(awk ' /ide=reverse/ { print "yes" } ' /proc/cmdline)"; then
105 for nc in idemodules; do
106 new_idemodules="$nc $new_idemodules"
108 idemodules="${new_idemodules}"
111 if [ -z "$idemodules" ]; then
112 warn "rootfs on IDE device but no related modules found, loading ide-generic."
113 idemodules="ide-generic"
117 for nd in $idemodules; do
123 [ -r /usr/share/pci-database/ide.pci ] || warn "/usr/share/pci-database/ide.pci missing."
124 [ -r /proc/bus/pci/devices ] || warn "/proc/bus/pci/devices missing."
125 warn "Automatic IDE modules finding not available."
136 # generate initrd fragment for ide device init