4 PREIDEMODS="-ide-core unknown -ide-detect -ide-disk -ide-gd_mod"
5 PREIDEMODSOLD="-ide-probe -ide-probe-mod -ide-disk -ide-gd_mod"
8 ide_only_root=${ide_only_root:-no}
10 # allow forcing loading IDE modules, likely from sysconfig/geninitrd
13 # return true if node is ide device
14 # @param string $node device node to be examined
18 if [ ! -e "$node" ]; then
19 warn "is_ide(): node $node doesn't exist!"
23 # TODO: more sophisticated check, not just pathname check
24 if is_yes "$(echo "$node" | awk '/^\/dev\/(hd[a-l]|ide\/)/ { print "yes"; }')"; then
31 # find modules for $devpath
32 # @param $devpath device to be examined
36 # remove partition, if any
37 local disk=${devpath%[0-9]*}
38 # set blockdev for rootfs (hda, sdc, ...)
39 local rootblkdev=${disk#/dev/}
42 if [ "$kernel_version_long" -lt "002004021" ]; then
43 verbose "Finding IDE modules for kernels <= 2.4.20"
44 for n in $PREIDEMODSOLD; do
49 for n in $PREIDEMODS; do
50 if [ "X$n" = "Xunknown" ]; then
51 verbose "Finding IDE modules using ide_hostadapter"
52 local mod idemodules=$(modprobe_conf | awk '/ide_hostadapter/ { print $3 }')
53 for mod in $idemodules; do
58 if [ "$tryauto" -eq 1 ]; then
60 if [ -r /usr/share/pci-database/ide.pci -a -r /proc/bus/pci/devices ]; then
61 verbose "Finding IDE modules using PCI ID database"
62 # Finding IDE modules using PCI ID database {{{
63 if is_yes "${ide_only_root}"; then
64 if [ -f /sys/block/${rootblkdev}/device/../../vendor -a -f /sys/block/${rootblkdev}/device/../../device ]; then
65 vendorid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootblkdev}/device/../../vendor)"
66 deviceid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootblkdev}/device/../../device)"
67 searchpciid="${vendorid}${deviceid}"
68 elif [ -f /proc/ide/${rootblkdev}/../config ]; then
69 searchpciid="$(awk ' /pci bus/ { print $7$9 } ' /proc/ide/${rootblkdev}/../config)"
73 if [ -z "${searchpciid}" ]; then
74 searchpciid="$(awk ' { print $2 } ' /proc/bus/pci/devices)"
79 for nb in $searchpciid; do
80 eval `awk -v pciid="$nb" '{
86 compmod = $1 ""; # make sure comparison type will be string
87 # cause pci IDs are hexadecimal numeric
88 if (compmod == pciid) {
90 # min_kernel=$3; # now in ide.pci $3,$4 = vendor and device name
97 print "module=" module "\nmin_kernel=" min_kernel "\nmax_kernel=\"" max_kernel "\"\n";
98 }' /usr/share/pci-database/ide.pci`
99 [ -n "$module" ] && idemodules="$idemodules $module"
101 if is_yes "$(awk ' /ide=reverse/ { print "yes" } ' /proc/cmdline)"; then
103 for nc in idemodules; do
104 new_idemodules="$nc $new_idemodules"
106 idemodules="${new_idemodules}"
109 if [ -z "$idemodules" ]; then
110 warn "rootfs on IDE device but no related modules found, loading ide-generic."
111 idemodules="ide-generic"
115 for nd in $idemodules; do
121 [ -r /usr/share/pci-database/ide.pci ] || warn "/usr/share/pci-database/ide.pci missing."
122 [ -r /proc/bus/pci/devices ] || warn "/proc/bus/pci/devices missing."
123 warn "Automatic IDE modules finding not available."
134 # generate initrd fragment for ide device init