On 01/29/2011 11:33 AM, pyther@pyther.net wrote:
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 | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 021f41b..7731d9f 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -943,10 +943,14 @@ 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
- shopt -u nullglob echo $slaves }
This version of the patch unsets nullglob at the end of the function