From 9076e2a107c9d843edf78349e0d45b633e8dc2d7 Mon Sep 17 00:00:00 2001 From: Mark Buechler Date: Fri, 18 Nov 2011 20:32:01 +0000 Subject: [PATCH] - Fix -issue_lip as reported by Iain Paton. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3934 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/scstadmin | 45 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index ca84661af..f20fb3f3b 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -4994,44 +4994,43 @@ sub _issueLip { my $attributes = $SCST->targetAttributes($driver, $target); if (!defined($$attributes{'host'})) { - #print "\t-> Driver/target '$driver/$target' has no 'host' attribute, ignoring.\n"; + print "\t-> Driver/target '$driver/$target' has no 'host' attribute, ignoring.\n"; return FALSE; } my $dir = new IO::Handle; - if (!(opendir $dir, $$attributes{'host'}->{'value'}.'/device/fc_host')) { - #print "\t-> Driver/target is not a fibre channel target, ignoring.\n"; + my $host = $$attributes{'host'}->{'value'}; + my $ldir = $SCST->SCST_TARGETS_DIR."/$driver/$target/host/device/fc_host:$host"; + + if (!(opendir $dir, $ldir)) { + print "\t-> Driver/target is not a fibre channel target, ignoring.\n"; return FALSE; } - foreach my $host (readdir($dir)) { - next if (($host eq '.') || ($host eq '..')); + my $lip = $ldir.'/issue_lip'; - my $lip = $$attributes{'host'}->{'value'}.'/device/fc_host/'.$host.'/issue_lip'; + if (-w $lip) { + my $io = new IO::File $lip, O_WRONLY; - if (-w $lip) { - my $io = new IO::File $lip, O_WRONLY; + print "WARNING: Failed to open file '$lip' for writing.\n" + if (!$io); - print "WARNING: Failed to open file '$lip' for writing.\n" - if (!$io); + print "\t-> Issuing LIP on fibre channel driver/target '$driver/$target' ($host): "; - print "\t-> Issuing LIP on fibre channel driver/target '$driver/$target' ($host): "; + my $bytes = syswrite($io, 1, 1); - my $bytes = syswrite($io, 1, 1); + print "done.\n"; - print "done.\n"; - - if (!$bytes) { - print "WARNING: Failed to issue LIP on driver/target '$driver/$target'.\n"; - $rc = TRUE; - } - - close $io; - } else { - #print "Fibre channel driver/target '$driver/$target' lacks the ability to ". - # "issue LIPs, ignoring.\n"; + if (!$bytes) { + print "WARNING: Failed to issue LIP on driver/target '$driver/$target'.\n"; + $rc = TRUE; } + + close $io; + } else { + print "Fibre channel driver/target '$driver/$target' lacks the ability to ". + "issue LIPs, ignoring.\n"; } close $dir;