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