File: ls-vscsi

package info (click to toggle)
powerpc-ibm-utils 1.2.22-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,684 kB
  • ctags: 1,134
  • sloc: ansic: 13,342; sh: 3,823; perl: 935; makefile: 121
file content (73 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /bin/bash

# Copyright (c) 2010 International Business Machines
# Common Public License Version 1.0 (see COPYRIGHT)
#
# Author Brian King <brking@linux.vnet.ibm.com>
#
# ls-vscsi - This utility provides the HMC or IVM with name information for
# 	     virtual scsi devices
#

LSVSCSI="ls-vscsi"
VERSION="0.1"
CAT="/bin/cat"
LS="/bin/ls"
SED="/bin/sed"
PSERIES_PLATFORM=$(dirname $0)/pseries_platform

usage()
{
    echo "Usage: $LSVSCSI"
    echo "Provide information on Virtual devices"
	echo ""
	echo "Optional arguments."
	echo "  -V  Display version information and exit"
	echo "  -h  Display this help information and exit"
	echo ""
}

show_version()
{
    echo "$LSVSCSI: Version $VERSION"
    echo "Written by: Brian King <brking@linux.vnet.ibm.com>"
}

. $PSERIES_PLATFORM
if [[ $platform != $PLATFORM_PSERIES_LPAR ]]; then
     echo "$LSVSCSI: is not supported on the $platform_name platform"
     exit 1
fi

while getopts ":Vh" flag ; do
    case "$flag" in

        V) show_version
                        exit 0 ;;

        h)              usage
                        exit 0 ;;
        \?)             usage
                        exit 1 ;;
    esac
done


# Look at every ibmvscsi (Virtual SCSI) device
for dev in $($LS -d /proc/device-tree/vdevice/v-scsi* 2> /dev/null) ; do
    # pull the physical location
    physloc=$($CAT $dev/ibm,loc-code)

    # find the slot so it can be used in sysfs
    slot=$(echo $dev | $SED -e "s/\/proc\/device-tree\/vdevice\/v-scsi@//")

    # there is only one host per device, assign it to the path's name
    for host in $($LS -d /sys/devices/vio/$slot/host*) ; do
	name=$(echo $host | $SED -e "s/.*\///")
	echo "$name $physloc"
    done
done

exit 0

# end