diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm index 164eda796..dc2748c40 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm @@ -414,7 +414,7 @@ sub new { sub scstVersion { my $self = shift; - my $attributes = $self->scstAttributes(); + my ($attributes, $errorString) = $self->scstAttributes(); return undef if (!defined($attributes)); return $$attributes{'version'}->{'value'}; @@ -427,8 +427,7 @@ sub scstAttributes { my $pHandle = new IO::Handle; my $_path = SCST_ROOT_DIR(); if (!(opendir $pHandle, $_path)) { - $self->{'err_string'} = "scstAttributes(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "scstAttributes(): Unable to read directory '$_path': $!"); } foreach my $attribute (readdir($pHandle)) { @@ -454,9 +453,8 @@ sub scstAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "scsiAttributes(): Unable to read ". - "scst attribute '$attribute': $!"; - return undef; + return (undef, "scsiAttributes(): Unable to read ". + "scst attribute '$attribute': $!"); } my $value = <$io>; @@ -510,7 +508,7 @@ sub scstAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setAttrFailed { @@ -561,11 +559,11 @@ sub drivers { } close $dHandle; } else { - $self->{'err_string'} = "drivers(): Unable to read directory '$_path': $!"; + return (undef, "drivers(): Unable to read directory '$_path': $!"); } } - return \@_drivers; + return (\@_drivers, undef); } @@ -573,7 +571,7 @@ sub targets { my $self = shift; my $driver = shift; - return undef if (!defined($driver)); + return (undef, "Too few arguments") if (!defined($driver)); my $tHandle = new IO::Handle; my $_path = make_path(SCST_TARGETS_DIR(), $driver); @@ -591,15 +589,16 @@ sub targets { } close $tHandle; @targets = sort(@targets); - return \@targets; + return (\@targets, undef); } + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "targets(): Driver '$driver' is not available"; + $errorString = "targets(): Driver '$driver' is not available"; } else { - $self->{'err_string'} = "targets(): Unable to read directory '$_path': $!"; + $errorString = "targets(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } sub groups { @@ -607,7 +606,7 @@ sub groups { my $driver = shift; my $target = shift; - return undef if (!defined($driver) || !defined($target)); + return (undef, "Too few arguments") if (!defined($driver) || !defined($target)); my $gHandle = new IO::Handle; my $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, @@ -625,17 +624,18 @@ sub groups { } } close $gHandle; - return \@groups; + return (\@groups, undef); } + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "groups(): Driver '$driver' is not available"; + $errorString = "groups(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "groups(): Target '$target' is not available"; + $errorString = "groups(): Target '$target' is not available"; } else { - $self->{'err_string'} = "groups(): Unable to read directory '$_path': $!"; + $errorString = "groups(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } sub initiators { @@ -645,23 +645,24 @@ sub initiators { my $group = shift; my @initiators; - return undef if (!defined($driver) || !defined($target) || + return (undef, "Too few arguments") if (!defined($driver) || !defined($target) || !defined($group)); my $iHandle = new IO::Handle; my $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS, $group, SCST_INITIATORS); if (!(opendir $iHandle, $_path)) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "initiators(): Driver '$driver' is not available"; + $errorString = "initiators(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "initiators(): Target '$target' is not available"; + $errorString = "initiators(): Target '$target' is not available"; } elsif ($self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "initiators(): Group '$group' does not exist"; + $errorString = "initiators(): Group '$group' does not exist"; } else { - $self->{'err_string'} = "initiators(): Unable to read directory '$_path': $!"; + $errorString = "initiators(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $initiator (readdir($iHandle)) { @@ -673,7 +674,7 @@ sub initiators { close $iHandle; - return \@initiators; + return (\@initiators, undef); } sub luns { @@ -682,7 +683,7 @@ sub luns { my $target = shift; my $group = shift; - return undef if (!defined($driver) || !defined($target)); + return (undef, "Too few arguments") if (!defined($driver) || !defined($target)); my $_path; @@ -697,16 +698,17 @@ sub luns { my $lHandle = new IO::Handle; if (!(opendir $lHandle, $_path)) { + my $errorString; if (defined($group) && $self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "initiators(): Group '$group' does not exist"; + $errorString = "initiators(): Group '$group' does not exist"; } elsif ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "luns(): Driver '$driver' is not available"; + $errorString = "luns(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "luns(): Target '$target' is not available"; + $errorString = "luns(): Target '$target' is not available"; } else { - $self->{'err_string'} = "luns(): Unable to read directory '$_path': $!"; + $errorString = "luns(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } my %luns; @@ -720,8 +722,7 @@ sub luns { my $_lHandle = new IO::Handle; if (!(opendir $_lHandle, $lPath)) { - $self->{'err_string'} = "luns(): Unable to read directory '$lPath': $!"; - return undef; + return (undef, "luns(): Unable to read directory '$lPath': $!"); } foreach my $attribute (readdir($_lHandle)) { @@ -740,7 +741,7 @@ sub luns { close $lHandle; - return \%luns; + return (\%luns, undef); } sub aluaAttributes { @@ -750,8 +751,7 @@ sub aluaAttributes { my $pHandle = new IO::Handle; my $_path = SCST_DEV_GROUP_DIR(); if (!(opendir $pHandle, $_path)) { - $self->{'err_string'} = "deviceGroupsAttributes(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "deviceGroupsAttributes(): Unable to read directory '$_path': $!"); } foreach my $attribute (readdir($pHandle)) { @@ -768,8 +768,7 @@ sub aluaAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "deviceGroupsAttributes(): Unable to read device attribute '$attribute': $!"; - return undef; + return (undef, "deviceGroupsAttributes(): Unable to read device attribute '$attribute': $!"); } my $value = <$io>; @@ -795,7 +794,7 @@ sub aluaAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub deviceGroups { @@ -805,8 +804,7 @@ sub deviceGroups { my $dHandle = new IO::Handle; my $_path = SCST_DEV_GROUP_DIR(); if (!(opendir $dHandle, $_path)) { - $self->{'err_string'} = "deviceGroups(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "deviceGroups(): Unable to read directory '$_path': $!"); } foreach my $group (readdir($dHandle)) { @@ -819,7 +817,7 @@ sub deviceGroups { close $dHandle; - return \@groups; + return (\@groups, undef); } sub deviceGroupDevices { @@ -827,17 +825,18 @@ sub deviceGroupDevices { my $group = shift; my @devices; - return undef if (!defined($group)); + return (undef, "Too few arguments") if (!defined($group)); my $dHandle = new IO::Handle; my $_path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_DEVICES); if (!(opendir $dHandle, $_path)) { + my $errorString; if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "deviceGroupDevices(): Device group '$group' does not exist"; + $errorString = "deviceGroupDevices(): Device group '$group' does not exist"; } else { - $self->{'err_string'} = "deviceGroupDevices(): Unable to read directory '$_path': $!"; + $errorString = "deviceGroupDevices(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $device (readdir($dHandle)) { @@ -850,7 +849,7 @@ sub deviceGroupDevices { close $dHandle; - return \@devices; + return (\@devices, undef); } sub targetGroups { @@ -858,17 +857,18 @@ sub targetGroups { my $group = shift; my @tgroups; - return undef if (!defined($group)); + return (undef, "Too few arguments") if (!defined($group)); my $dHandle = new IO::Handle; my $_path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS); if (!(opendir $dHandle, $_path)) { + my $errorString; if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "targetGroups(): Device group '$group' does not exist"; + $errorString = "targetGroups(): Device group '$group' does not exist"; } else { - $self->{'err_string'} = "targetGroups(): Unable to read directory '$_path': $!"; + $errorString = "targetGroups(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $tgroup (readdir($dHandle)) { @@ -881,7 +881,7 @@ sub targetGroups { close $dHandle; - return \@tgroups; + return (\@tgroups, undef); } sub targetGroupTargets { @@ -890,19 +890,20 @@ sub targetGroupTargets { my $tgroup = shift; my @targets; - return undef if (!defined($group) || !defined($tgroup)); + return (undef, "Too few arguments") if (!defined($group) || !defined($tgroup)); my $dHandle = new IO::Handle; my $_path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $tgroup); if (!(opendir $dHandle, $_path)) { + my $errorString; if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "targetGroupTargets(): Device group '$group' does not exist"; + $errorString = "targetGroupTargets(): Device group '$group' does not exist"; } elsif ($self->targetGroupExists($group, $tgroup) != TRUE) { - $self->{'err_string'} = "targetGroupTargets(): Target group '$tgroup' does not exist"; + $errorString = "targetGroupTargets(): Target group '$tgroup' does not exist"; } else { - $self->{'err_string'} = "targetGroupTargets(): Unable to read directory '$_path': $!"; + $errorString = "targetGroupTargets(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $tgt (readdir($dHandle)) { @@ -917,7 +918,7 @@ sub targetGroupTargets { @targets = sort(@targets); - return \@targets; + return (\@targets, undef); } sub driverExists { @@ -926,7 +927,7 @@ sub driverExists { return FALSE if (!defined($driver)); - my $drivers = $self->drivers(); + my ($drivers, $errorString) = $self->drivers(); return SCST_C_FATAL_ERROR if (!defined($drivers)); @@ -943,7 +944,7 @@ sub driverDynamicAttributes { my %attributes; my $available; - return undef if (!defined($driver)); + return (undef, "Too few arguments") if (!defined($driver)); if (new_sysfs_interface()) { my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver, @@ -960,14 +961,15 @@ sub driverDynamicAttributes { SCST_MGMT_IO), O_RDONLY; if (!$io) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "driverDynamicAttributes(): Driver '$driver' ". + $errorString = "driverDynamicAttributes(): Driver '$driver' ". "is not available"; } else { - $self->{'err_string'} = "driverDynamicAttributes(): Unable to open mgmt ". + $errorString = "driverDynamicAttributes(): Unable to open mgmt ". "interface for driver '$driver': $!"; } - return undef; + return (undef, $errorString); } while (my $in = <$io>) { @@ -987,7 +989,7 @@ sub driverDynamicAttributes { } } - return \%attributes; + return (\%attributes, undef); } sub checkDriverDynamicAttributes { @@ -995,7 +997,7 @@ sub checkDriverDynamicAttributes { my $driver = shift; my $check = shift; - my $available = $self->driverDynamicAttributes($driver); + my ($available, $errorString) = $self->driverDynamicAttributes($driver); if (!defined($available)) { my $rc = $self->driverExists($driver); @@ -1143,10 +1145,10 @@ sub targetType { my $driver = shift; my $target = shift; - return undef if (!defined($driver) || !defined($target)); + return (undef, "Too few arguments") if (!defined($driver) || !defined($target)); if ($self->driverIsVirtualCapable($driver)) { - my $attribs = $self->targetAttributes($driver, $target); + my ($attribs, $errorString) = $self->targetAttributes($driver, $target); if (defined($$attribs{'hw_target'}) && ($$attribs{'hw_target'}->{'value'} == TRUE)) { @@ -1223,7 +1225,7 @@ sub targetDynamicAttributes { my %attributes; my $available; - return undef if (!defined($driver)); + return (undef, "Too few arguments") if (!defined($driver)); if (new_sysfs_interface()) { my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver, @@ -1240,14 +1242,15 @@ sub targetDynamicAttributes { SCST_MGMT_IO), O_RDONLY; if (!$io) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "targetDynamicAttributes(): Driver '$driver' ". + $errorString = "targetDynamicAttributes(): Driver '$driver' ". "is not available"; } else { - $self->{'err_string'} = "targetDynamicAttributes(): Unable to open mgmt ". + $errorString = "targetDynamicAttributes(): Unable to open mgmt ". "interface for driver '$driver': $!"; } - return undef; + return (undef, $errorString); } while (my $in = <$io>) { @@ -1267,7 +1270,7 @@ sub targetDynamicAttributes { } } - return \%attributes; + return (\%attributes, undef); } sub checkTargetDynamicAttributes { @@ -1275,7 +1278,7 @@ sub checkTargetDynamicAttributes { my $driver = shift; my $check = shift; - my $available = $self->targetDynamicAttributes($driver); + my ($available, $errorString) = $self->targetDynamicAttributes($driver); if (!defined($available)) { my $rc = $self->driverExists($driver); @@ -1409,7 +1412,7 @@ sub removeVirtualTarget { # case for e.g. the 'scst_local' driver. $self->enableTarget($driver, $target, FALSE); - my $sessions = $self->sessions($driver, $target); + my ($sessions, $errorString) = $self->sessions($driver, $target); my %can_close; foreach my $session (keys %{$sessions}) { @@ -1424,7 +1427,7 @@ sub removeVirtualTarget { my $has_sessions = 1; my $now = time(); while ($has_sessions && (($now + $TIMEOUT) > time())) { - $sessions = $self->sessions($driver, $target); + ($sessions, $errorString) = $self->sessions($driver, $target); foreach my $session (keys %can_close) { if (!defined($$sessions{$session})) { @@ -1481,7 +1484,7 @@ sub groupExists { return FALSE if (!defined($driver) || !defined($target) || !defined($group)); - my $groups = $self->groups($driver, $target); + my ($groups, $errorString) = $self->groups($driver, $target); if (!defined($groups)) { my $rc = $self->targetExists($driver, $target); @@ -1508,7 +1511,7 @@ sub initiatorExists { return FALSE if (!defined($driver) || !defined($target) || !defined($group) || !defined($initiator)); - my $initiators = $self->initiators($driver, $target, $group); + my ($initiators, $errorString) = $self->initiators($driver, $target, $group); if (!defined($initiators)) { my $rc = $self->groupExists($driver, $target, $group); @@ -1535,7 +1538,7 @@ sub lunExists { return FALSE if (!defined($driver) || !defined($target) || !defined($lun)); - my $luns = $self->luns($driver, $target, $group); + my ($luns, $errorString) = $self->luns($driver, $target, $group); if (!defined($luns)) { my $rc = $self->driverExists($driver); @@ -1763,10 +1766,10 @@ sub addDeviceGroupDevice { return $rc if ($rc > 1); # Check all device groups for this device - my $dgroups = $self->deviceGroups(); + my ($dgroups, $errorString) = $self->deviceGroups(); foreach my $dgroup (@{$dgroups}) { - my $devs = $self->deviceGroupDevices($dgroup); + my ($devs, $errorString) = $self->deviceGroupDevices($dgroup); foreach my $dev (@{$devs}) { return SCST_C_DGRP_DEVICE_OTHER if ($dev eq $device); @@ -2411,7 +2414,7 @@ sub replaceLun { return SCST_C_LUN_BAD_ATTRIBUTES if ($rc == TRUE); return $rc if ($rc > 1); - my $luns = $self->luns($driver, $target, $group); + my ($luns, $errorString) = $self->luns($driver, $target, $group); return SCST_C_LUN_DEV_EXISTS if ($$luns{$lun} eq $device); @@ -2543,8 +2546,7 @@ sub devices { my $_path = new_sysfs_interface() || !defined($handler) ? SCST_DEVICES_DIR() : make_path(SCST_HANDLERS_DIR(), $handler); if (!(opendir $dHandle, $_path)) { - $self->{'err_string'} = "devices(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "devices(): Unable to read directory '$_path': $!"); } foreach my $device (readdir($dHandle)) { @@ -2560,7 +2562,7 @@ sub devices { close $dHandle; - return \@devices; + return (\@devices, undef); } sub deviceOpen { @@ -2569,7 +2571,7 @@ sub deviceOpen { return FALSE if (!defined($device)); - my $devices = $self->devices(); + my ($devices, $errorString) = $self->devices(); return SCST_C_FATAL_ERROR if (!defined($devices)); @@ -2588,15 +2590,16 @@ sub deviceAttributes { my $pHandle = new IO::Handle; my $_path = make_path(SCST_DEVICES_DIR(), $device); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->deviceOpen($device) != TRUE) { - $self->{'err_string'} = "deviceAttributes(): Device '$device' is not open"; + $errorString = "deviceAttributes(): Device '$device' is not open"; } else { - $self->{'err_string'} = "deviceAttributes(): Unable to read directory '$_path': $!"; + $errorString = "deviceAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } - my $dca = $self->deviceCreateAttributes($self->deviceHandler($device)); + my ($dca, $errorString) = $self->deviceCreateAttributes($self->deviceHandler($device)); foreach my $attribute (readdir($pHandle)) { next if ($attribute eq '.' || $attribute eq '..' || @@ -2660,9 +2663,8 @@ sub deviceAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "deviceAttributes(): Unable to read ". - "device attribute '$attribute': $!"; - return undef; + return (undef, "deviceAttributes(): Unable to read ". + "device attribute '$attribute': $!"); } my ($value, $is_key) = split("\n", _sysread($io) , 2); @@ -2703,7 +2705,7 @@ sub deviceAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub driverAttributes { @@ -2714,12 +2716,13 @@ sub driverAttributes { my $pHandle = new IO::Handle; my $_path = make_path(SCST_TARGETS_DIR(), $driver); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "driverAttributes(): Driver '$driver' is not available"; + $errorString = "driverAttributes(): Driver '$driver' is not available"; } else { - $self->{'err_string'} = "driverAttributes(): Unable to read directory '$_path': $!"; + $errorString = "driverAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -2745,9 +2748,8 @@ sub driverAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "driverAttributes(): Unable to read ". - "driver attribute '$attribute': $!"; - return undef; + return (undef, "driverAttributes(): Unable to read ". + "driver attribute '$attribute': $!"); } my $value = <$io>; @@ -2803,7 +2805,7 @@ sub driverAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setDriverAttribute { @@ -2842,19 +2844,20 @@ sub targetAttributes { my $target = shift; my %attributes; - return undef if (!defined($driver) || !defined($target)); + return (undef, "Too few arguments") if (!defined($driver) || !defined($target)); my $pHandle = new IO::Handle; my $_path = make_path(SCST_TARGETS_DIR(), $driver, $target); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "targetAttributes(): Driver '$driver' is not available"; + $errorString = "targetAttributes(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "targetAttributes(): Target '$target' is not available"; + $errorString = "targetAttributes(): Target '$target' is not available"; } else { - $self->{'err_string'} = "targetAttributes(): Unable to read directory '$_path': $!"; + $errorString = "targetAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -2874,8 +2877,7 @@ sub targetAttributes { my $_session_path = make_path($_path, $attribute); my $pSessHandle = new IO::Handle; if (!(opendir $pSessHandle, $_session_path)) { - $self->{'err_string'} = "targetAttributes(): Unable to read directory '$_session_path': $!"; - return undef; + return (undef, "targetAttributes(): Unable to read directory '$_session_path': $!"); } my $key = 0; foreach my $e (readdir($pSessHandle)) { @@ -2902,9 +2904,8 @@ sub targetAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "targetAttributes(): Unable to read ". - "target attribute '$attribute': $!"; - return undef; + return (undef, "targetAttributes(): Unable to read ". + "target attribute '$attribute': $!"); } my $value = <$io>; @@ -2938,7 +2939,7 @@ sub targetAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setTargetAttribute { @@ -2999,16 +3000,17 @@ sub groupAttributes { my $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS, $group); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "groupAttributes(): Driver '$driver' is not available"; + $errorString = "groupAttributes(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "groupAttributes(): Target '$target' is not available"; + $errorString = "groupAttributes(): Target '$target' is not available"; } elsif ($self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "groupAttributes(): Group '$group' does not exist"; + $errorString = "groupAttributes(): Group '$group' does not exist"; } else { - $self->{'err_string'} = "groupAttributes(): Unable to read directory '$_path': $!"; + $errorString = "groupAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -3036,9 +3038,8 @@ sub groupAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "groupAttributes(): Unable to read ". - "group attribute '$attribute': $!"; - return undef; + return (undef, "groupAttributes(): Unable to read ". + "group attribute '$attribute': $!"); } my $value = <$io>; @@ -3072,7 +3073,7 @@ sub groupAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setGroupAttribute { @@ -3131,6 +3132,7 @@ sub lunAttributes { my $target = shift; my $lun = shift; my $group = shift; + my $errorString; my %attributes; my ($_path, $luncrattr); @@ -3138,28 +3140,28 @@ sub lunAttributes { if (defined($group)) { $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS, $group, SCST_LUNS, $lun); - $luncrattr = $self->lunCreateAttributes($driver, $target, - $group); + ($luncrattr, $errorString) = + $self->lunCreateAttributes($driver, $target, $group); } else { $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_LUNS, $lun); - $luncrattr = $self->lunCreateAttributes($driver, $target); + ($luncrattr, $errorString) = $self->lunCreateAttributes($driver, $target); } my $pHandle = new IO::Handle; if (!(opendir $pHandle, $_path)) { if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "lunAttributes(): Driver '$driver' is not available"; + $errorString = "lunAttributes(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "lunAttributes(): Target '$target' is not available"; + $errorString = "lunAttributes(): Target '$target' is not available"; } elsif (defined($group) && $self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "lunAttributes(): Group '$group' does not exist"; + $errorString = "lunAttributes(): Group '$group' does not exist"; } elsif ($self->lunExists($driver, $target, $lun, $group) != TRUE) { - $self->{'err_string'} = "lunAttributes(): LUN '$lun' does not exist"; + $errorString = "lunAttributes(): LUN '$lun' does not exist"; } else { - $self->{'err_string'} = "lunAttributes(): Unable to read directory '$_path': $!"; + $errorString = "lunAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -3191,9 +3193,8 @@ sub lunAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "lunAttributes(): Unable to read ". - "lun attribute '$attribute': $!"; - return undef; + return (undef, "lunAttributes(): Unable to read ". + "lun attribute '$attribute': $!"); } my $value = <$io>; @@ -3229,7 +3230,7 @@ sub lunAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setLunAttribute { @@ -3287,7 +3288,7 @@ sub setLunAttribute { if (!$rc); return $rc if ($rc > 1); - my $attributes = $self->lunAttributes($driver, $target, $lun, $group); + my ($attributes, $errorString) = $self->lunAttributes($driver, $target, $lun, $group); return SCST_C_LUN_BAD_ATTRIBUTES if (!defined($$attributes{$attribute})); return SCST_C_LUN_ATTRIBUTE_STATIC if ($$attributes{$attribute}->{'static'}); @@ -3307,18 +3308,19 @@ sub initiatorAttributes { my $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS, $group, SCST_INITIATORS, $initiator); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "initiatorAttributes(): Driver '$driver' is not available"; + $errorString = "initiatorAttributes(): Driver '$driver' is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "initiatorAttributes(): Target '$target' is not available"; + $errorString = "initiatorAttributes(): Target '$target' is not available"; } elsif ($self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "initiatorAttributes(): Group '$group' does not exist"; + $errorString = "initiatorAttributes(): Group '$group' does not exist"; } elsif ($self->initiatorExists($driver, $target, $group, $initiator) != TRUE) { - $self->{'err_string'} = "initiatorAttributes(): Initiator '$initiator' does not exist"; + $errorString = "initiatorAttributes(): Initiator '$initiator' does not exist"; } else { - $self->{'err_string'} = "initiatorAttributes(): Unable to read directory '$_path': $!"; + $errorString = "initiatorAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -3345,9 +3347,8 @@ sub initiatorAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "initiatorAttributes(): Unable to read ". - "initiator attribute '$attribute': $!"; - return undef; + return (undef, "initiatorAttributes(): Unable to read ". + "initiator attribute '$attribute': $!"); } my $value = <$io>; @@ -3381,7 +3382,7 @@ sub initiatorAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setInitiatorAttribute { @@ -3437,12 +3438,13 @@ sub deviceGroupAttributes { my $pHandle = new IO::Handle; my $_path = make_path(SCST_DEV_GROUP_DIR(), $group); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "deviceGroupAttributes(): Device group '$group' does not exist"; + $errorString = "deviceGroupAttributes(): Device group '$group' does not exist"; } else { - $self->{'err_string'} = "deviceGroupAttributes(): Unable to read directory '$_path': $!"; + $errorString = "deviceGroupAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -3467,9 +3469,8 @@ sub deviceGroupAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "deviceGroupAttributes(): Unable to read ". - "device group attribute '$attribute': $!"; - return undef; + return (undef, "deviceGroupAttributes(): Unable to read ". + "device group attribute '$attribute': $!"); } my $value = <$io>; @@ -3503,7 +3504,7 @@ sub deviceGroupAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub targetGroupAttributes { @@ -3515,14 +3516,15 @@ sub targetGroupAttributes { my $pHandle = new IO::Handle; my $_path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $tgroup); if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "targetGroupAttributes(): Device group '$group' does not exist"; + $errorString = "targetGroupAttributes(): Device group '$group' does not exist"; } elsif ($self->targetGroupExists($group, $tgroup) != TRUE) { - $self->{'err_string'} = "targetGroupAttributes(): Target Group '$tgroup' does not exist"; + $errorString = "targetGroupAttributes(): Target Group '$tgroup' does not exist"; } else { - $self->{'err_string'} = "targetGroupAttributes(): Unable to read directory '$_path': $!"; + $errorString = "targetGroupAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -3547,9 +3549,8 @@ sub targetGroupAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "targetGroupAttributes(): Unable to read ". - "target group attribute '$attribute': $!"; - return undef; + return (undef, "targetGroupAttributes(): Unable to read ". + "target group attribute '$attribute': $!"); } my $value = <$io>; @@ -3583,7 +3584,7 @@ sub targetGroupAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub targetGroupTargetAttributes { @@ -3597,20 +3598,21 @@ sub targetGroupTargetAttributes { my $pHandle = new IO::Handle; my $_path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $tgroup, $tgt); if (-l $_path && !$local_tgt) { - return \%attributes; + return (\%attributes, undef); } if (!(opendir $pHandle, $_path)) { + my $errorString; if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "targetGroupTargetAttributes(): Device group '$group' does not exist"; + $errorString = "targetGroupTargetAttributes(): Device group '$group' does not exist"; } elsif ($self->targetGroupExists($group, $tgroup) != TRUE) { - $self->{'err_string'} = "targetGroupTargetAttributes(): Target Group '$tgroup' does not exist"; + $errorString = "targetGroupTargetAttributes(): Target Group '$tgroup' does not exist"; } elsif ($self->targetGroupTargetExists($group, $tgroup, $tgt) != TRUE) { - $self->{'err_string'} = "targetGroupTargetAttributes(): Target '$tgt' does not exist"; + $errorString = "targetGroupTargetAttributes(): Target '$tgt' does not exist"; } else { - $self->{'err_string'} = "targetGroupTargetAttributes(): Unable to read directory '$_path': $!"; + $errorString = "targetGroupTargetAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($pHandle)) { @@ -3636,9 +3638,8 @@ sub targetGroupTargetAttributes { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "targetGroupTargetAttributes(): Unable to read ". - "target group target attribute '$attribute': $!"; - return undef; + return (undef, "targetGroupTargetAttributes(): Unable to read ". + "target group target attribute '$attribute': $!"); } my $value = <$io>; @@ -3672,7 +3673,7 @@ sub targetGroupTargetAttributes { close $pHandle; - return \%attributes; + return (\%attributes, undef); } sub setAluaAttribute { @@ -3815,8 +3816,7 @@ sub handlers { my $hHandle = new IO::Handle; my $_path = SCST_HANDLERS_DIR(); if (!(opendir $hHandle, $_path)) { - $self->{'err_string'} = "handlers(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "handlers(): Unable to read directory '$_path': $!"); } foreach my $handler (readdir($hHandle)) { @@ -3829,7 +3829,7 @@ sub handlers { close $hHandle; - return \@handlers; + return (\@handlers, undef); } sub handlerExists { @@ -3838,7 +3838,7 @@ sub handlerExists { return FALSE if (!defined($handler)); - my $handlers = $self->handlers(); + my ($handlers, $errorString) = $self->handlers(); return SCST_C_FATAL_ERROR if (!defined($handlers)); @@ -3883,17 +3883,19 @@ sub handlerAttributes { my $handler = shift; my %attributes; - $attributes{'devices'}->{'value'} = devices($self, $handler); + my ($a, $errorString) = devices($self, $handler); + $attributes{'devices'}->{'value'} = $a; my $hHandle = new IO::Handle; my $_path = make_path(SCST_HANDLERS_DIR(), $handler); if (!(opendir $hHandle, $_path)) { + my $errorString; if ($self->handlerExists($handler) != TRUE) { - $self->{'err_string'} = "handlerAttributes(): Handler '$handler' is not available"; + $errorString = "handlerAttributes(): Handler '$handler' is not available"; } else { - $self->{'err_string'} = "handlerAttributes(): Unable to read directory '$_path': $!"; + $errorString = "handlerAttributes(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $attribute (readdir($hHandle)) { @@ -3915,9 +3917,8 @@ sub handlerAttributes { my $io = new IO::File $path, O_RDONLY; if (!$io) { - $self->{'err_string'} = "handlerAttributes(): Unable to read handler attribute ". - "'$attribute': $!"; - return undef; + return (undef, "handlerAttributes(): Unable to read handler attribute ". + "'$attribute': $!"); } my $value = <$io>; @@ -3982,14 +3983,14 @@ sub handlerAttributes { $attributes{'devices'}->{'static'} = TRUE; - return \%attributes; + return (\%attributes, undef); } sub deviceExists { my $self = shift; my $device = shift; - my $handlers = $self->handlers(); + my ($handlers, $errorString) = $self->handlers(); return SCST_C_FATAL_ERROR if (!defined($handlers)); @@ -4005,7 +4006,7 @@ sub handlerDeviceExists { my $handler = shift; my $device = shift; - my $devices = $self->devicesByHandler($handler); + my ($devices, $errorString) = $self->devicesByHandler($handler); if (!defined($devices)) { my $rc = $self->handlerExists($handler); @@ -4026,16 +4027,19 @@ sub devicesByHandler { my $self = shift; my $handler = shift; - my $attributes = $self->handlerAttributes($handler); + my ($attributes, $errorString) = $self->handlerAttributes($handler); if (!defined($attributes)) { + my $errorString; if ($self->handlerExists($handler) != TRUE) { - $self->{'err_string'} = "devicesByHandler(): Handler '$handler' is not available"; + $errorString = "devicesByHandler(): Handler '$handler' is not available"; + } else { + $errorString = "devicesByHandler() failed"; } - return undef; + return (undef, $errorString); } - return \@{$$attributes{'devices'}->{'value'}}; + return (\@{$$attributes{'devices'}->{'value'}}, undef); } sub checkDeviceCreateAttributes { @@ -4045,7 +4049,7 @@ sub checkDeviceCreateAttributes { return FALSE if (!defined($check)); - my $available = $self->deviceCreateAttributes($handler); + my ($available, $errorString) = $self->deviceCreateAttributes($handler); if (!defined($available)) { my $rc = $self->handlerExists($handler); @@ -4089,14 +4093,15 @@ sub deviceCreateAttributes { SCST_MGMT_IO), O_RDONLY; if (!$io) { + my $errorString; if ($self->handlerExists($handler) != TRUE) { - $self->{'err_string'} = "deviceCreateAttributes(): Handler '$handler' ". + $errorString = "deviceCreateAttributes(): Handler '$handler' ". "is not available"; } else { - $self->{'err_string'} = "deviceCreateAttributes(): Unable to open mgmt ". + $errorString = "deviceCreateAttributes(): Unable to open mgmt ". "interface for handler '$handler': $!"; } - return undef; + return (undef, $errorString); } while (my $in = <$io>) { @@ -4116,7 +4121,7 @@ sub deviceCreateAttributes { } } - return \%attributes; + return (\%attributes, undef); } sub openDevice { @@ -4174,8 +4179,6 @@ sub openDevice { return SCST_C_DEV_OPEN_FAIL if ($errno == EINVAL); - $self->{'err_string'} = "openDevice(): Unable to open mgmt interface for ". - "handler '$handler': $errno"; return SCST_C_FATAL_ERROR; } @@ -4218,8 +4221,6 @@ sub closeDevice { return SCST_C_DEV_NO_DEVICE if ($rc != TRUE); return $rc if ($rc > 1); - $self->{'err_string'} = "closeDevice(): Unable to open mgmt interface for handler ". - "'$handler': $errno"; return SCST_C_FATAL_ERROR; } @@ -4268,7 +4269,7 @@ sub checkTargetCreateAttributes { return FALSE if (!defined($check)); - my $available = $self->targetCreateAttributes($driver); + my ($available, $errorString) = $self->targetCreateAttributes($driver); if (!defined($available)) { my $rc = $self->driverExists($driver); @@ -4311,14 +4312,15 @@ sub targetCreateAttributes { SCST_MGMT_IO), O_RDONLY; if (!$io) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "targetCreateAttributes(): Driver '$driver' ". + $errorString = "targetCreateAttributes(): Driver '$driver' ". "is not available"; } else { - $self->{'err_string'} = "targetCreateAttributes(): Unable to open driver mgmt ". + $errorString = "targetCreateAttributes(): Unable to open driver mgmt ". "interface for driver '$driver': $!"; } - return undef; + return (undef, $errorString); } while (my $in = <$io>) { @@ -4338,7 +4340,7 @@ sub targetCreateAttributes { } } - return \%attributes; + return (\%attributes, undef); } sub enableTarget { @@ -4371,7 +4373,7 @@ sub deviceGroupExists { my $self = shift; my $group = shift; - my $groups = $self->deviceGroups(); + my ($groups, $errorString) = $self->deviceGroups(); return SCST_C_FATAL_ERROR if (!defined($groups)); @@ -4387,13 +4389,9 @@ sub deviceGroupDeviceExists { my $group = shift; my $device = shift; - my $devices = $self->deviceGroupDevices($group); + my ($devices, $errorString) = $self->deviceGroupDevices($group); if (!defined($devices)) { - if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "deviceGroupDeviceExists(): Device group '$group' does not exist"; - return undef; - } return SCST_C_FATAL_ERROR; } @@ -4409,13 +4407,9 @@ sub targetGroupExists { my $group = shift; my $tgroup = shift; - my $tgroups = $self->targetGroups($group); + my ($tgroups, $errorString) = $self->targetGroups($group); if (!defined($tgroups)) { - if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "targetGroupExists(): Device group '$group' does not exist"; - return undef; - } return SCST_C_FATAL_ERROR; } @@ -4432,18 +4426,10 @@ sub targetGroupTargetExists { my $tgroup = shift; my $tgt = shift; - my $targets = $self->targetGroupTargets($group, $tgroup); + my ($targets, $errorString) = $self->targetGroupTargets($group, $tgroup); if (!defined($targets)) { - if ($self->deviceGroupExists($group) != TRUE) { - $self->{'err_string'} = "targetGroupTargetExists(): Device group '$group' does not exist"; - return undef; - } elsif ($self->targetGroupExists($group, $tgroup) != TRUE) { - $self->{'err_string'} = "targetGroupTargetExists(): Target group '$tgroup' does not exist"; - return undef; - } else { - return SCST_C_FATAL_ERROR; - } + return SCST_C_FATAL_ERROR; } foreach my $_tgt (@{$targets}) { @@ -4462,7 +4448,7 @@ sub checkLunCreateAttributes { return FALSE if (!defined($check)); - my $available = $self->lunCreateAttributes($driver, $target, $group); + my ($available, $errorString) = $self->lunCreateAttributes($driver, $target, $group); if (!defined($available)) { my $rc = $self->driverExists($driver); @@ -4510,9 +4496,8 @@ sub lunCreateAttributes { if (new_sysfs_interface()) { if (defined($group)) { if ($self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "lunCreateAttributes(): Group '$group' ". - "does not exist"; - return undef; + return ("lunCreateAttributes(): Group '$group' ". + "does not exist"); } $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, @@ -4542,20 +4527,21 @@ sub lunCreateAttributes { my $io = new IO::File $_path, O_RDONLY; if (!$io) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "lunCreateAttributes(): Driver '$driver' ". + $errorString = "lunCreateAttributes(): Driver '$driver' ". "is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "lunCreateAttributes(): Target '$target' ". + $errorString = "lunCreateAttributes(): Target '$target' ". "is not available"; } elsif (defined($group) && $self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "lunCreateAttributes(): Group '$group' ". + $errorString = "lunCreateAttributes(): Group '$group' ". "does not exist"; } else { - $self->{'err_string'} = "lunCreateAttributes(): Unable to open luns mgmt ". + $errorString = "lunCreateAttributes(): Unable to open luns mgmt ". "interface for group '$group': $!"; } - return undef; + return (undef, $errorString); } while (my $in = <$io>) { @@ -4574,7 +4560,7 @@ sub lunCreateAttributes { } } } - return \%attributes; + return (\%attributes, undef); } sub checkInitiatorCreateAttributes { @@ -4586,7 +4572,7 @@ sub checkInitiatorCreateAttributes { return FALSE if (!defined($check)); - my $available = $self->initiatorCreateAttributes($driver, $target, $group); + my ($available, $errorString) = $self->initiatorCreateAttributes($driver, $target, $group); if (!defined($available)) { my $rc = $self->driverExists($driver); @@ -4636,21 +4622,21 @@ sub initiatorCreateAttributes { O_RDONLY; if (!$io) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "initiatorCreateAttributes(): Driver '$driver' ". + $errorString = "initiatorCreateAttributes(): Driver '$driver' ". "is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "initiatorCreateAttributes(): Target '$target' ". + $errorString = "initiatorCreateAttributes(): Target '$target' ". "is not available"; - return undef; } elsif ($self->groupExists($driver, $target, $group) != TRUE) { - $self->{'err_string'} = "initiatorCreateAttributes(): Group '$group' ". + $errorString = "initiatorCreateAttributes(): Group '$group' ". "does not exist"; } else { - $self->{'err_string'} = "initiatorCreateAttributes(): Unable to open initiators mgmt ". + $errorString = "initiatorCreateAttributes(): Unable to open initiators mgmt ". "interface for group '$group': $!"; } - return undef; + return (undef, $errorString); } while (my $in = <$io>) { @@ -4670,7 +4656,7 @@ sub initiatorCreateAttributes { } } - return \%attributes; + return (\%attributes, undef); } sub sessions { @@ -4679,22 +4665,23 @@ sub sessions { my $target = shift; my %_sessions; - return undef if (!defined($driver) || !defined($target)); + return (undef, "Too few arguments") if (!defined($driver) || !defined($target)); my $sHandle = new IO::Handle; my $_path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_SESSIONS); if (!(opendir $sHandle, $_path)) { + my $errorString; if ($self->driverExists($driver) != TRUE) { - $self->{'err_string'} = "sessions(): Driver '$driver' ". + $errorString = "sessions(): Driver '$driver' ". "is not available"; } elsif ($self->targetExists($driver, $target) != TRUE) { - $self->{'err_string'} = "sessions(): Target '$target' ". + $errorString = "sessions(): Target '$target' ". "is not available"; } else { - $self->{'err_string'} = "sessions(): Unable to read directory '$_path': $!"; + $errorString = "sessions(): Unable to read directory '$_path': $!"; } - return undef; + return (undef, $errorString); } foreach my $session (readdir($sHandle)) { @@ -4702,8 +4689,7 @@ sub sessions { my $pHandle = new IO::Handle; my $sPath = make_path($_path, $session); if (!(opendir $pHandle, $sPath)) { - $self->{'err_string'} = "sessions(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "sessions(): Unable to read directory '$_path': $!"); } foreach my $attribute (readdir($pHandle)) { @@ -4739,9 +4725,9 @@ sub sessions { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "sessions(): Unable to read ". - "session attribute '$attribute': $!"; - return undef; + return (undef, + "sessions(): Unable to read ". + "session attribute '$attribute': $!"); } my $value = <$io>; @@ -4758,7 +4744,7 @@ sub sessions { } close $sHandle; - return \%_sessions; + return (\%_sessions, undef); } sub closeSession { @@ -4767,7 +4753,7 @@ sub closeSession { my $target = shift; my $session = shift; - my $sessions = $self->sessions($driver, $target); + my ($sessions, $errorString) = $self->sessions($driver, $target); return SCST_C_NO_SESSION if (!defined($$sessions{$session})); @@ -4799,8 +4785,7 @@ sub sgvStats { my $sHandle = new IO::Handle; my $_path = SCST_SGV_DIR(); if (!(opendir $sHandle, $_path)) { - $self->{'err_string'} = "svgStats(): Unable to read directory '$_path': $!"; - return undef; + return (undef, "svgStats(): Unable to read directory '$_path': $!"); } foreach my $stat (readdir($sHandle)) { @@ -4811,8 +4796,7 @@ sub sgvStats { if (-d $sPath) { my $lHandle = new IO::Handle; if (!(opendir $lHandle, $sPath)) { - $self->{'err_string'} = "svgStats(): Unable to read directory '$sPath': $!"; - return undef; + return (undef, "svgStats(): Unable to read directory '$sPath': $!"); } foreach my $lief (readdir($lHandle)) { @@ -4821,9 +4805,8 @@ sub sgvStats { my $io = new IO::File $pPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "sgvStats(): Unable to read ". - "sgv stat '$stat/$lief': $!"; - return undef; + return (undef, "sgvStats(): Unable to read ". + "sgv stat '$stat/$lief': $!"); } my $buffer; @@ -4839,9 +4822,8 @@ sub sgvStats { my $io = new IO::File $sPath, O_RDONLY; if (!$io) { - $self->{'err_string'} = "sgvStats(): Unable to read ". - "sgv stat '$stat': $!"; - return undef; + return (undef, "sgvStats(): Unable to read ". + "sgv stat '$stat': $!"); } my $buffer; @@ -4855,20 +4837,14 @@ sub sgvStats { } close $sHandle; - return \%stats; + return (\%stats, undef); } sub errorString { my $self = shift; my $rc = shift; - return $VERBOSE_ERROR{$rc} if (defined($rc)); - return undef if (!$self->{'err_string'}); - - my $string = $self->{'err_string'}; - $self->{'err_string'} = undef; - - return $string; + return defined($rc) ? $VERBOSE_ERROR{$rc} : undef; } # Read from the SCST sysfs file $1. Return either the data read or undef if diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t index 2f91137a3..267423138 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t @@ -11,7 +11,7 @@ use SCST::SCST; sub getScstThreadCount { my $SCST = shift; - my $scstAttributes = $SCST->scstAttributes(); + my ($scstAttributes, $errorString) = $SCST->scstAttributes(); my $threadHash = $scstAttributes->{'threads'}; return exists($threadHash->{'keys'}) ? $threadHash->{'keys'}->{'0'}->{'value'} : $threadHash->{'value'}; } diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t index 547ed82af..28db54d06 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t @@ -4,7 +4,7 @@ use strict; use Test; BEGIN { - plan tests => 181; + plan tests => 177; } use Data::Dumper; @@ -13,17 +13,18 @@ use SCST::SCST; sub addTargets { my $SCST = shift; - ok($SCST->targets('no-such-driver'), undef); - ok($SCST->{'err_string'}, - "targets(): Driver 'no-such-driver' is not available"); + ok(Dumper($SCST->targets('no-such-driver')), + Dumper(undef, "targets(): Driver 'no-such-driver' is not available")); - my %drivers = map { $_ => 1 } @{$SCST->drivers()}; + my ($drivers, $errorString) = $SCST->drivers(); + my %drivers = map { $_ => 1 } @{$drivers}; ok(exists($drivers{'iscsi'})); ok(exists($drivers{'scst_local'})); my $all_hw_tgt = 1; - for my $driver (@{$SCST->drivers()}) { - for my $target (@{$SCST->targets($driver)}) { + for my $driver (@{$drivers}) { + my ($targets, $errorString) = $SCST->targets($driver); + for my $target (@{$targets}) { if ($SCST->targetType($driver, $target) != $SCST::SCST::TGT_TYPE_HARDWARE) { $all_hw_tgt = undef; @@ -32,35 +33,36 @@ sub addTargets { } ok($all_hw_tgt); - ok(Dumper($SCST->targets()), Dumper(undef)); - ok(Dumper($SCST->targets('no-such-driver')), Dumper(undef)); - ok($SCST->{'err_string'}, - "targets(): Driver 'no-such-driver' is not available"); - ok(Dumper($SCST->targets('scst_local')), Dumper([])); - ok(Dumper($SCST->targets('iscsi')), Dumper([])); + ok(Dumper($SCST->targets()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->targets('no-such-driver')), + Dumper(undef, "targets(): Driver 'no-such-driver' is not available")); + ok(Dumper($SCST->targets('scst_local')), Dumper([], undef)); + ok(Dumper($SCST->targets('iscsi')), Dumper([], undef)); ok($SCST->addVirtualTarget('no-such-driver', ''), $SCST->SCST_C_DRV_NO_DRIVER); ok($SCST->removeVirtualTarget('no-such-driver', ''), $SCST->SCST_C_DRV_NO_DRIVER); ok($SCST->addVirtualTarget('scst_local', 'local1'), 0); - ok(Dumper($SCST->targetType()), Dumper(undef)); - ok(Dumper($SCST->targetType('scst_local')), Dumper(undef)); + ok(Dumper($SCST->targetType()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->targetType('scst_local')), + Dumper(undef, "Too few arguments")); ok($SCST->targetType('scst_local', 'no-such-target'), $SCST::SCST::TGT_TYPE_VIRTUAL); ok($SCST->targetType('scst_local', 'local1'), $SCST::SCST::TGT_TYPE_VIRTUAL); - ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'])); + ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'], undef)); ok($SCST->removeVirtualTarget('scst_local', 'local2'), $SCST->SCST_C_TGT_NO_TARGET); - ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'])); + ok(Dumper($SCST->targets('scst_local')), Dumper(['local1'], undef)); ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0); - ok(Dumper($SCST->targets('scst_local')), Dumper([])); + ok(Dumper($SCST->targets('scst_local')), Dumper([], undef)); ok($SCST->addVirtualTarget('scst_local', 'local1', { 'session_name' => 'local1' }), 0); ok($SCST->addVirtualTarget('scst_local', 'local2', { 'session_name' => 'local2' }), 0); - ok(Dumper($SCST->targets('scst_local')), Dumper(['local1', 'local2'])); + ok(Dumper($SCST->targets('scst_local')), + Dumper(['local1', 'local2'], undef)); ok($SCST->targetExists(), 0); ok($SCST->targetExists('no-such-driver'), 0); @@ -75,9 +77,10 @@ sub addTargets { sub sessTest { my $SCST = shift; - ok(Dumper($SCST->sessions()), Dumper(undef)); - ok(Dumper($SCST->sessions('scst_local')), Dumper(undef)); - my $s = $SCST->sessions('scst_local', 'local1'); + ok(Dumper($SCST->sessions()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->sessions('scst_local')), + Dumper(undef, "Too few arguments")); + my ($s, $errorString) = $SCST->sessions('scst_local', 'local1'); ok(Dumper(sort(keys(%$s))), Dumper('local1')); ok($s->{'local1'}->{'commands'}->{'value'}, '0'); } @@ -85,19 +88,22 @@ sub sessTest { sub driverDynamicAttributesTest { my $SCST = shift; - ok(Dumper($SCST->driverDynamicAttributes()), Dumper(undef)); - ok(Dumper($SCST->driverDynamicAttributes('no-such-driver')), Dumper(undef)); - ok($SCST->{'err_string'}, - "driverDynamicAttributes(): Driver 'no-such-driver' is not available"); - ok(Dumper($SCST->driverDynamicAttributes('scst_local')), Dumper({})); + ok(Dumper($SCST->driverDynamicAttributes()), + Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->driverDynamicAttributes('no-such-driver')), + Dumper(undef, "driverDynamicAttributes(): Driver 'no-such-driver' is " . + "not available")); + ok(Dumper($SCST->driverDynamicAttributes('scst_local')), + Dumper({}, undef)); } sub iniGrpTest { my $SCST = shift; - ok(Dumper($SCST->groups()), Dumper(undef)); - ok(Dumper($SCST->groups('scst_local')), Dumper(undef)); - ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([])); + ok(Dumper($SCST->groups()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->groups('scst_local')), + Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([], undef)); ok($SCST->addGroup(), $SCST->SCST_C_GRP_ADD_FAIL); ok($SCST->addGroup('no-such-driver', 'local1', 'group1'), @@ -110,7 +116,7 @@ sub iniGrpTest { ok($SCST->addGroup('scst_local', 'local1', 'group2'), 0); ok($SCST->addGroup('scst_local', 'local1', 'group3'), 0); ok(Dumper($SCST->groups('scst_local', 'local1')), - Dumper(['group1', 'group2', 'group3'])); + Dumper(['group1', 'group2', 'group3'], undef)); ok($SCST->groupExists(), 0); ok($SCST->groupExists('no-such-driver', '', ''), 0); @@ -128,7 +134,7 @@ sub iniGrpTest { $SCST->SCST_C_GRP_NO_GROUP); ok($SCST->removeGroup('scst_local', 'local1', 'group2'), 0); ok($SCST->removeGroup('scst_local', 'local1', 'group3'), 0); - ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([])); + ok(Dumper($SCST->groups('scst_local', 'local1')), Dumper([], undef)); ok($SCST->addGroup('scst_local', 'local1', 'group1'), 0); ok($SCST->addInitiator('scst_local', 'local1', 'group1'), @@ -143,11 +149,13 @@ sub iniGrpTest { ok($SCST->addInitiator('scst_local', 'local1', 'group1', 'ini2'), 0); ok($SCST->addInitiator('scst_local', 'local1', 'group1', 'ini1'), $SCST->SCST_C_GRP_INI_EXISTS); - ok(Dumper($SCST->initiators()), Dumper(undef)); - ok(Dumper($SCST->initiators('scst_local')), Dumper(undef)); - ok(Dumper($SCST->initiators('scst_local', 'local1')), Dumper(undef)); + ok(Dumper($SCST->initiators()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->initiators('scst_local')), + Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->initiators('scst_local', 'local1')), + Dumper(undef, "Too few arguments")); ok(Dumper($SCST->initiators('scst_local', 'local1', 'group1')), - Dumper(['ini1', 'ini2'])); + Dumper(['ini1', 'ini2'], undef)); ok($SCST->initiatorExists(), 0); ok($SCST->initiatorExists('no-such-driver', '', '', ''), 0); @@ -180,7 +188,8 @@ sub iniGrpTest { ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini2'), 0); ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini2'), $SCST->SCST_C_GRP_NO_INI); - ok(Dumper($SCST->initiators('scst_local', 'local1', 'group1')), Dumper([])); + ok(Dumper($SCST->initiators('scst_local', 'local1', 'group1')), + Dumper([], undef)); ok($SCST->removeGroup('scst_local', 'local1', 'group1'), 0); } @@ -190,7 +199,7 @@ sub lunReadOnly { my $target = shift; my $lun = shift; - my $a = $SCST->lunAttributes($driver, $target, $lun); + my ($a, $errorString) = $SCST->lunAttributes($driver, $target, $lun); my $roHash = $a->{'read_only'}; return exists($roHash->{'keys'}) ? $roHash->{'keys'}->{'0'}->{'value'} : $roHash->{'value'}; @@ -207,6 +216,8 @@ sub lunTest { $SCST->SCST_C_DEV_OPEN_FAIL); ok($SCST->openDevice("vdisk_fileio", "disk01", { 'filename' => '/proc/cpuinfo' }), 0); + ok(Dumper($SCST->devicesByHandler("vdisk_fileio")), + Dumper(["disk01"], undef)); ok($SCST->openDevice("vdisk_fileio", "disk01", { 'filename' => '/proc/cpuinfo' }), $SCST->SCST_C_DEV_EXISTS); @@ -255,20 +266,18 @@ sub lunTest { $SCST->SCST_C_GRP_NO_GROUP); ok($SCST->lunExists('scst_local', 'local1', 0, 'group1'), 1); - ok(Dumper($SCST->luns()), Dumper(undef)); - ok(Dumper($SCST->luns('scst_local')), Dumper(undef)); - ok(Dumper($SCST->luns('no-such-driver', 'local1')), Dumper(undef)); - ok($SCST->{'err_string'}, - "luns(): Driver 'no-such-driver' is not available"); - ok(Dumper($SCST->luns('scst_local', 'no-such-target')), Dumper(undef)); - ok($SCST->{'err_string'}, - "luns(): Target 'no-such-target' is not available"); + ok(Dumper($SCST->luns()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->luns('scst_local')), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->luns('no-such-driver', 'local1')), + Dumper(undef, "luns(): Driver 'no-such-driver' is not available")); + ok(Dumper($SCST->luns('scst_local', 'no-such-target')), + Dumper(undef, "luns(): Target 'no-such-target' is not available")); ok(Dumper($SCST->luns('scst_local', 'local1')), Dumper({ '0' => 'disk01', '1' => 'disk02', '2' => 'disk01', - '3' => 'disk02' })); + '3' => 'disk02' }, undef)); ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')), Dumper({ '0' => 'disk01', '2' => 'disk02', '4' => 'disk01', - '6' => 'disk02' })); + '6' => 'disk02' }, undef)); ok(lunReadOnly($SCST, 'scst_local', 'local1', 0), '0'); ok($SCST->setLunAttribute(), $SCST->SCST_C_LUN_SETATTR_FAIL); @@ -293,11 +302,11 @@ sub lunTest { ok($SCST->replaceLun('scst_local', 'local1', 0, 'disk02', {}), 0); ok(Dumper($SCST->luns('scst_local', 'local1')), Dumper({ '0' => 'disk02', '1' => 'disk02', '2' => 'disk01', - '3' => 'disk02' })); + '3' => 'disk02' }, undef)); ok($SCST->replaceLun('scst_local', 'local1', 0, 'disk01', {}), 0); ok(Dumper($SCST->luns('scst_local', 'local1')), Dumper({ '0' => 'disk01', '1' => 'disk02', '2' => 'disk01', - '3' => 'disk02' })); + '3' => 'disk02' }, undef)); ok($SCST->clearLuns(undef, undef), $SCST->SCST_C_TGT_CLR_LUN_FAIL); ok($SCST->clearLuns(undef, undef, 'group1'), @@ -313,15 +322,16 @@ sub lunTest { ok($SCST->removeLun('scst_local', 'local1', '8', 'group1'), $SCST->SCST_C_GRP_NO_LUN); ok($SCST->clearLuns('scst_local', 'local1'), 0); - ok(Dumper($SCST->luns('scst_local', 'local1')), Dumper({ })); + ok(Dumper($SCST->luns('scst_local', 'local1')), Dumper({ }, undef)); ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')), Dumper({ '0' => 'disk01', '2' => 'disk02', '4' => 'disk01', - '6' => 'disk02' })); + '6' => 'disk02' }, undef)); ok($SCST->removeLun('scst_local', 'local1', '4', 'group1'), 0); ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')), - Dumper({ '0' => 'disk01', '2' => 'disk02', '6' => 'disk02' })); + Dumper({ '0' => 'disk01', '2' => 'disk02', '6' => 'disk02' }, undef)); ok($SCST->clearLuns('scst_local', 'local1', 'group1'), 0); - ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')), Dumper({ })); + ok(Dumper($SCST->luns('scst_local', 'local1', 'group1')), + Dumper({ }, undef)); ok($SCST->removeInitiator('scst_local', 'local1', 'group1', 'ini1'), 0); ok($SCST->removeGroup('scst_local', 'local1', 'group1'), 0); @@ -339,7 +349,7 @@ sub remTargets { ok($SCST->removeVirtualTarget('scst_local', 'local2'), 0); ok($SCST->removeVirtualTarget('scst_local', 'local1'), 0); - ok(Dumper($SCST->targets('scst_local')), Dumper([])); + ok(Dumper($SCST->targets('scst_local')), Dumper([], undef)); } my $_DEBUG_ = 0; diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t index be0ffcbde..c2b39a7d1 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t @@ -4,7 +4,7 @@ use strict; use Test; BEGIN { - plan tests => 65; + plan tests => 62; } use Data::Dumper; @@ -13,7 +13,8 @@ use SCST::SCST; sub setup { my $SCST = shift; - my %drivers = map { $_ => 1 } @{$SCST->drivers()}; + my ($drivers, $errorString) = $SCST->drivers(); + my %drivers = map { $_ => 1 } @{$drivers}; ok(exists($drivers{'iscsi'})); ok(exists($drivers{'scst_local'})); @@ -37,17 +38,18 @@ sub setup { sub test { my $SCST = shift; - ok(Dumper($SCST->deviceGroups()), Dumper([])); + ok(Dumper($SCST->deviceGroups()), Dumper([], undef)); ok($SCST->addDeviceGroup('dg1'), 0); ok($SCST->addDeviceGroup('dg2'), 0); ok($SCST->addDeviceGroup('dg3'), 0); ok($SCST->addDeviceGroup('dg4'), 0); - ok(Dumper($SCST->deviceGroups()), Dumper(['dg1', 'dg2', 'dg3', 'dg4'])); + ok(Dumper($SCST->deviceGroups()), + Dumper(['dg1', 'dg2', 'dg3', 'dg4'], undef)); - ok(Dumper($SCST->deviceGroupDevices()), Dumper(undef)); - ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper([])); + ok(Dumper($SCST->deviceGroupDevices()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper([], undef)); ok($SCST->addDeviceGroupDevice('dg1', 'disk01'), 0); ok($SCST->addDeviceGroupDevice('dg1', 'disk01'), $SCST->SCST_C_DGRP_DEVICE_EXISTS); @@ -56,26 +58,28 @@ sub test { $SCST->SCST_C_DGRP_DEVICE_OTHER); ok($SCST->addDeviceGroupDevice('dg3', 'disk03'), 0); ok($SCST->addDeviceGroupDevice('dg4', 'disk04'), 0); - ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper(['disk01'])); - ok(Dumper($SCST->deviceGroupDevices('dg2')), Dumper(['disk02'])); - ok(Dumper($SCST->deviceGroupDevices('dg3')), Dumper(['disk03'])); - ok(Dumper($SCST->deviceGroupDevices('dg4')), Dumper(['disk04'])); + ok(Dumper($SCST->deviceGroupDevices('dg1')), Dumper(['disk01'], undef)); + ok(Dumper($SCST->deviceGroupDevices('dg2')), Dumper(['disk02'], undef)); + ok(Dumper($SCST->deviceGroupDevices('dg3')), Dumper(['disk03'], undef)); + ok(Dumper($SCST->deviceGroupDevices('dg4')), Dumper(['disk04'], undef)); - ok($SCST->targetGroups(), undef); - ok($SCST->targetGroups('no-such-device-group'), undef); - ok($SCST->{'err_string'}, - "targetGroups(): Device group 'no-such-device-group' does not exist"); - ok(Dumper($SCST->targetGroups('dg1')), Dumper([])); + ok(Dumper($SCST->targetGroups()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->targetGroups('no-such-device-group')), + Dumper(undef, "targetGroups(): Device group 'no-such-device-group'" . + " does not exist")); + ok(Dumper($SCST->targetGroups('dg1')), Dumper([], undef)); - ok($SCST->targetGroupTargets(), undef); - ok($SCST->targetGroupTargets('no-such-device-group'), undef); - ok($SCST->targetGroupTargets('no-such-device-group', 'tg1'), undef); - ok($SCST->{'err_string'}, - "targetGroupTargets(): Device group 'no-such-device-group' does not exist"); - ok($SCST->targetGroupTargets('dg1', 'no-such-target-group'), undef); - ok($SCST->{'err_string'}, - "targetGroupTargets(): Target group 'no-such-target-group' does not exist"); - ok($SCST->targetGroupTargets('dg1', 'tg1'), undef); + ok(Dumper($SCST->targetGroupTargets()), Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->targetGroupTargets('no-such-device-group')), + Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->targetGroupTargets('no-such-device-group', 'tg1')), + Dumper(undef, "targetGroupTargets(): Device group 'no-such-device-". + "group' does not exist")); + ok(Dumper($SCST->targetGroupTargets('dg1', 'no-such-target-group')), + Dumper(undef, "targetGroupTargets(): Target group 'no-such-target-". + "group' does not exist")); + ok(Dumper($SCST->targetGroupTargets('dg1', 'tg1')), Dumper(undef, + "targetGroupTargets(): Target group 'tg1' does not exist")); ok($SCST->addTargetGroup(), $SCST->SCST_C_DGRP_ADD_GRP_FAIL); ok($SCST->addTargetGroup('no-such-device-group', 'tg1'), $SCST->SCST_C_DEV_GRP_NO_GROUP); @@ -83,13 +87,13 @@ sub test { ok($SCST->addTargetGroup('dg1', 'tg1'), $SCST->SCST_C_DGRP_GROUP_EXISTS); ok($SCST->addTargetGroup('dg1', 'tg2'), 0); - ok(Dumper($SCST->targetGroupAttributes('dg1', 'tg1')->{'group_id'}), - Dumper({ 'keys' => { '0' => { 'value' => '0' } }, - 'static' => 0 })); + my ($tga, $errorString) = $SCST->targetGroupAttributes('dg1', 'tg1'); + ok(Dumper($tga->{'group_id'}), + Dumper({ 'keys' => { '0' => { 'value' => '0' } }, 'static' => 0 })); ok($SCST->setTargetGroupAttribute('dg1', 'tg1', 'group_id', 7), 0); - ok(Dumper($SCST->targetGroupAttributes('dg1', 'tg1')->{'group_id'}), - Dumper({ 'keys' => { '0' => { 'value' => '7' } }, - 'static' => 0 })); + ($tga, $errorString) = $SCST->targetGroupAttributes('dg1', 'tg1'); + ok(Dumper($tga->{'group_id'}), + Dumper({ 'keys' => { '0' => { 'value' => '7' } }, 'static' => 0 })); ok($SCST->addTargetGroupTarget(), $SCST->SCST_C_TGRP_ADD_TGT_FAIL); ok($SCST->addTargetGroupTarget('no-such-device-group', 'tg1', 'tgt1'), @@ -101,23 +105,24 @@ sub test { $SCST->SCST_C_TGRP_TGT_EXISTS); ok($SCST->addTargetGroupTarget('dg1', 'tg2', 'tgt2'), 0); - ok(Dumper($SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1') - ->{'rel_tgt_id'}), - Dumper({ 'keys' => { '0' => { 'value' => '0' } }, - 'static' => 0 })); + my $tgta; + ($tgta, $errorString) = + $SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1'); + ok(Dumper($tgta->{'rel_tgt_id'}), + Dumper({ 'keys' => { '0' => { 'value' => '0' } }, 'static' => 0 })); ok($SCST->setTargetGroupTargetAttribute('dg1', 'tg1', 'tgt1', 'rel_tgt_id', 8), 0); - ok(Dumper($SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1') - ->{'rel_tgt_id'}), - Dumper({ 'keys' => { '0' => { 'value' => '8' } }, - 'static' => 0 })); + ($tgta, $errorString) = + $SCST->targetGroupTargetAttributes('dg1', 'tg1', 'tgt1'); + ok(Dumper($tgta->{'rel_tgt_id'}), + Dumper({ 'keys' => { '0' => { 'value' => '8' } }, 'static' => 0 })); ok($SCST->removeDeviceGroup('dg1'), 0); ok($SCST->removeDeviceGroup('dg2'), 0); ok($SCST->removeDeviceGroup('dg3'), 0); ok($SCST->removeDeviceGroup('dg4'), 0); - ok(Dumper($SCST->deviceGroups()), Dumper([])); + ok(Dumper($SCST->deviceGroups()), Dumper([], undef)); } sub teardown { diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t index 47592e516..02ff569ca 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t @@ -4,7 +4,7 @@ use strict; use Test; BEGIN { - plan tests => 57; + plan tests => 55; } use Data::Dumper; @@ -13,7 +13,8 @@ use SCST::SCST; sub setup { my $SCST = shift; - my %drivers = map { $_ => 1 } @{$SCST->drivers()}; + my ($drivers, $errorString) = $SCST->drivers(); + my %drivers = map { $_ => 1 } @{$drivers}; ok(exists($drivers{'iscsi'})); ok(exists($drivers{'scst_local'})); @@ -28,13 +29,14 @@ sub setup { sub testDriverDynAttr { my $SCST = shift; - ok($SCST->driverDynamicAttributes(), undef); - ok($SCST->driverDynamicAttributes('no-such-driver'), undef); - ok($SCST->{'err_string'}, - "driverDynamicAttributes(): Driver 'no-such-driver' is not available"); - ok(Dumper($SCST->driverDynamicAttributes('scst_local')), Dumper({})); + ok(Dumper($SCST->driverDynamicAttributes()), + Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->driverDynamicAttributes('no-such-driver')), + Dumper(undef, "driverDynamicAttributes(): Driver 'no-such-driver' is " . + "not available")); + ok(Dumper($SCST->driverDynamicAttributes('scst_local')), Dumper({}, undef)); ok(Dumper($SCST->driverDynamicAttributes('iscsi')), - Dumper({ 'IncomingUser' => '', 'OutgoingUser' => '' })); + Dumper({ 'IncomingUser' => '', 'OutgoingUser' => '' }, undef)); ok($SCST->checkDriverDynamicAttributes('no-such-driver'), $SCST->SCST_C_DRV_NO_DRIVER); ok($SCST->checkDriverDynamicAttributes('no-such-driver', { }), @@ -60,7 +62,8 @@ sub testDriverDynAttr { 'bar 12CharSecret'), 0); ok($SCST->addDriverDynamicAttribute('iscsi', 'IncomingUser', 'joe 12charsecret'), 0); - ok(Dumper($SCST->driverAttributes('iscsi')->{'IncomingUser'}), + my ($da, $errorString) = $SCST->driverAttributes('iscsi'); + ok(Dumper($da->{'IncomingUser'}), Dumper({ 'keys' => { '0' => { 'value' => 'bar 12CharSecret' }, '1' => { 'value' => 'joe 12charsecret' } }, 'static' => 0 })); @@ -73,21 +76,23 @@ sub testDriverDynAttr { 'joe 12charsecret'), 0); ok($SCST->removeDriverDynamicAttribute('iscsi', 'IncomingUser', 'bar 12CharSecret'), 0); - ok(!exists($SCST->driverAttributes('iscsi')->{'IncomingUser'})); + ($da, $errorString) = $SCST->driverAttributes('iscsi'); + ok(!exists($da->{'IncomingUser'})); } sub testTargetDynAttr { my $SCST = shift; - ok($SCST->targetDynamicAttributes(), undef); - ok($SCST->targetDynamicAttributes('no-such-driver'), undef); - ok($SCST->{'err_string'}, - "targetDynamicAttributes(): Driver 'no-such-driver' is not available"); - ok(Dumper($SCST->targetDynamicAttributes('scst_local')), Dumper({})); + ok(Dumper($SCST->targetDynamicAttributes()), + Dumper(undef, "Too few arguments")); + ok(Dumper($SCST->targetDynamicAttributes('no-such-driver')), + Dumper(undef, "targetDynamicAttributes(): Driver 'no-such-driver' is" . + " not available")); + ok(Dumper($SCST->targetDynamicAttributes('scst_local')), Dumper({}, undef)); ok(Dumper($SCST->targetDynamicAttributes('iscsi')), Dumper({ 'IncomingUser' => '', 'OutgoingUser' => '', - 'allowed_portal' => '' })); + 'allowed_portal' => '' }, undef)); ok($SCST->checkTargetDynamicAttributes('no-such-driver'), $SCST->SCST_C_DRV_NO_DRIVER); ok($SCST->checkTargetDynamicAttributes('no-such-driver', { }), @@ -116,7 +121,8 @@ sub testTargetDynAttr { 'bar 12CharSecret'), 0); ok($SCST->addTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser', 'joe 12charsecret'), 0); - ok(Dumper($SCST->targetAttributes('iscsi', 'tgt1')->{'IncomingUser'}), + my ($ta, $errorString) = $SCST->targetAttributes('iscsi', 'tgt1'); + ok(Dumper($ta->{'IncomingUser'}), Dumper({ 'keys' => { '0' => { 'value' => 'bar 12CharSecret' }, '1' => { 'value' => 'joe 12charsecret' } }, 'static' => 0 })); @@ -132,7 +138,8 @@ sub testTargetDynAttr { 'joe 12charsecret'), 0); ok($SCST->removeTargetDynamicAttribute('iscsi', 'tgt1', 'IncomingUser', 'bar 12CharSecret'), 0); - ok(!exists($SCST->targetAttributes('iscsi', 'tgt1')->{'IncomingUser'})); + ($ta, $errorString) = $SCST->targetAttributes('iscsi', 'tgt1'); + ok(!exists($ta->{'IncomingUser'})); } sub teardown { diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t index 411be7a4e..2aa100c6a 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t @@ -29,7 +29,8 @@ use File::Temp qw/tempfile/; sub setup { my $SCST = shift; - my %drivers = map { $_ => 1 } @{$SCST->drivers()}; + my ($drivers, $errorString) = $SCST->drivers(); + my %drivers = map { $_ => 1 } @{$drivers}; ok(exists($drivers{'ib_srpt'})); } diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 334fb8750..6e976e93b 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1170,58 +1170,58 @@ sub readWorkingConfig { # Get current handlers/devices - my $handlers = $SCST->handlers(); - immediateExit($SCST->errorString()); + my ($handlers, $errorString) = $SCST->handlers(); + immediateExit($errorString); foreach my $handler (@{$handlers}) { - my $devices = $SCST->devicesByHandler($handler); - immediateExit($SCST->errorString()); + my ($devices, $errorString) = $SCST->devicesByHandler($handler); + immediateExit($errorString); $CURRENT{'handler'}->{$handler} = $devices; } # Get current assignments - my $drivers = $SCST->drivers(); - immediateExit($SCST->errorString()); + my ($drivers, $errorString) = $SCST->drivers(); + immediateExit($errorString); foreach my $driver (@{$drivers}) { my %empty; $CURRENT{'assign'}->{$driver} = \%empty; - my $targets = $SCST->targets($driver); - immediateExit($SCST->errorString()); + my ($targets, $errorString) = $SCST->targets($driver); + immediateExit($errorString); foreach my $target (@{$targets}) { my %empty; $CURRENT{'assign'}->{$driver}->{$target} = \%empty; - my $luns = $SCST->luns($driver, $target); + my ($luns, $errorString) = $SCST->luns($driver, $target); $CURRENT{'assign'}->{$driver}->{$target}->{'LUN'} = $luns if (defined($luns)); - my $groups = $SCST->groups($driver, $target); - immediateExit($SCST->errorString()); + my ($groups, $errorString) = $SCST->groups($driver, $target); + immediateExit($errorString); foreach my $group (@{$groups}) { - $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'INITIATORS'} = - $SCST->initiators($driver, $target, $group); - immediateExit($SCST->errorString()); - - $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'LUN'} = - $SCST->luns($driver, $target, $group); - immediateExit($SCST->errorString()); + my ($initiators, $errorString) = $SCST->initiators($driver, $target, $group); + immediateExit($errorString); + $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'INITIATORS'} = $initiators; + my ($luns, $errorString) = $SCST->luns($driver, $target, $group); + $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'LUN'} = $luns; + immediateExit($errorString); } } } - my $dgroups = $SCST->deviceGroups(); - immediateExit($SCST->errorString()); + my ($dgroups, $errorString) = $SCST->deviceGroups(); + immediateExit($errorString); foreach my $dgroup (@{$dgroups}) { - $CURRENT{'dgroups'}->{$dgroup}->{'devices'} = $SCST->deviceGroupDevices($dgroup); - immediateExit($SCST->errorString()); - my $tgroups = $SCST->targetGroups($dgroup); - immediateExit($SCST->errorString()); + my ($dgd, $errorString) = $SCST->deviceGroupDevices($dgroup); + immediateExit($errorString); + $CURRENT{'dgroups'}->{$dgroup}->{'devices'} = $dgd; + my ($tgroups, $errorString) = $SCST->targetGroups($dgroup); + immediateExit($errorString); foreach my $tgroup (@{$tgroups}) { - $CURRENT{'dgroups'}->{$dgroup}->{'tgroups'}->{$tgroup}->{'targets'} = - $SCST->targetGroupTargets($dgroup, $tgroup); + my ($tgt, $errorString) = $SCST->targetGroupTargets($dgroup, $tgroup); + $CURRENT{'dgroups'}->{$dgroup}->{'tgroups'}->{$tgroup}->{'targets'} = $tgt; } } @@ -1348,8 +1348,8 @@ sub writeConfiguration { print $io "# Automatically generated by $Version.\n\n"; { - my $attributes = $SCST->scstAttributes(); - immediateExit($SCST->errorString()); + my ($attributes, $errorString) = $SCST->scstAttributes(); + immediateExit($errorString); print $io serializeKeyAttr("", $attributes); if ($nonkey) { @@ -1366,8 +1366,8 @@ sub writeConfiguration { my $handler_buff; my $handler_buff_nk; - my $handler_attrs = $SCST->deviceCreateAttributes($handler); - my $attributes = $SCST->handlerAttributes($handler); + my ($handler_attrs, $errorString) = $SCST->deviceCreateAttributes($handler); + my ($attributes, $errorString) = $SCST->handlerAttributes($handler); $handler_buff = serializeKeyAttr("\t", $attributes); $handler_buff_nk = serializeNkAttr("\t", $attributes) if ($nonkey); @@ -1378,7 +1378,7 @@ sub writeConfiguration { foreach my $device (sort @{$devices}) { $device_buff .= "\tDEVICE $device"; - my $attributes = $SCST->deviceAttributes($device); + my ($attributes, $errorString) = $SCST->deviceAttributes($device); my $attribute_buff; my $attribute_buff_nk; @@ -1423,7 +1423,7 @@ sub writeConfiguration { foreach my $driver (sort keys %{$CURRENT{'assign'}}) { my $driver_buff; - my $drv_attrs = $SCST->driverAttributes($driver); + my ($drv_attrs, $errorString) = $SCST->driverAttributes($driver); my $drv_attr_buff; my $drv_attr_buff_nk; @@ -1434,13 +1434,13 @@ sub writeConfiguration { $drv_attr_buff_nk .= "\n" if ($drv_attr_buff_nk); my $targets = $CURRENT{'assign'}->{$driver}; - my $tgt_attrs = $SCST->targetCreateAttributes($driver); + my ($tgt_attrs, $errorString) = $SCST->targetCreateAttributes($driver); my $target_buff; foreach my $target (sort keys %{$targets}) { $target_buff .= "\tTARGET $target"; - my $attributes = $SCST->targetAttributes($driver, $target); + my ($attributes, $errorString) = $SCST->targetAttributes($driver, $target); my $attribute_buff; my $attribute_buff_nk; @@ -1456,7 +1456,7 @@ sub writeConfiguration { $attribute_buff_nk .= "\n" if ($attribute_buff_nk); my $luns = $CURRENT{'assign'}->{$driver}->{$target}->{'LUN'}; - my $lun_attrs = $SCST->lunCreateAttributes($driver, $target); + my ($lun_attrs, $errorString) = $SCST->lunCreateAttributes($driver, $target); my $t_lun_buff; foreach my $lun (sort numerically keys %{$luns}) { @@ -1464,7 +1464,7 @@ sub writeConfiguration { $t_lun_buff .= "\t\tLUN $lun $lun_dev"; - my $attributes = $SCST->lunAttributes($driver, $target, $lun); + my ($attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun); my $l_attribute_buff = serializeKeyAttr("\t\t\t", $attributes, @@ -1495,8 +1495,8 @@ sub writeConfiguration { my $group_buff; foreach my $group (sort keys %{$groups}) { - my $lun_attrs = $SCST->lunCreateAttributes($driver, $target, $group); - my $ini_attrs = $SCST->initiatorCreateAttributes($driver, $target, $group); + my ($lun_attrs, $errorString) = $SCST->lunCreateAttributes($driver, $target, $group); + my ($ini_attrs, $errorString) = $SCST->initiatorCreateAttributes($driver, $target, $group); $group_buff .= "\t\tGROUP $group"; @@ -1508,7 +1508,7 @@ sub writeConfiguration { $lun_buff .= "\t\t\tLUN $lun $lun_dev"; - my $attributes = $SCST->lunAttributes($driver, $target, $lun, $group); + my ($attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun, $group); my $l_attribute_buff = serializeKeyAttr("\t\t\t\t", @@ -1540,7 +1540,7 @@ sub writeConfiguration { foreach my $init (sort @{$inits}) { $init_buff .= "\n\t\t\tINITIATOR " . escapeMeta($init); - my $attributes = $SCST->initiatorAttributes($driver, $target, $group, $init); + my ($attributes, $errorString) = $SCST->initiatorAttributes($driver, $target, $group, $init); my $i_attribute_buff = serializeKeyAttr("\t\t\t\t", @@ -1572,7 +1572,7 @@ sub writeConfiguration { $group_buff .= $init_buff; } - my $grp_attributes = $SCST->groupAttributes($driver, $target, $group); + my ($grp_attributes, $errorString) = $SCST->groupAttributes($driver, $target, $group); my $g_attribute_buff = serializeKeyAttr("\t\t\t", $grp_attributes); @@ -1636,7 +1636,7 @@ sub writeConfiguration { } } - my $dga = $SCST->aluaAttributes(); + my ($dga, $errorString) = $SCST->aluaAttributes(); my $dga_buff = serializeKeyAttr("\t", $dga); my $dga_buff_nk = serializeNkAttr("\t", $dga) if ($nonkey); if ($dga_buff_nk) { @@ -1652,7 +1652,7 @@ sub writeConfiguration { foreach my $dgroup (sort keys %{$CURRENT{'dgroups'}}) { my $dgroup_buff; - my $dgroup_attrs = $SCST->deviceGroupAttributes($dgroup); + my ($dgroup_attrs, $errorString) = $SCST->deviceGroupAttributes($dgroup); my $dgrp_attr_buff; my $dgrp_attr_buff_nk; @@ -1679,7 +1679,7 @@ sub writeConfiguration { foreach my $tgroup (sort keys %{$tgroups}) { $tgroup_buff .= "\tTARGET_GROUP $tgroup"; - my $attributes = $SCST->targetGroupAttributes($dgroup, $tgroup); + my ($attributes, $errorString) = $SCST->targetGroupAttributes($dgroup, $tgroup); my $attribute_buff; my $attribute_buff_nk; @@ -1695,7 +1695,7 @@ sub writeConfiguration { foreach my $tgt (@{$tgts}) { $tgt_buff .= "\t\tTARGET $tgt"; - my $tgt_attrs = $SCST->targetGroupTargetAttributes($dgroup, $tgroup, $tgt); + my ($tgt_attrs, $errorString) = $SCST->targetGroupTargetAttributes($dgroup, $tgroup, $tgt); my $t_attribute_buff = serializeKeyAttr("\t\t\t", $tgt_attrs); @@ -1993,7 +1993,7 @@ sub applyConfigDevices { foreach my $handler (keys %{$handlers}) { foreach my $device (@{$$handlers{$handler}}) { if (!defined($$config{'HANDLER'}->{$handler}->{'DEVICE'}->{$device})) { - my $attributes = $SCST->deviceAttributes($device); + my ($attributes, $errorString) = $SCST->deviceAttributes($device); if ($deletions) { closeDevice($handler, $device, $deletions); @@ -2020,14 +2020,14 @@ sub applyConfigDevices { my $attributes = configToAttr(\%_attributes); my $create_attrs = configToAttr(\%_attributes); - my $possible = $SCST->deviceCreateAttributes($handler); - condExit($SCST->errorString()); + my ($possible, $errorString) = $SCST->deviceCreateAttributes($handler); + condExit($errorString); filterCreateAttributes($possible, $create_attrs, FALSE); filterCreateAttributes($possible, $attributes, TRUE); if (handlerHasDevice($handler, $device)) { - my $old_create_attrs = $SCST->deviceAttributes($device); - condExit($SCST->errorString()); + my ($old_create_attrs, $errorString) = $SCST->deviceAttributes($device); + condExit($errorString); filterCreateAttributes($possible, $old_create_attrs, FALSE); if (compareToKeyAttribute($create_attrs, $old_create_attrs)) { @@ -2106,10 +2106,10 @@ sub applyConfigAssignments { } } else { my $c_attrs = configToAttr($$config{'TARGET_DRIVER'}->{$driver}->{'TARGET'}->{$target}->{'LUN'}->{$lun}->{$device}); - my $o_attrs = $SCST->lunAttributes($driver, $target, $lun); - condExit($SCST->errorString()); - my $possible = $SCST->lunCreateAttributes($driver, $target); - condExit($SCST->errorString()); + my ($o_attrs, $errorString) = $SCST->lunAttributes($driver, $target, $lun); + condExit($errorString); + my ($possible, $errorString) = $SCST->lunCreateAttributes($driver, $target); + condExit($errorString); filterCreateAttributes($possible, $c_attrs, FALSE); @@ -2149,10 +2149,10 @@ sub applyConfigAssignments { } } else { my $c_attrs = configToAttr($$config{'TARGET_DRIVER'}->{$driver}->{'TARGET'}->{$target}->{'GROUP'}->{$group}->{'LUN'}->{$lun}->{$device}); - my $o_attrs = $SCST->lunAttributes($driver, $target, $lun, $group); - condExit($SCST->errorString()); - my $possible = $SCST->lunCreateAttributes($driver, $target, $group); - condExit($SCST->errorString()); + my ($o_attrs, $errorString) = $SCST->lunAttributes($driver, $target, $lun, $group); + condExit($errorString); + my ($possible, $errorString) = $SCST->lunCreateAttributes($driver, $target, $group); + condExit($errorString); filterCreateAttributes($possible, $c_attrs, FALSE); @@ -2233,7 +2233,7 @@ sub applyConfigEnableDrivers { } my $attributes = configToAttr(\%_attributes); - my $d_attributes = $SCST->driverAttributes($driver); + my ($d_attributes, $errorString) = $SCST->driverAttributes($driver); if (defined($$d_attributes{'enabled'}) && ($$d_attributes{'enabled'}->{'value'} != $$attributes{'enabled'})) { @@ -2474,10 +2474,10 @@ sub applyTargetAssignments { my $possible; - my $is_virtual = $SCST->driverIsVirtualCapable($driver); + my ($is_virtual, $errorString) = $SCST->driverIsVirtualCapable($driver); if ($is_virtual) { - $possible = $SCST->targetCreateAttributes($driver); + ($possible, $errorString) = $SCST->targetCreateAttributes($driver); } foreach my $target (sort keys %{$targets}) { @@ -2554,7 +2554,7 @@ sub applyConfigEnableTargets { } my $attributes = configToAttr(\%_attributes); - my $t_attributes = $SCST->targetAttributes($driver, $target); + my ($t_attributes, $errorString) = $SCST->targetAttributes($driver, $target); if (defined($$t_attributes{'enabled'}) && ($$t_attributes{'enabled'}->{'value'} != $$attributes{'enabled'})) { @@ -2713,17 +2713,17 @@ sub clearConfiguration { foreach my $handler (sort keys %{$handlers}) { foreach my $device (@{$$handlers{$handler}}) { - my $attributes = $SCST->deviceAttributes($device); + my ($attributes, $errorString) = $SCST->deviceAttributes($device); closeDevice($handler, $device, TRUE); } } # Todo - check return code - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); foreach my $driver (@{$drivers}) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { disableTarget($driver, $target); @@ -2743,10 +2743,10 @@ sub addVirtualTarget { my $attributes = shift; # Enable all hardware targets before creating virtual ones - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $_target (@{$targets}) { - my $attributes = $SCST->targetAttributes($driver, $_target); + my ($attributes, $errorString) = $SCST->targetAttributes($driver, $_target); if (defined($$attributes{'hw_target'}) && !$$attributes{'enabled'}->{'value'}) { @@ -2779,7 +2779,7 @@ sub listHandlers { return listHandler($handler) if ($handler); - my $handlers = $SCST->handlers(); + my ($handlers, $errorString) = $SCST->handlers(); my $l_handler; foreach my $handler (@{$handlers}) { @@ -2805,7 +2805,7 @@ sub listHandler { my %toprint; my $got_handler = ($handler ne ''); - my $handlers = $SCST->handlers(); + my ($handlers, $errorString) = $SCST->handlers(); my $l_device; my $l_handler; @@ -2818,7 +2818,7 @@ sub listHandler { $l_handler = length($handler) if ($l_handler < length($handler)); - my $devices = $SCST->devicesByHandler($handler); + my ($devices, $errorString) = $SCST->devicesByHandler($handler); if ($#{$devices} == -1) { push @{$devices}, '-'; @@ -2839,7 +2839,7 @@ sub listHandler { print "\n"; foreach my $handler (keys %toprint) { - my $devices = $SCST->devicesByHandler($handler); + my ($devices, $errorString) = $SCST->devicesByHandler($handler); my $first = TRUE; if ($#{$devices} == -1) { @@ -2874,9 +2874,9 @@ sub listDevice { my $device = shift; my $nonkey = shift; - my $attributes = $SCST->deviceAttributes($device); + my ($attributes, $errorString) = $SCST->deviceAttributes($device); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such device '$device' exists.\n"; @@ -2892,7 +2892,7 @@ sub listDeviceGroups { return listDeviceGroup($group) if ($group ne ''); - my $groups = $SCST->deviceGroups(); + my ($groups, $errorString) = $SCST->deviceGroups(); my $l_group; foreach my $group (@{$groups}) { @@ -2919,7 +2919,7 @@ sub listDeviceGroups { sub listDeviceGroup { my $group = shift; - my $devices = $SCST->deviceGroupDevices($group); + my ($devices, $errorString) = $SCST->deviceGroupDevices($group); my $l_device; foreach my $device (@{$devices}) { @@ -2939,7 +2939,7 @@ sub listDeviceGroup { print "\t$device\n"; } - my $tgroups = $SCST->targetGroups($group); + my ($tgroups, $errorString) = $SCST->targetGroups($group); my $l_tgroup; foreach my $tgroup (@{$tgroups}) { @@ -2970,7 +2970,7 @@ sub listTargetGroups { return listDeviceGroups(undef, TRUE) if ($group eq ''); return listTargetGroup($group, $tgroup) if ($tgroup ne ''); - my $tgroups = $SCST->targetGroups($group); + my ($tgroups, $errorString) = $SCST->targetGroups($group); my $l_tgroup; foreach my $tgroup (@{$tgroups}) { @@ -3001,7 +3001,7 @@ sub listTargetGroup { my $group = shift; my $tgroup = shift; - my $targets = $SCST->targetGroupTargets($group, $tgroup); + my ($targets, $errorString) = $SCST->targetGroupTargets($group, $tgroup); my $l_tgt; foreach my $tgt (@{$targets}) { @@ -3030,7 +3030,7 @@ sub listDeviceGroupDevices { return listDevice($device) if ($device ne ''); - my $devices = $SCST->deviceGroupDevices($group); + my ($devices, $errorString) = $SCST->deviceGroupDevices($group); my $l_device; foreach my $device (@{$devices}) { @@ -3058,7 +3058,7 @@ sub listDrivers { return listTargets($driver, undef) if ($driver ne ''); - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); my $l_driver; foreach my $driver (@{$drivers}) { @@ -3088,7 +3088,7 @@ sub listTargets { my $got_driver = ($driver ne ''); - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); my $l_driver; my $l_target; @@ -3101,7 +3101,7 @@ sub listTargets { $l_driver = length($driver) if ($l_driver < length($driver)); - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { $l_target = length($target) if ($l_target < length($target)); @@ -3120,7 +3120,7 @@ sub listTargets { my %p; foreach my $driver (keys %toprint) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { if (!defined($p{$driver})) { @@ -3139,17 +3139,17 @@ sub listTargets { } sub listSessions { - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); foreach my $driver (@{$drivers}) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { my $had_sessions = FALSE; print "Driver/Target: $driver/$target\n\n"; - my $sessions = $SCST->sessions($driver, $target); + my ($sessions, $errorString) = $SCST->sessions($driver, $target); foreach my $session (keys %{$sessions}) { print "\tSession: $session\n\n"; @@ -3187,12 +3187,13 @@ sub listGroup { my $group = shift; my $luns = shift; my $initiators = shift; + my $errorString; - $luns = $SCST->luns($driver, $target, $group) if (!$luns); - $initiators = $SCST->initiators($driver, $target, $group) - if (($initiators eq '') && ($group ne '')); - - return TRUE if issueWarning($SCST->errorString()); + ($luns, $errorString) = $SCST->luns($driver, $target, $group) if (!$luns); + if (($initiators eq '') && ($group ne '')) { + ($initiators, $errorString) = $SCST->initiators($driver, $target, $group); + return TRUE if issueWarning($errorString); + } if ((keys %{$luns}) || ($#{$initiators} > -1)) { my $l_device; @@ -3268,13 +3269,13 @@ sub listGroups { my $got_target = $target; my $got_driver = $driver; - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); foreach my $_driver (@{$drivers}) { $driver = $_driver if (!$got_driver); if ($driver eq $_driver) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $_target (@{$targets}) { $target = $_target if (!$got_target); @@ -3287,7 +3288,7 @@ sub listGroups { print "\n"; - my $groups = $SCST->groups($driver, $target); + my ($groups, $errorString) = $SCST->groups($driver, $target); foreach my $_group (@{$groups}) { $group = $_group if (!$got_group); @@ -3320,10 +3321,12 @@ sub listGroups { sub listExported { my $device = shift; my $attributes = shift; + my $errorString; - $attributes = $SCST->deviceAttributes($device) if (!$attributes); - - return TRUE if issueWarning($SCST->errorString()); + if (!$attributes) { + ($attributes, $errorString) = $SCST->deviceAttributes($device) ; + return TRUE if issueWarning($errorString); + } if (keys %{$$attributes{'exported'}}) { my $exported = $$attributes{'exported'}->{'value'}; @@ -3491,9 +3494,9 @@ sub listAttributes { sub listScstAttributes { my $nonkey = shift; - my $attributes = $SCST->scstAttributes(); + my ($attributes, $errorString) = $SCST->scstAttributes(); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "FATAL: Unable to get a list of SCST attributes! Please make sure SCST is loaded.\n"; @@ -3507,9 +3510,9 @@ sub listHandlerAttributes { my $handler = shift; my $nonkey = shift; - my $attributes = $SCST->handlerAttributes($handler); + my ($attributes, $errorString) = $SCST->handlerAttributes($handler); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such handler '$handler' found.\n"; @@ -3519,9 +3522,9 @@ sub listHandlerAttributes { my $rc = listAttributes($attributes, $nonkey); return $rc if $rc; - $attributes = $SCST->deviceCreateAttributes($handler); + ($attributes, $errorString) = $SCST->deviceCreateAttributes($handler); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return TRUE if (!scalar keys %{$attributes}); print "\n\tDevice CREATE attributes available\n"; @@ -3538,16 +3541,16 @@ sub listDriverAttributes { my $driver = shift; my $nonkey = shift; - my $attributes = $SCST->driverAttributes($driver); + my ($attributes, $errorString) = $SCST->driverAttributes($driver); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); my $rc = listAttributes($attributes, $nonkey); return $rc if ($rc); if ($SCST->driverIsVirtualCapable($driver)) { - $attributes = $SCST->driverDynamicAttributes($driver); - return TRUE if issueWarning($SCST->errorString()); + ($attributes, $errorString) = $SCST->driverDynamicAttributes($driver); + return TRUE if issueWarning($errorString); if (scalar keys %{$attributes}) { print "\n\tDynamic attributes available\n"; @@ -3558,9 +3561,9 @@ sub listDriverAttributes { } } - my $attributes = $SCST->targetCreateAttributes($driver); + my ($attributes, $errorString) = $SCST->targetCreateAttributes($driver); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return TRUE if (!scalar keys %{$attributes}); print "\n\tTarget CREATE attributes available:\n"; @@ -3579,9 +3582,9 @@ sub listTargetAttributes { my $target = shift; my $nonkey = shift; - my $attributes = $SCST->targetAttributes($driver, $target); + my ($attributes, $errorString) = $SCST->targetAttributes($driver, $target); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such driver/target '$driver/$target' found.\n"; @@ -3592,8 +3595,8 @@ sub listTargetAttributes { return $rc if $rc; if ($SCST->driverIsVirtualCapable($driver)) { - $attributes = $SCST->targetDynamicAttributes($driver); - return TRUE if issueWarning($SCST->errorString()); + ($attributes, $errorString) = $SCST->targetDynamicAttributes($driver); + return TRUE if issueWarning($errorString); if (scalar keys %{$attributes}) { print "\n\tDynamic attributes available\n"; @@ -3605,9 +3608,9 @@ sub listTargetAttributes { } } - $attributes = $SCST->lunCreateAttributes($driver, $target); + ($attributes, $errorString) = $SCST->lunCreateAttributes($driver, $target); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return TRUE if (!scalar keys %{$attributes}); print "\n\tLUN CREATE attributes available\n"; @@ -3626,9 +3629,9 @@ sub listGroupAttributes { my $group = shift; my $nonkey = shift; - my $attributes = $SCST->groupAttributes($driver, $target, $group); + my ($attributes, $errorString) = $SCST->groupAttributes($driver, $target, $group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such driver/target/group '$driver/$target/$group' found.\n"; @@ -3638,9 +3641,9 @@ sub listGroupAttributes { my $rc = listAttributes($attributes, $nonkey); return $rc if $rc; - $attributes = $SCST->lunCreateAttributes($driver, $target, $group); + ($attributes, $errorString) = $SCST->lunCreateAttributes($driver, $target, $group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return TRUE if (!scalar keys %{$attributes}); print "\n\tLUN CREATE attributes available\n"; @@ -3650,9 +3653,9 @@ sub listGroupAttributes { print "\t$attribute\n"; } - $attributes = $SCST->initiatorCreateAttributes($driver, $target, $group); + ($attributes, $errorString) = $SCST->initiatorCreateAttributes($driver, $target, $group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return TRUE if (!scalar keys %{$attributes}); print "\n\tInitiator CREATE attributes available\n"; @@ -3672,9 +3675,9 @@ sub listLunAttributes { my $lun = shift; my $nonkey = shift; - my $attributes = $SCST->lunAttributes($driver, $target, $lun, $group); + my ($attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun, $group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { if ($group ne '') { @@ -3695,16 +3698,16 @@ sub listInitiatorAttributes { my $initiator = shift; my $nonkey = shift; - my $attributes = $SCST->initiatorAttributes($driver, $target, $group, $initiator); + my ($attributes, $errorString) = $SCST->initiatorAttributes($driver, $target, $group, $initiator); # As if writing, initiators didn't have attributes. This will # allow us to support it in the future. - if ($SCST->errorString() =~ /Not a directory/) { + if ($errorString =~ /Not a directory/) { print "Initiators do not (yet) have attributes.\n"; return; } - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such driver/target/group/initiator '$driver/$target/$group/$initiator' found.\n"; @@ -3718,9 +3721,9 @@ sub listDeviceGroupAttributes { my $group = shift; my $nonkey = shift; - my $attributes = $SCST->deviceGroupAttributes($group); + my ($attributes, $errorString) = $SCST->deviceGroupAttributes($group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); # Special case - as of writing, device group attributes didn't exist. if (!scalar(keys %{$attributes})) { @@ -3736,9 +3739,9 @@ sub listTargetGroupAttributes { my $tgroup = shift; my $nonkey = shift; - my $attributes = $SCST->targetGroupAttributes($group, $tgroup); + my ($attributes, $errorString) = $SCST->targetGroupAttributes($group, $tgroup); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such device group/target group '$group/$tgroup' found.\n"; @@ -3754,9 +3757,9 @@ sub listTargetGroupTargetAttributes { my $tgt = shift; my $nonkey = shift; - my $attributes = $SCST->targetGroupTargetAttributes($group, $tgroup, $tgt, TRUE); + my ($attributes, $errorString) = $SCST->targetGroupTargetAttributes($group, $tgroup, $tgt, TRUE); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); if (!scalar(keys %{$attributes})) { print "No such device group/target group/target '$group/$tgroup/$tgt' found.\n"; @@ -3788,9 +3791,9 @@ sub setScstAttributes { my $showset = shift; my $error = "\t-> WARNING: SCST lacks the settable attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->scstAttributes(); + my ($_attributes, $errorString) = $SCST->scstAttributes(); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, undef, undef, undef, $attributes, $_attributes, $error, \&setScstAttribute, $showset); @@ -3818,9 +3821,9 @@ sub setDeviceAttributes { my $error = "\t-> WARNING: Device '$device' lacks the settable ". "attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->deviceAttributes($device); + my ($_attributes, $errorString) = $SCST->deviceAttributes($device); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, undef, undef, $device, $attributes, $_attributes, $error, \&setDeviceAttribute, $showset); @@ -3848,9 +3851,9 @@ sub setHandlerAttributes { my $error = "\t-> WARNING: Handler '$handler' lacks the settable ". "attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->handlerAttributes($handler); + my ($_attributes, $errorString) = $SCST->handlerAttributes($handler); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, undef, undef, $handler, $attributes, $_attributes, $error, \&setHandlerAttribute, $showset); @@ -3881,9 +3884,9 @@ sub setGroupAttributes { my $error = "\t-> WARNING: Driver/target/group '$driver/$target/$group' lacks the settable ". "attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->groupAttributes($driver, $target, $group); + my ($_attributes, $errorString) = $SCST->groupAttributes($driver, $target, $group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, $driver, $target, $group, $attributes, $_attributes, $error, \&setGroupAttribute, $showset); @@ -3928,9 +3931,9 @@ sub setLunAttributes { "attribute '%s', ignoring.\n\n"; } - my $_attributes = $SCST->lunAttributes($driver, $target, $lun, $group); + my ($_attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun, $group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes($driver, $target, $lun, $group, $attributes, $_attributes, $error, \&setLunAttribute, $showset); @@ -3961,13 +3964,13 @@ sub setInitiatorAttributes { my $attributes = shift; my $showset = shift; - my $_attributes = $SCST->initiatorAttributes($driver, $target, $group, $initiator); + my ($_attributes, $errorString) = $SCST->initiatorAttributes($driver, $target, $group, $initiator); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); # As if writing, initiators didn't have attributes. This will # allow us to support it in the future. - if ($SCST->errorString() =~ /Not a directory/) { + if ($errorString =~ /Not a directory/) { print "Initiators do not (yet) have attributes.\n"; return; } @@ -3985,9 +3988,9 @@ sub setAluaAttributes { my $error = "\t-> WARNING: no settable ALUA attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->aluaAttributes(); + my ($_attributes, $errorString) = $SCST->aluaAttributes(); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, undef, undef, undef, $attributes, $_attributes, $error, \&setAluaAttribute, $showset); @@ -4015,9 +4018,9 @@ sub setDeviceGroupAttributes { my $error = "\t-> WARNING: Device Group '$group' lacks the settable attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->deviceGroupAttributes($group); + my ($_attributes, $errorString) = $SCST->deviceGroupAttributes($group); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, undef, undef, $group, $attributes, $_attributes, $error, \&setDeviceGroupAttribute, $showset); @@ -4048,9 +4051,9 @@ sub setTargetGroupAttributes { my $error = "\t-> WARNING: Target Group '$group/$tgroup' lacks the settable attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->targetGroupAttributes($group, $tgroup); + my ($_attributes, $errorString) = $SCST->targetGroupAttributes($group, $tgroup); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, undef, $group, $tgroup, $attributes, $_attributes, $error, \&setTargetGroupAttribute, $showset); @@ -4082,9 +4085,9 @@ sub setTargetGroupTargetAttributes { my $error = "\t-> WARNING: Target '$group/$tgroup/$tgt' lacks the settable attribute '%s', ignoring.\n\n"; - my $_attributes = $SCST->targetGroupTargetAttributes($group, $tgroup, $tgt, TRUE); + my ($_attributes, $errorString) = $SCST->targetGroupTargetAttributes($group, $tgroup, $tgt, TRUE); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); return setAttributes(undef, $group, $tgroup, $tgt, $attributes, $_attributes, $error, \&setTargetGroupTargetAttribute, $showset); @@ -4184,9 +4187,9 @@ sub setDriverAttributes { my $changes = 0; my $driverCap = $SCST->driverIsVirtualCapable($driver); - my $_attributes = $SCST->driverAttributes($driver); + my ($_attributes, $errorString) = $SCST->driverAttributes($driver); - return 0 if issueWarning($SCST->errorString()); + return 0 if issueWarning($errorString); # build caches for easier matching foreach my $attribute (keys %{$attributes}) { @@ -4257,9 +4260,9 @@ sub addDriverDynamicAttributes { my $driver = shift; my $attributes = shift; - my $_attributes = $SCST->driverAttributes($driver); + my ($_attributes, $errorString) = $SCST->driverAttributes($driver); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); my $existing = cacheAttributes($_attributes); @@ -4294,9 +4297,9 @@ sub removeDriverDynamicAttributes { my $driver = shift; my $attributes = shift; - my $_attributes = $SCST->driverAttributes($driver); + my ($_attributes, $errorString) = $SCST->driverAttributes($driver); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); my $existing = cacheAttributes($_attributes); @@ -4360,9 +4363,9 @@ sub setTargetAttributes { my $changes = 0; my $driverCap = $SCST->driverIsVirtualCapable($driver); - my $_attributes = $SCST->targetAttributes($driver, $target); + my ($_attributes, $errorString) = $SCST->targetAttributes($driver, $target); - return 0 if issueWarning($SCST->errorString()); + return 0 if issueWarning($errorString); # build caches for easier matching foreach my $attribute (keys %{$attributes}) { @@ -4436,9 +4439,9 @@ sub addTargetDynamicAttributes { my $target = shift; my $attributes = shift; - my $_attributes = $SCST->targetAttributes($driver, $target); + my ($_attributes, $errorString) = $SCST->targetAttributes($driver, $target); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); my $existing = cacheAttributes($_attributes); @@ -4477,9 +4480,9 @@ sub removeTargetDynamicAttributes { my $target = shift; my $attributes = shift; - my $_attributes = $SCST->targetAttributes($driver, $target); + my ($_attributes, $errorString) = $SCST->targetAttributes($driver, $target); - return TRUE if issueWarning($SCST->errorString()); + return TRUE if issueWarning($errorString); my $existing = cacheAttributes($_attributes); @@ -4537,7 +4540,7 @@ sub closeDevice { my $device = shift; my $force = shift; - my $attributes = $SCST->deviceAttributes($device); + my ($attributes, $errorString) = $SCST->deviceAttributes($device); if (!$force) { if (keys %{$$attributes{'exported'}}) { @@ -4617,8 +4620,8 @@ sub removeDeviceGroup { my $force = shift; if (!$force) { - my $devices = $SCST->deviceGroupDevices($group); - my $tgroups = $SCST->targetGroups($group); + my ($devices, $errorString) = $SCST->deviceGroupDevices($group); + my ($tgroups, $errorString) = $SCST->targetGroups($group); if (($#{$devices} > -1) || ($#{$tgroups} > -1)) { print "\n"; @@ -4644,7 +4647,7 @@ sub removeTargetGroup { my $force = shift; if (!$force) { - my $tgts = $SCST->targetGroupTargets($group, $tgroup); + my ($tgts, $errorString) = $SCST->targetGroupTargets($group, $tgroup); if ($#{$tgts} > -1) { print "\n"; @@ -4703,10 +4706,10 @@ sub removeDeviceGroupDevice { if (!$force) { my $found = FALSE; - my $tgroups = $SCST->targetGroups($group); + my ($tgroups, $errorString) = $SCST->targetGroups($group); foreach my $tgroup (@{$tgroups}) { - my $targets = $SCST->targetGroupTargets($group, $tgroup); + my ($targets, $errorString) = $SCST->targetGroupTargets($group, $tgroup); if ($#{$targets} > -1) { print "\n"; @@ -4756,8 +4759,8 @@ sub removeGroup { my $force = shift; if (!$force) { - my $luns = $SCST->luns($driver, $target, $group); - my $initiators = $SCST->initiators($driver, $target, $group); + my ($luns, $errorString) = $SCST->luns($driver, $target, $group); + my ($initiators, $errorString) = $SCST->initiators($driver, $target, $group); if ((keys %{$luns}) || ($#{$initiators} > -1)) { listGroup($driver, $target, $group, $luns, $initiators); @@ -4959,8 +4962,8 @@ sub clearDriverDynamicAttributes { print "\t-> Removing all dynamic attributes from driver '$driver': "; - my $attributes = $SCST->driverAttributes($driver); - my $dynamic = $SCST->driverDynamicAttributes($driver); + my ($attributes, $errorString) = $SCST->driverAttributes($driver); + my ($dynamic, $errorString) = $SCST->driverDynamicAttributes($driver); foreach my $attribute (keys %{$attributes}) { if (defined($$dynamic{$attribute})) { @@ -4988,8 +4991,8 @@ sub clearTargetDynamicAttributes { print "\t-> Removing all dynamic attributes from driver/target '$driver/$target': "; - my $attributes = $SCST->targetAttributes($driver, $target); - my $dynamic = $SCST->targetDynamicAttributes($driver); + my ($attributes, $errorString) = $SCST->targetAttributes($driver, $target); + my ($dynamic, $errorString) = $SCST->targetDynamicAttributes($driver); foreach my $attribute (keys %{$attributes}) { if (defined($$dynamic{$attribute})) { @@ -5035,7 +5038,7 @@ sub enableDriver { my $driver = shift; my %attributes = ('enabled', 1); - my $attrs = $SCST->driverAttributes($driver); + my ($attrs, $errorString) = $SCST->driverAttributes($driver); return TRUE if (!defined($$attrs{'enabled'})); return setDriverAttributes($driver, \%attributes); @@ -5045,7 +5048,7 @@ sub disableDriver { my $driver = shift; my %attributes = ('enabled', 0); - my $attrs = $SCST->driverAttributes($driver); + my ($attrs, $errorString) = $SCST->driverAttributes($driver); return TRUE if (!defined($$attrs{'enabled'})); return setDriverAttributes($driver, \%attributes); @@ -5059,10 +5062,10 @@ sub issueLip { if (defined($driver) && defined($target)) { return _issueLip($driver, $target, $warn); } else { - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); foreach my $driver(@{$drivers}) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { my $rc = _issueLip($driver, $target, $warn); @@ -5081,7 +5084,7 @@ sub _issueLip { my $warn = shift; my $rc = FALSE; - my $attributes = $SCST->targetAttributes($driver, $target); + my ($attributes, $errorString) = $SCST->targetAttributes($driver, $target); if (!defined($$attributes{'host'}) && $warn) { print "\t-> Driver/target '$driver/$target' has no 'host' attribute, ignoring.\n"; @@ -5330,7 +5333,7 @@ sub readOldConfigFile { } } - my $drivers = $SCST->drivers(); + my ($drivers, $errorString) = $SCST->drivers(); my %added_targets; # Handle default groups @@ -5342,7 +5345,7 @@ sub readOldConfigFile { my($device, $lun) = split(/\,/, $device); foreach my $driver (@{$drivers}) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { $new{'TARGET_DRIVER'}->{$driver}->{'TARGET'}->{$target}->{'LUN'}->{$lun}->{$device} = {}; @@ -5355,7 +5358,7 @@ sub readOldConfigFile { my $found_t = FALSE; # Find the associated target foreach my $driver (@{$drivers}) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { if ($target eq $group_t) { @@ -5407,7 +5410,7 @@ sub readOldConfigFile { # Fill in with known targets, all disabled. foreach my $driver (@{$drivers}) { - my $targets = $SCST->targets($driver); + my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { addAllGroupsToTarget(\%config, \%new, $driver, $target); @@ -5426,7 +5429,7 @@ sub readOldConfigFile { foreach my $driver (keys %{$new{'TARGET_DRIVER'}}) { next if ($driver =~ /^qla/); - my $attributes = $SCST->driverAttributes($driver); + my ($attributes, $errorString) = $SCST->driverAttributes($driver); if (defined($$attributes{'enabled'})) { $new{'TARGET_DRIVER'}->{$driver}->{'enabled'}->{'1'} = {};