mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-17 12:46:27 +00:00
scstadmin: Improve robustness
Instead of only interpreting the empty string as "no argument passed", also consider 'undef' as "no argument passed". git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8905 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -1497,7 +1497,7 @@ sub serializeKeyAttr {
|
|||||||
foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) {
|
foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) {
|
||||||
my $value =
|
my $value =
|
||||||
$$attributes{$attribute}->{'keys'}->{$key}->{'value'};
|
$$attributes{$attribute}->{'keys'}->{$key}->{'value'};
|
||||||
push (@values, $value) if ($value ne '');
|
push (@values, $value) if ($value);
|
||||||
}
|
}
|
||||||
foreach my $value (sort @values) {
|
foreach my $value (sort @values) {
|
||||||
$result .= "$prefix$attribute " . escapeMeta($value) . "\n";
|
$result .= "$prefix$attribute " . escapeMeta($value) . "\n";
|
||||||
@@ -1532,7 +1532,7 @@ sub serializeNkAttr {
|
|||||||
&& $attribute ne 'enabled'
|
&& $attribute ne 'enabled'
|
||||||
&& $attribute ne 'hw_target') {
|
&& $attribute ne 'hw_target') {
|
||||||
my $value = $$attributes{$attribute}->{'value'};
|
my $value = $$attributes{$attribute}->{'value'};
|
||||||
if ($value ne '') {
|
if ($value) {
|
||||||
$result .= "$prefix$attribute " . escapeMeta($value) . "\n";
|
$result .= "$prefix$attribute " . escapeMeta($value) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3140,7 +3140,7 @@ sub listDevices {
|
|||||||
my $device = shift;
|
my $device = shift;
|
||||||
my $nonkey = shift;
|
my $nonkey = shift;
|
||||||
|
|
||||||
return listDevice($device, $nonkey) if ($device ne '');
|
return listDevice($device, $nonkey) if ($device);
|
||||||
return listHandler();
|
return listHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3164,7 +3164,7 @@ sub listDeviceGroups {
|
|||||||
my $group = shift;
|
my $group = shift;
|
||||||
my $showall = shift;
|
my $showall = shift;
|
||||||
|
|
||||||
return listDeviceGroup($group) if ($group ne '');
|
return listDeviceGroup($group) if ($group);
|
||||||
|
|
||||||
my ($groups, $errorString) = $SCST->deviceGroups();
|
my ($groups, $errorString) = $SCST->deviceGroups();
|
||||||
|
|
||||||
@@ -3244,7 +3244,7 @@ sub listTargetGroups {
|
|||||||
my $indent = shift;
|
my $indent = shift;
|
||||||
|
|
||||||
return listDeviceGroups(undef, TRUE) if ($group eq '');
|
return listDeviceGroups(undef, TRUE) if ($group eq '');
|
||||||
return listTargetGroup($group, $tgroup) if ($tgroup ne '');
|
return listTargetGroup($group, $tgroup) if ($tgroup);
|
||||||
|
|
||||||
my ($tgroups, $errorString) = $SCST->targetGroups($group);
|
my ($tgroups, $errorString) = $SCST->targetGroups($group);
|
||||||
|
|
||||||
@@ -3304,7 +3304,7 @@ sub listDeviceGroupDevices {
|
|||||||
my $group = shift;
|
my $group = shift;
|
||||||
my $device = shift;
|
my $device = shift;
|
||||||
|
|
||||||
return listDevice($device) if ($device ne '');
|
return listDevice($device) if ($device);
|
||||||
|
|
||||||
my ($devices, $errorString) = $SCST->deviceGroupDevices($group);
|
my ($devices, $errorString) = $SCST->deviceGroupDevices($group);
|
||||||
|
|
||||||
@@ -3332,7 +3332,7 @@ sub listDeviceGroupDevices {
|
|||||||
sub listDrivers {
|
sub listDrivers {
|
||||||
my $driver = shift;
|
my $driver = shift;
|
||||||
|
|
||||||
return listTargets($driver, undef) if ($driver ne '');
|
return listTargets($driver, undef) if ($driver);
|
||||||
|
|
||||||
my ($drivers, $errorString) = $SCST->drivers();
|
my ($drivers, $errorString) = $SCST->drivers();
|
||||||
|
|
||||||
@@ -3360,7 +3360,7 @@ sub listTargets {
|
|||||||
my $target = shift;
|
my $target = shift;
|
||||||
my %toprint;
|
my %toprint;
|
||||||
|
|
||||||
return listGroups($driver, $target, undef) if (($target ne '') && ($driver ne ''));
|
return listGroups($driver, $target, undef) if ($target and $driver);
|
||||||
|
|
||||||
my $got_driver = defined($driver);
|
my $got_driver = defined($driver);
|
||||||
|
|
||||||
@@ -3539,7 +3539,7 @@ sub listGroups {
|
|||||||
my $group = shift;
|
my $group = shift;
|
||||||
my $found = FALSE;
|
my $found = FALSE;
|
||||||
|
|
||||||
if (($group ne '') && ($driver ne '') && ($target ne '')) {
|
if ($group and $driver and $target) {
|
||||||
return listGroup($driver, $target, $group);
|
return listGroup($driver, $target, $group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3948,7 +3948,7 @@ sub listLunAttributes {
|
|||||||
return TRUE if issueWarning($errorString);
|
return TRUE if issueWarning($errorString);
|
||||||
|
|
||||||
if (!scalar(keys %{$attributes})) {
|
if (!scalar(keys %{$attributes})) {
|
||||||
if ($group ne '') {
|
if ($group) {
|
||||||
print "No such driver/target/group/lun '$driver/$target/$group/$lun' found.\n";
|
print "No such driver/target/group/lun '$driver/$target/$group/$lun' found.\n";
|
||||||
} else {
|
} else {
|
||||||
print "No such driver/target/lun '$driver/$target/$lun' found.\n";
|
print "No such driver/target/lun '$driver/$target/$lun' found.\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user