From 5d6b0142a8223ff36d6dfde38c6ff2ded0d1cbb4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 30 Jul 2013 10:49:02 +0000 Subject: [PATCH] scstadmin: Fix parsing names of multi-valued attributes When defining e.g. more than ten CHAP users in scst.conf, scstadmin only saves the first then CHAP users. Make sure that scstadmin saves all information defined in sysfs. Reported-by: Artur Piechocki git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4928 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scst-0.9.10/lib/SCST/SCST.pm | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) 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 7f273a253..d9354ee91 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 @@ -464,9 +464,9 @@ sub scstAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -2655,9 +2655,9 @@ sub deviceAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -2738,9 +2738,9 @@ sub driverAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -2901,9 +2901,9 @@ sub targetAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3046,9 +3046,9 @@ sub groupAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3217,9 +3217,9 @@ sub lunAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3374,9 +3374,9 @@ sub initiatorAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3502,9 +3502,9 @@ sub deviceGroupAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3583,9 +3583,9 @@ sub targetGroupAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3675,9 +3675,9 @@ sub targetGroupTargetAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } } @@ -3954,9 +3954,9 @@ sub handlerAttributes { my $key = 0; if ($is_key) { - if ($attribute =~ /.*(\d+)$/) { - $key = $1; - $attribute =~ s/\d+$//; + if ($attribute =~ /^([^\d]+)(\d+)$/) { + $attribute = $1; + $key = $2; } }