]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/grub-0.97-dmraid.patch
cryptodev: Update kernel module.
[people/pmueller/ipfire-2.x.git] / src / patches / grub-0.97-dmraid.patch
CommitLineData
82705b6e
MT
1--- grub-0.97/util/grub-install.in.dmraid 2006-01-13 16:40:24.000000000 -0500
2+++ grub-0.97/util/grub-install.in 2006-01-13 16:40:37.000000000 -0500
3@@ -101,17 +101,24 @@
4 # Break the device name into the disk part and the partition part.
5 case "$host_os" in
6 linux*)
7- tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
8+ tmp_disk=`echo "$1" | grep -v '/mapper/control$' |
9+ grep -v '/mapper/[[:alnum:]]\+-[[:alnum:]]\+$' | uniq |
10+ sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
11 -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
12 -e 's%\(fd[0-9]*\)$%\1%' \
13 -e 's%/part[0-9]*$%/disc%' \
14- -e 's%\(c[0-7]d[0-9]*\).*$%\1%'`
15- tmp_part=`echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
16+ -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
17+ -e 's%\(/mapper/[[:alpha:]]\+_[[:alpha:]]\+\)[[:digit:]]\+$%\1%'`
18+ tmp_part=`echo "$1" | grep -v '/mapper/control$' |
19+ grep -v '/mapper/[[:alnum:]]\+-[[:alnum:]]\+$' | uniq |
20+ sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
21 -e 's%.*d[0-9]*p%%' \
22 -e 's%.*/fd[0-9]*$%%' \
23 -e 's%.*/floppy/[0-9]*$%%' \
24 -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
25- -e 's%.*c[0-7]d[0-9]*p%%'`
26+ -e 's%.*c[0-7]d[0-9]*p%%' \
27+ -e 's%.*/mapper/[[:alpha:]]\+_[[:alpha:]]\+\([[:digit:]]\+\)$%\1%' |
28+ grep -v '.*/mapper/.*'`
29 ;;
30 gnu*)
31 tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
32@@ -253,6 +260,43 @@
33 return 0
34 }
35
36+# Usage: stat_device file
37+# Find major:minor of a device node.
38+stat_device() {
39+ majmin=`stat -c "%t:%T" "$1" 2>/dev/null`
40+ if test -z "$majmin"; then
41+ echo "Could not find device for $1" 2>&1
42+ exit 1
43+ fi
44+
45+ echo "$majmin"
46+}
47+
48+# Usage: find_mapper_device file
49+# Find a file in /dev/mapper with the same major:minor as the specified node.
50+find_mapper_device() {
51+ if [ -b "$1" ]; then
52+ dev="$1"
53+ else
54+ mntpnt=`echo "$1" | sed 's,/,\\\\/,g'`
55+ dev=`awk '($2 ~ /'$mntpnt'/) { print $1 }' /etc/mtab`
56+ fi
57+ if test -z "$dev"; then
58+ echo "Could not find device for $1" 2>&1
59+ exit 1
60+ fi
61+
62+ majmin=`stat_device $dev`
63+ for x in /dev/mapper/* ; do
64+ devmajmin=`stat_device "$x"`
65+ if [ "$majmin" == "$devmajmin" ]; then
66+ echo "$x"
67+ return 0
68+ fi
69+ done
70+ return 1
71+}
72+
73 # Usage: find_device file
74 # Find block device on which the file resides.
75 find_device () {
76@@ -265,9 +309,14 @@
77 exit 1
78 fi
79
80- tmp_fname=`resolve_symlink $tmp_fname`
81+ ret_fname=`resolve_symlink $tmp_fname`
82+ tmp_fname=`find_mapper_device $ret_fname`
83+ if test -n "$tmp_fname"; then
84+ ret_fname="$tmp_fname"
85+ fi
86
87- echo "$tmp_fname"
88+ echo "$ret_fname"
89+ return 0
90 }
91
92 copy_images() {