summaryrefslogtreecommitdiff
path: root/hook-functions
diff options
context:
space:
mode:
authorMichael Prokop <mika@debian.org>2010-06-08 03:02:08 +0200
committerMichael Prokop <mika@debian.org>2010-06-08 03:50:36 +0200
commitb1c242ffc5762fea6c15fe880e352008a5c34c43 (patch)
treefd38e6db1d33076ff18788152e122ce231a789d3 /hook-functions
parent86223e387feb41c8dd15231fc87ce23c2b71c310 (diff)
downloadinitramfs-tools-b1c242ffc5762fea6c15fe880e352008a5c34c43.tar.gz
initramfs-tools-b1c242ffc5762fea6c15fe880e352008a5c34c43.zip
hook-functions: make device name handling for /proc/mdstat more flexible for MODULES=dep
We can't assume it's always [hs]dX# in /proc/mdstat. It can be e.g. also [hs]dX (raw device) or dm-## as well. So don't statically calculate the string based on string length but instead try to be as smart as possible. Also add support for handling additional arguments in the /proc/mdstat output like "(auto-read-only)". This affects MODULES=dep only. [Closes: #584520] + [Closes: #514756] Reported-by: Simon Richter <Simon.Richter@hogyros.de> Reported-by: Martin Michlmayr <tbm@cyrius.com> Signed-off-by: Michael Prokop <mika@debian.org>
Diffstat (limited to 'hook-functions')
-rw-r--r--hook-functions30
1 files changed, 23 insertions, 7 deletions
diff --git a/hook-functions b/hook-functions
index 86dc905..8bebdea 100644
--- a/hook-functions
+++ b/hook-functions
@@ -259,8 +259,9 @@ dep_add_modules()
done
# lvm on md or luks on md
if [ "${block#md}" != "${block}" ]; then
- block=$(awk "/^${block}/{print substr(\$5, 1, 4); exit}" \
- /proc/mdstat)
+ block=$(grep "^${block}" /proc/mdstat | \
+ awk "{gsub(/^${block} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
+ block="${block%%\[*}"
fi
# luks or lvm on cciss or ida
if [ "${block#cciss}" != "${block}" ] \
@@ -272,13 +273,28 @@ dep_add_modules()
# md root new naming scheme /dev/md/X
elif [ "${root#/dev/md/}" != "${root}" ]; then
root=${root#/dev/md/}
- block=$(awk "/^md${root}/{print substr(\$5, 1, 3); exit}" \
- /proc/mdstat)
+ block=$(grep "^md${root}" /proc/mdstat | \
+ awk "{gsub(/^md${root} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
+ block="${block%%\[*}"
+ # drop the partition number only for sdX and hdX devices
+ # and keep it for other devices like loop#, dm-# devices
+ case "$block" in
+ sd*) block=${block%%[0-9]*};;
+ hd*) block=${block%%[0-9]*};;
+ esac
# md root /dev/mdX
elif [ "${root#/dev/md}" != "${root}" ]; then
- root=${root#/dev/}
- block=$(awk "/^${root}/{print substr(\$5, 1, 3); exit}" \
- /proc/mdstat)
+ root=${root#/dev/md}
+ block=$(grep "^md${root}" /proc/mdstat | \
+ awk "{gsub(/^md${root} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
+ block="${block%%\[*}"
+ # drop the partition number only for sdX and hdX devices
+ # and keep it for other devices like loop#, dm-# devices
+ case "$block" in
+ sd*) block=${block%%[0-9]*};;
+ hd*) block=${block%%[0-9]*};;
+ esac
+
# cciss device
elif [ "${root#/dev/cciss/}" != "${root}" ]; then
block=${root#/dev/cciss/*}