From b2119c2133e98811836e93be2f65bc3aa7899e96 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 16 Feb 2019 17:15:45 +0000 Subject: [PATCH] scstadmin: Sort output of -list_* options alphabetically Making the output of these options predictable is necessary because a later patch will add regression tests for the -list_* options. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7930 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scst-1.0.0/lib/SCST/SCST.pm | 3 +++ scstadmin/scstadmin.sysfs/scstadmin | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index e73570395..be4576410 100644 --- a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -556,6 +556,7 @@ sub drivers { push @drivers, $driver; } } + @drivers = sort(@drivers); close $dHandle; } else { return (undef, "drivers(): Unable to read directory '$_path': $!"); @@ -3834,6 +3835,8 @@ sub handlers { close $hHandle; + @handlers = sort(@handlers); + return (\@handlers, undef); } diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 078602551..51947df28 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -3062,7 +3062,7 @@ sub listHandler { }; print "\n"; - foreach my $handler (keys %toprint) { + foreach my $handler (sort keys %toprint) { my ($devices, $errorString) = $SCST->devicesByHandler($handler); my $first = TRUE; @@ -3070,7 +3070,7 @@ sub listHandler { push @{$devices}, '-'; } - foreach my $device (@{$devices}) { + foreach my $device (sort @{$devices}) { if ($first) { printf("\t%-*s %-*s\n", $l_handler, $handler, $l_device, $device); $first = FALSE; @@ -3343,7 +3343,7 @@ sub listTargets { my %p; - foreach my $driver (keys %toprint) { + foreach my $driver (sort keys %toprint) { my ($targets, $errorString) = $SCST->targets($driver); foreach my $target (@{$targets}) { @@ -3739,7 +3739,7 @@ sub listHandlerAttributes { print "\n\tDevice CREATE attributes available\n"; print "\t----------------------------------\n"; - foreach my $attribute (keys %{$attributes}) { + foreach my $attribute (sort keys %{$attributes}) { print "\t$attribute\n"; } @@ -3765,7 +3765,7 @@ sub listDriverAttributes { print "\n\tDynamic attributes available\n"; print "\t----------------------------\n"; - foreach my $attribute (keys %{$attributes}) { + foreach my $attribute (sort keys %{$attributes}) { print "\t$attribute\n"; } } @@ -3778,7 +3778,7 @@ sub listDriverAttributes { print "\n\tTarget CREATE attributes available:\n"; print "\t-----------------------------------\n"; - foreach my $attribute (keys %{$attributes}) { + foreach my $attribute (sort keys %{$attributes}) { print "\t$attribute\n"; } } @@ -3811,7 +3811,7 @@ sub listTargetAttributes { print "\n\tDynamic attributes available\n"; print "\t----------------------------\n"; - foreach my $attribute (keys %{$attributes}) { + foreach my $attribute (sort keys %{$attributes}) { print "\t$attribute\n"; } } @@ -3825,7 +3825,7 @@ sub listTargetAttributes { print "\n\tLUN CREATE attributes available\n"; print "\t-------------------------------\n"; - foreach my $attribute (keys %{$attributes}) { + foreach my $attribute (sort keys %{$attributes}) { print "\t$attribute\n"; } @@ -3858,7 +3858,7 @@ sub listGroupAttributes { print "\n\tLUN CREATE attributes available\n"; print "\t-------------------------------\n"; - foreach my $attribute (keys %{$attributes}) { + foreach my $attribute (sort keys %{$attributes}) { print "\t$attribute\n"; }