Whamcloud - gitweb
Be more specific so that other lustre* cruft is not picked up.
[fs/lustre-release.git] / build / sles8-update_INITRD_MODULES.sh
1 # Check if $1 is equal to any argument in $1 .. $*.
2 #
3 contains() {
4     local x=$1
5     shift
6
7     case " $@ " in
8     *" $x "*)   return 0 ;;
9     *)          return 1 ;;
10     esac
11 }
12
13 # Check the old value of INITRD_MODULES:
14 #  - Remove modules that no longer exist.
15 #  - Add modules that were built into the kernel before.
16 #
17 update_INITRD_MODULES() {
18     # MD_MODS is the list of modules that require md.o.
19     local MD_MODS="linear multipath raid0 raid1 raid5"
20
21     # NON_SCSI is a whitelist of modules that are no scsi drivers. Any
22     # module not listed here is assumed to be a scsi driver, and the
23     # low-level scsi modules are added to INITRD_MODULES.
24     local NON_SCSI="jbd ext3 jfs xfs reiserfs $MD_MODS md"
25
26     local result maybe_scsi need_md have_md have_scsi have_sd m
27     for m in "$@" ; do
28         m="${m%.o}" ; m="${m%.ko}"
29         
30         contains "$m" $NON_SCSI || maybe_scsi=1
31         contains "$m" $MD_MODS && need_md=1
32         [ "$m" == md ] && have_md=1
33         if contains "$m" scsi_mod sd_mod ; then
34             eval have_${m%_mod}=1
35             continue
36         fi
37         if contains "$m" xfs_dmapi xfs_support ; then
38             echo "Module $m no longer exists, and was removed from" \
39                  "INITRD_MODULES." >&2
40             continue
41         fi
42         
43         result[${#result[@]}]="$m"
44     done
45     if [ -n "$maybe_scsi" -o -n "$have_scsi" -o -n "$have_sd" ]; then
46         [ -z "$have_scsi" -o -z "$have_sd" ] \
47             && echo "Adding SCSI disk modules to INITRD_MODULES" >&2
48         result=(scsi_mod sd_mod ${result[@]})
49     fi
50     if [ -n "$need_md" -a -z "$have_md" ]; then
51         echo "Adding RAID support module to INITRD_MODULES" >&2
52         result=(md ${result[@]})
53     fi
54
55     echo ${result[@]}
56 }