1#!/bin/sh
2#
3# Show device mapper dependent / underlying devices.  This is useful for
4# looking up the /dev/sd* devices associated with a dm or multipath device. 
5#
6
7if [ "$1" = "-h" ] ; then
8	echo "Show device mapper dependent (underlying) devices."
9	exit
10fi
11
12dev="$VDEV_PATH"
13
14# If the VDEV path is a symlink, resolve it to a real device
15if [ -L "$dev" ] ; then
16	dev=$(readlink "$dev")
17fi
18
19dev=$(basename "$dev")
20val=""
21if [ -d "/sys/class/block/$dev/slaves" ] ; then
22	# ls -C: output in columns, no newlines
23	val=$(ls -C "/sys/class/block/$dev/slaves")
24
25	# ls -C will print two spaces between files; change to one space.
26	val=$(echo "$val" | sed -r 's/[[:blank:]]+/ /g')
27fi
28
29echo "dm-deps=$val"
30