PHP 7.4.33
Preview: fc_wwpn_id Size: 1.10 KB
//lib/udev/fc_wwpn_id

#!/bin/bash
#
# fc_wwpn_id
#
# Generates device node names links based on FC WWPN
# Copyright (c) 2016 Hannes Reinecke, SUSE Linux GmbH
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation version 2 of the License.
#

DEVPATH=$1
SCSIPATH=$(cd -P "/sys$DEVPATH/device" || exit; echo "$PWD")

d=$SCSIPATH
[ -d "$d/scsi_disk" ] || exit 0
target_lun=${d##*:}

while [ -n "$d" ] ; do
    d=${d%/*}
    e=${d##*/}
    case "$e" in
	rport*)
	    rport=$e
	    rport_dir="/sys/class/fc_remote_ports/$rport"
	    if [ -d "$rport_dir" ] ; then
		rport_wwpn=$(cat "$rport_dir/port_name")
	    fi
	    ;;
	host*)
	    host=$e
	    host_dir="/sys/class/fc_host/$host"
	    if [ -d "$host_dir" ] ; then
		host_wwpn=$(cat "$host_dir/port_name")
		break;
	    fi
    esac
done

if [ -n "$rport_wwpn" ] || [ -n "$host_wwpn" ] ; then
    echo "FC_TARGET_LUN=$target_lun"
fi

if [ -n "$rport_wwpn" ] ; then
    echo "FC_TARGET_WWPN=$rport_wwpn"
fi

if [ -n "$host_wwpn" ] ; then
    echo "FC_INITIATOR_WWPN=$host_wwpn"
fi

Directory Contents

Dirs: 2 × Files: 12

Name Size Perms Modified Actions
hwdb.d DIR
- drwxr-xr-x 2025-04-24 05:09:27
Edit Download
rules.d DIR
- drwxr-xr-x 2025-06-06 05:07:59
Edit Download
40.73 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download
32.51 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download
20.57 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download
1.10 KB lrwxr-xr-x 2022-10-08 11:49:23
Edit Download
16.43 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download
1.41 KB lrwxr-xr-x 2024-09-24 08:36:00
Edit Download
2.33 KB lrwxr-xr-x 2025-04-22 01:55:39
Edit Download
12.41 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download
1.46 MB lrwxr-xr-x 2019-12-16 19:52:38
Edit Download
16.45 KB lrwxr-xr-x 2022-10-08 11:08:06
Edit Download
53.70 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download
11.99 KB lrwxr-xr-x 2025-04-22 01:58:57
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).