]> git.pld-linux.org Git - projects/geninitrd.git/blame - mod-ide.sh
Allow more than 10 md devices.
[projects/geninitrd.git] / mod-ide.sh
CommitLineData
30ca4815
ER
1#!/bin/sh
2#
3# geninitrd mod: ide
4
74578b86
AM
5PREIDEMODS="-ide-core unknown -ide-detect -ide-disk -ide-gd_mod"
6PREIDEMODSOLD="-ide-probe -ide-probe-mod -ide-disk -ide-gd_mod"
30ca4815
ER
7
8# ???
9ide_only_root=${ide_only_root:-no}
10
11# allow forcing loading IDE modules, likely from sysconfig/geninitrd
12ADDIDE=${ADDIDE:-no}
13
14# return true if node is ide device
15# @param string $node device node to be examined
16# @access public
17is_ide() {
18 local node="$1"
19 if [ ! -e "$node" ]; then
20 warn "is_ide(): node $node doesn't exist!"
21 return 1
22 fi
23
24 # TODO: more sophisticated check, not just pathname check
25 if is_yes "$(echo "$node" | awk '/^\/dev\/(hd[a-l]|ide\/)/ { print "yes"; }')"; then
26 return 0
27 fi
28
29 return 1
30}
31
32# find modules for $devpath
33# @param $devpath device to be examined
34# @access public
35find_modules_ide() {
36 local devpath=$1
37 # remove partition, if any
38 local disk=${devpath%[0-9]*}
39 # set blockdev for rootfs (hda, sdc, ...)
40 local rootblkdev=${disk#/dev/}
41
42 local n
b02a6b13 43 if [ "$kernel_version_long" -lt "002004021" ]; then
30ca4815
ER
44 debug "Finding IDE modules for kernels <= 2.4.20"
45 for n in $PREIDEMODSOLD; do
b02a6b13 46 find_module "$n"
30ca4815
ER
47 done
48 else
49 local tryauto=1
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
55 tryauto=0;
b02a6b13 56 find_module "$mod"
30ca4815
ER
57 done
58
59 if [ "$tryauto" -eq 1 ]; then
60 # If tryauto {{{
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)"
71 fi
72 fi
73
74 if [ -z "${searchpciid}" ]; then
75 searchpciid="$(awk ' { print $2 } ' /proc/bus/pci/devices)"
76 fi
77
78 idemodules=""
79
80 for nb in $searchpciid; do
81 eval `awk -v pciid="$nb" '{
82 gsub("\t"," ");
83 gsub(" +", " ");
84 gsub("^ ","");
85 if (/^[\t ]*#/)
86 next;
87 compmod = $1 ""; # make sure comparison type will be string
88 # cause pci IDs are hexadecimal numeric
89 if (compmod == pciid) {
90 module=$2;
91 # min_kernel=$3; # now in ide.pci $3,$4 = vendor and device name
92 # max_kernel=$4; #
93 exit 0;
94 }
95 }
96
97 END {
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"
101 done
102 if is_yes "$(awk ' /ide=reverse/ { print "yes" } ' /proc/cmdline)"; then
103 new_idemodules=""
104 for nc in idemodules; do
105 new_idemodules="$nc $new_idemodules"
106 done
107 idemodules="${new_idemodules}"
108 fi
109
110 if [ -z "$idemodules" ]; then
111 warn "rootfs on IDE device but no related modules found, loading ide-generic."
112 idemodules="ide-generic"
113 fi
114
115 # }}}
116 for nd in $idemodules; do
b02a6b13 117 find_module "-$nd"
30ca4815
ER
118 done
119 # }}}
120 # else tryauto {{{
121 else
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."
125 fi
126 # }}}
127 fi
128 else
b02a6b13 129 find_module "$n"
30ca4815
ER
130 fi
131 done
132 fi
133}
134
135# generate initrd fragment for ide device init
136# @access public
137initrd_gen_ide() {
138 # nothing to do here
139 return 0
140}
This page took 0.04091 seconds and 4 git commands to generate.