[arch-releng] [PATCH 2/2] Use globbing and parameter expansion to get the raid slave devices
pyther at pyther.net
pyther at pyther.net
Sun Jan 23 18:06:22 EST 2011
Uses bash globbing and parameter expansion to find all of the slaves for
a raid device. This is a much better method then using ls. Also, by
looking at DEVNAME in the uevent file we provide support for block
device that are not in the root of /dev.
---
src/core/libs/lib-blockdevices-filesystems.sh | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 021f41b..f388d5b 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -943,10 +943,13 @@ mdraid_slave0 ()
# ex: /dev/md0 has slaves: "/dev/sda1 /dev/sdb2 /dev/sdc2"
mdraid_all_slaves ()
{
+ shopt -s nullglob
local slave=
- local slaves=
- for slave in $(ls /sys/class/block/$(basename $1)/slaves/); do
- slaves=$slaves"/dev/"$slave" "
+ local slaves=
+ for slave in /sys/class/block/${1##*/}/slaves/*; do
+ source "$slave/uevent"
+ slaves="$slaves/dev/$DEVNAME "
+ unset DEVNAME
done
echo $slaves
}
--
1.7.3.5
More information about the arch-releng
mailing list