3
# Copyright 2010 United States Government as represented by the
4
# Administrator of the National Aeronautics and Space Administration.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
# NOTE(vish): This script helps udev create common names for discovered iscsi
20
# volumes under /dev/iscsi. To use it, create /dev/iscsi and add
21
# a file to /etc/udev/rules.d like so:
23
# echo 'KERNEL=="sd*", BUS=="scsi", PROGRAM="/path/to/iscsidev.sh
24
# %b",SYMLINK+="iscsi/%c%n"' > /etc/udev/rules.d/55-openiscsi.rules
29
if [ ! -e /sys/class/iscsi_host ]; then
33
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/session*/targetname"
35
target_name=$(cat ${file})
37
if [ -z "${target_name}" ]; then
41
echo "${target_name##*:}"