From: <mga...@us...> - 2010-12-07 17:40:23
|
Revision: 2968 http://scst.svn.sourceforge.net/scst/?rev=2968&view=rev Author: mgandalf Date: 2010-12-07 17:40:16 +0000 (Tue, 07 Dec 2010) Log Message: ----------- - Hopefully fix all remaining exit code issues. - Better fix for empty groups - don't write empty braces. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2010-12-07 17:35:16 UTC (rev 2967) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2010-12-07 17:40:16 UTC (rev 2968) @@ -1405,8 +1405,9 @@ } } - $group_buff .= " {\n"; if ($lun_buff || $init_buff) { + $group_buff .= " {\n"; + if ($lun_buff) { $group_buff .= $lun_buff; } @@ -1456,7 +1457,8 @@ $group_buff .= $g_attribute_buff; } - if ($group_buff) { + if ($group_buff && ($lun_buff || $init_buff || + $g_attribute_buff || $g_attribute_buff_nk)) { $group_buff .= "\t\t}\n\n"; $group_buff =~ s/\n+$/\n/; } @@ -1694,7 +1696,7 @@ print "\t-> Done, $changes change(s) made.\n"; - return 0; + return FALSE; } sub applyConfigDevices { @@ -1901,7 +1903,7 @@ } } - return if ($only_del); + return $changes if ($only_del); $assignments = $$config{'TARGET_DRIVER'}; @@ -2254,6 +2256,8 @@ } print "\t-> Configuration cleared.\n"; + + return FALSE; } sub addVirtualTarget { @@ -2303,6 +2307,8 @@ foreach my $handler (@{$handlers}) { print "\t$handler\n"; } + + return FALSE; } sub listHandler { @@ -2363,6 +2369,8 @@ } else { print "No such handler '$handler' found.\n"; } + + return FALSE; } sub listDevices { @@ -2379,7 +2387,7 @@ my $attributes = $SCST->deviceAttributes($device); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "No such device '$device' exists.\n"; @@ -2411,6 +2419,8 @@ foreach my $driver (@{$drivers}) { print "\t$driver\n"; } + + return FALSE; } sub listTargets { @@ -2468,6 +2478,8 @@ } else { print "No such driver '$driver' exists.\n"; } + + return FALSE; } sub listSessions { @@ -2509,6 +2521,8 @@ } } } + + return FALSE; } sub listGroup { @@ -2522,7 +2536,7 @@ $initiators = $SCST->initiators($driver, $target, $group) if (($initiators eq '') && ($group ne '')); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if ((keys %{$luns}) || ($#{$initiators} > -1)) { my $l_device; @@ -2581,6 +2595,7 @@ } } + return FALSE; } sub listGroups { @@ -2642,6 +2657,8 @@ print "Target '$target' not found.\n"; } } + + return FALSE; } sub listExported { @@ -2650,7 +2667,7 @@ $attributes = $SCST->deviceAttributes($device) if (!$attributes); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (keys %{$$attributes{'exported'}}) { my $exported = $$attributes{'exported'}->{'value'}; @@ -2695,6 +2712,8 @@ } else { print "Device '$device' is not currently in use by any group.\n"; } + + return FALSE; } sub listAttributes { @@ -2809,6 +2828,8 @@ print "\n"; } + + return FALSE; } sub listScstAttributes { @@ -2816,7 +2837,7 @@ my $attributes = $SCST->scstAttributes(); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "FATAL: Unable to get a list of SCST attributes! Please make sure SCST is loaded.\n"; @@ -2832,7 +2853,7 @@ my $attributes = $SCST->handlerAttributes($handler); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "No such handler '$handler' found.\n"; @@ -2844,8 +2865,8 @@ $attributes = $SCST->deviceCreateAttributes($handler); - return if issueWarning($SCST->errorString()); - return if (!scalar keys %{$attributes}); + return TRUE if issueWarning($SCST->errorString()); + return TRUE if (!scalar keys %{$attributes}); print "\n\tDevice CREATE attributes available\n"; print "\t----------------------------------\n"; @@ -2853,6 +2874,8 @@ foreach my $attribute (keys %{$attributes}) { print "\t$attribute\n"; } + + return FALSE; } sub listDriverAttributes { @@ -2861,7 +2884,7 @@ my $attributes = $SCST->driverAttributes($driver); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "No such driver '$driver' found.\n"; @@ -2873,7 +2896,7 @@ if ($SCST->driverIsVirtualCapable($driver)) { $attributes = $SCST->driverDynamicAttributes($driver); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (scalar keys %{$attributes}) { print "\n\tDynamic attributes available\n"; @@ -2886,8 +2909,8 @@ my $attributes = $SCST->targetCreateAttributes($driver); - return if issueWarning($SCST->errorString()); - return if (!scalar keys %{$attributes}); + return TRUE if issueWarning($SCST->errorString()); + return TRUE if (!scalar keys %{$attributes}); print "\n\tTarget CREATE attributes available:\n"; print "\t-----------------------------------\n"; @@ -2896,6 +2919,8 @@ print "\t$attribute\n"; } } + + return FALSE; } sub listTargetAttributes { @@ -2905,7 +2930,7 @@ my $attributes = $SCST->targetAttributes($driver, $target); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "No such driver/target '$driver/$target' found.\n"; @@ -2917,7 +2942,7 @@ if ($SCST->driverIsVirtualCapable($driver)) { $attributes = $SCST->targetDynamicAttributes($driver); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (scalar keys %{$attributes}) { print "\n\tDynamic attributes available\n"; @@ -2931,8 +2956,8 @@ $attributes = $SCST->lunCreateAttributes($driver, $target); - return if issueWarning($SCST->errorString()); - return if (!scalar keys %{$attributes}); + return TRUE if issueWarning($SCST->errorString()); + return TRUE if (!scalar keys %{$attributes}); print "\n\tLUN CREATE attributes available\n"; print "\t-------------------------------\n"; @@ -2940,6 +2965,8 @@ foreach my $attribute (keys %{$attributes}) { print "\t$attribute\n"; } + + return FALSE; } sub listGroupAttributes { @@ -2950,7 +2977,7 @@ my $attributes = $SCST->groupAttributes($driver, $target, $group); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "No such driver/target/group '$driver/$target/$group' found.\n"; @@ -2962,8 +2989,8 @@ $attributes = $SCST->lunCreateAttributes($driver, $target, $group); - return if issueWarning($SCST->errorString()); - return if (!scalar keys %{$attributes}); + return TRUE if issueWarning($SCST->errorString()); + return TRUE if (!scalar keys %{$attributes}); print "\n\tLUN CREATE attributes available\n"; print "\t-------------------------------\n"; @@ -2974,8 +3001,8 @@ $attributes = $SCST->initiatorCreateAttributes($driver, $target, $group); - return if issueWarning($SCST->errorString()); - return if (!scalar keys %{$attributes}); + return TRUE if issueWarning($SCST->errorString()); + return TRUE if (!scalar keys %{$attributes}); print "\n\tInitiator CREATE attributes available\n"; print "\t-------------------------------------\n"; @@ -2983,6 +3010,8 @@ foreach my $attribute (keys %{$attributes}) { print "\t$attribute\n"; } + + return FALSE; } sub listLunAttributes { @@ -2994,7 +3023,7 @@ my $attributes = $SCST->lunAttributes($driver, $target, $lun, $group); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { if ($group ne '') { @@ -3024,7 +3053,7 @@ return; } - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); if (!scalar(keys %{$attributes})) { print "No such driver/target/group/initiator '$driver/$target/$group/$initiator' found.\n"; @@ -3058,7 +3087,7 @@ my $error = "\t-> WARNING: SCST lacks the settable attribute '%s', ignoring.\n\n"; my $_attributes = $SCST->scstAttributes(); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); return setAttributes(undef, undef, undef, undef, $attributes, $_attributes, $error, \&setScstAttribute, $showset); @@ -3088,7 +3117,7 @@ "attribute '%s', ignoring.\n\n"; my $_attributes = $SCST->deviceAttributes($device); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); return setAttributes(undef, undef, undef, $device, $attributes, $_attributes, $error, \&setDeviceAttribute, $showset); @@ -3118,7 +3147,7 @@ "attribute '%s', ignoring.\n\n"; my $_attributes = $SCST->handlerAttributes($handler); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); return setAttributes(undef, undef, undef, $handler, $attributes, $_attributes, $error, \&setHandlerAttribute, $showset); @@ -3151,7 +3180,7 @@ "attribute '%s', ignoring.\n\n"; my $_attributes = $SCST->groupAttributes($driver, $target, $group); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); return setAttributes(undef, $driver, $target, $group, $attributes, $_attributes, $error, \&setGroupAttribute, $showset); @@ -3198,7 +3227,7 @@ my $_attributes = $SCST->lunAttributes($driver, $target, $lun, $group); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); return setAttributes($driver, $target, $lun, $group, $attributes, $_attributes, $error, \&setLunAttribute, $showset); @@ -3231,7 +3260,7 @@ my $_attributes = $SCST->initiatorAttributes($driver, $target, $group, $initiator); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); # As if writing, initiators didn't have attributes. This will # allow us to support it in the future. @@ -3326,7 +3355,7 @@ my $driverCap = $SCST->driverIsVirtualCapable($driver); my $_attributes = $SCST->driverAttributes($driver); - return if issueWarning($SCST->errorString()); + return 0 if issueWarning($SCST->errorString()); # build caches for easier matching foreach my $attribute (keys %{$attributes}) { @@ -3399,7 +3428,7 @@ my $_attributes = $SCST->driverAttributes($driver); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); my $existing = cacheAttributes($_attributes); @@ -3412,6 +3441,8 @@ addDriverDynamicAttribute($driver, $attribute, $$attributes{$attribute}); } + + return FALSE; } sub addDriverDynamicAttribute { @@ -3424,6 +3455,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub removeDriverDynamicAttributes { @@ -3432,7 +3465,7 @@ my $_attributes = $SCST->driverAttributes($driver); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); my $existing = cacheAttributes($_attributes); @@ -3445,6 +3478,8 @@ removeDriverDynamicAttribute($driver, $attribute, $$attributes{$attribute}); } + + return FALSE; } sub removeDriverDynamicAttribute { @@ -3452,13 +3487,15 @@ my $attribute = shift; my $value = shift; - return if (!$SCST->driverIsVirtualCapable($driver)); + return TRUE if (!$SCST->driverIsVirtualCapable($driver)); print "\t-> Removing dynamic attribute '$attribute' with value '$value' for driver '$driver': "; my $rc = $SCST->removeDriverDynamicAttribute($driver, $attribute, $value); print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub setTargetAttribute { @@ -3479,6 +3516,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub setTargetAttributes { @@ -3492,7 +3531,7 @@ my $driverCap = $SCST->driverIsVirtualCapable($driver); my $_attributes = $SCST->targetAttributes($driver, $target); - return if issueWarning($SCST->errorString()); + return 0 if issueWarning($SCST->errorString()); # build caches for easier matching foreach my $attribute (keys %{$attributes}) { @@ -3568,7 +3607,7 @@ my $_attributes = $SCST->targetAttributes($driver, $target); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); my $existing = cacheAttributes($_attributes); @@ -3582,6 +3621,8 @@ addTargetDynamicAttribute($driver, $target, $attribute, $$attributes{$attribute}); } + + return FALSE; } sub addTargetDynamicAttribute { @@ -3596,6 +3637,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub removeTargetDynamicAttributes { @@ -3605,7 +3648,7 @@ my $_attributes = $SCST->targetAttributes($driver, $target); - return if issueWarning($SCST->errorString()); + return TRUE if issueWarning($SCST->errorString()); my $existing = cacheAttributes($_attributes); @@ -3619,6 +3662,8 @@ removeTargetDynamicAttribute($driver, $target, $attribute, $$attributes{$attribute}); } + + return FALSE; } sub removeTargetDynamicAttribute { @@ -3627,13 +3672,15 @@ my $attribute = shift; my $value = shift; - return if (!$SCST->driverIsVirtualCapable($driver)); + return TRUE if (!$SCST->driverIsVirtualCapable($driver)); print "\t-> Removing dynamic attribute '$attribute' with value '$value' for driver/target '$driver/$target': "; my $rc = $SCST->removeTargetDynamicAttribute($driver, $target, $attribute, $value); print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } #################################################################### @@ -3650,6 +3697,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub closeDevice { @@ -3674,13 +3723,15 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub resyncDevice { my $device = shift; my %attributes = ('resync_size', 1); - setDeviceAttributes($device, \%attributes); + return setDeviceAttributes($device, \%attributes); } #################################################################### @@ -3697,6 +3748,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub removeGroup { @@ -3722,6 +3775,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } #################################################################### @@ -3754,6 +3809,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub removeInitiator { @@ -3770,6 +3827,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub moveInitiator { @@ -3786,6 +3845,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub clearInitiators { @@ -3800,6 +3861,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } #################################################################### @@ -3825,6 +3888,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub removeLun { @@ -3846,6 +3911,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub replaceLun { @@ -3864,6 +3931,8 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub clearLuns { @@ -3882,12 +3951,14 @@ print "done.\n"; immediateExit($SCST->errorString($rc)) if ($rc); + + return FALSE; } sub clearDriverDynamicAttributes { my $driver = shift; - return if (!$SCST->driverIsVirtualCapable($driver)); + return TRUE if (!$SCST->driverIsVirtualCapable($driver)); print "\t-> Removing all dynamic attributes from driver '$driver': "; @@ -3908,13 +3979,15 @@ } print "done.\n"; + + return FALSE; } sub clearTargetDynamicAttributes { my $driver = shift; my $target = shift; - return if (!$SCST->driverIsVirtualCapable($driver)); + return TRUE if (!$SCST->driverIsVirtualCapable($driver)); print "\t-> Removing all dynamic attributes from driver/target '$driver/$target': "; @@ -3935,6 +4008,8 @@ } print "done.\n"; + + return FALSE; } #################################################################### @@ -3945,6 +4020,8 @@ my %attributes = ('enabled', 1); setTargetAttributes($driver, $target, \%attributes); + + return FALSE; } sub disableTarget { @@ -3953,6 +4030,8 @@ my %attributes = ('enabled', 0); setTargetAttributes($driver, $target, \%attributes); + + return FALSE; } sub enableDriver { @@ -3960,9 +4039,9 @@ my %attributes = ('enabled', 1); my $attrs = $SCST->driverAttributes($driver); - return if (!defined($$attrs{'enabled'})); + return TRUE if (!defined($$attrs{'enabled'})); - setDriverAttributes($driver, \%attributes); + return setDriverAttributes($driver, \%attributes); } sub disableDriver { @@ -3970,9 +4049,9 @@ my %attributes = ('enabled', 0); my $attrs = $SCST->driverAttributes($driver); - return if (!defined($$attrs{'enabled'})); + return TRUE if (!defined($$attrs{'enabled'})); - setDriverAttributes($driver, \%attributes); + return setDriverAttributes($driver, \%attributes); } sub issueLip { @@ -4084,6 +4163,8 @@ @buff_a = split(//, $buffer); $CONFIG = parseStanza(\@buff_a); + + return FALSE; } sub parseStanza { @@ -4383,6 +4464,8 @@ %{$$new{'TARGET_DRIVER'}->{$driver}->{'TARGET'}->{$target}->{'GROUP'}->{$group}->{'LUN'}->{$lun}->{$device}} = (); } } + + return FALSE; } sub findTargetDriver { @@ -4496,7 +4579,7 @@ sub immediateExit { my $error = shift; - return if (!$error); + return FALSE if (!$error); print "\n\nFATAL: Received the following error:\n\n\t"; print "$error\n\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mga...@us...> - 2010-12-08 15:01:54
|
Revision: 2979 http://scst.svn.sourceforge.net/scst/?rev=2979&view=rev Author: mgandalf Date: 2010-12-08 15:01:48 +0000 (Wed, 08 Dec 2010) Log Message: ----------- - Exit 0 and issue warning on empty config file. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2010-12-08 14:57:48 UTC (rev 2978) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2010-12-08 15:01:48 UTC (rev 2979) @@ -1516,6 +1516,11 @@ readConfigFile() if (!$CONFIG); + if (!scalar keys %{$CONFIG}) { + print "-> WARNING: Configuration is empty or unreadable, aborting.\n\n"; + exit 0; + } + # Check for a minimum sane configuration if (!defined($$CONFIG{'TARGET_DRIVER'}) || !(scalar keys %{$$CONFIG{'TARGET_DRIVER'}})) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mga...@us...> - 2010-12-10 17:22:57
|
Revision: 3011 http://scst.svn.sourceforge.net/scst/?rev=3011&view=rev Author: mgandalf Date: 2010-12-10 16:08:52 +0000 (Fri, 10 Dec 2010) Log Message: ----------- - Small cleanup of issueLip(). - Issue a LIP on any changes which might effect initiators. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2010-12-10 13:39:33 UTC (rev 3010) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2010-12-10 16:08:52 UTC (rev 3011) @@ -565,7 +565,7 @@ } sub main { - my $rc; + my $rc = 0; STDOUT->autoflush(1); @@ -601,7 +601,8 @@ $rc = checkConfiguration(); immediateExit("Configuration has errors, aborting.") if ($rc); last if ($force && prompt()); - $rc = applyConfiguration($force); + my $changes = applyConfiguration($force); + $rc = issueLip() if ($changes); last SWITCH; }; defined($checkConfig) && do { @@ -616,7 +617,8 @@ }; defined($clearConfig) && do { last if (prompt()); - $rc = clearConfiguration($force); + $rc = clearConfiguration(); + $rc = issueLip() if (!$rc); last SWITCH; }; defined($listHandler) && do { @@ -734,11 +736,14 @@ defined($addDriverAttr) && do { print "\n-> Making requested changes.\n"; $rc = addDriverDynamicAttributes($addDriverAttr, $attributes); + $rc = issueLip() if (!$rc); + print "\t-> Done.\n"; last SWITCH; }; defined($addTargetAttr) && do { print "\n-> Making requested changes.\n"; $rc = addTargetDynamicAttributes($driver, $addTargetAttr, $attributes); + $rc = issueLip() if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -746,6 +751,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeDriverDynamicAttributes($remDriverAttr, $attributes); + $rc = issueLip() if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -753,6 +759,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeTargetDynamicAttributes($driver, $remTargetAttr, $attributes); + $rc = issueLip() if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -766,12 +773,14 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = closeDevice($handler, $closeDev, $force); + $rc = issueLip() if (!$rc); print "\t-> Done.\n"; last SWITCH; }; defined($resyncDev) && do { print "\n-> Making requested changes.\n"; $rc = resyncDevice($resyncDev); + $rc = issueLip() if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -785,6 +794,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeVirtualTarget($driver, $removeTarget); + $rc = issueLip($driver) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -804,6 +814,7 @@ defined($addInitiator) && do { print "\n-> Making requested changes.\n"; $rc = addInitiator($driver, $target, $group, $addInitiator); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -811,6 +822,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeInitiator($driver, $target, $group, $removeInitiator); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -818,6 +830,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = moveInitiator($driver, $target, $group, $moveInitiator, $to); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -825,12 +838,14 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearInitiators($driver, $target, $group); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; defined($addLun) && do { print "\n-> Making requested changes.\n"; $rc = addLun($driver, $target, $device, $addLun, $attributes, $group); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -838,6 +853,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeLun($driver, $target, $removeLun, $group); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -845,6 +861,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = replaceLun($driver, $target, $group, $replaceLun, $device, $attributes); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -852,6 +869,7 @@ last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearLuns($driver, $target, $group); + $rc = issueLip($driver, $target) if (!$rc); print "\t-> Done.\n"; last SWITCH; }; @@ -1701,7 +1719,7 @@ print "\t-> Done, $changes change(s) made.\n"; - return FALSE; + return $changes; } sub applyConfigDevices { @@ -2211,8 +2229,6 @@ } sub clearConfiguration { - my $force = shift; - my $assignments = $CURRENT{'assign'}; print "-> Clearing running configuration.\n"; @@ -2222,7 +2238,7 @@ foreach my $group (sort keys %{$$assignments{$driver}->{$target}->{'GROUP'}}) { clearInitiators($driver, $target, $group); clearLuns($driver, $target, $group); - removeGroup($driver, $target, $group, $force); + removeGroup($driver, $target, $group, TRUE); } clearLuns($driver, $target); @@ -2242,7 +2258,7 @@ foreach my $handler (sort keys %{$handlers}) { foreach my $device (@{$$handlers{$handler}}) { my $attributes = $SCST->deviceAttributes($device); - closeDevice($handler, $device, $force); + closeDevice($handler, $device, TRUE); } } @@ -4090,14 +4106,14 @@ my $attributes = $SCST->targetAttributes($driver, $target); if (!defined($$attributes{'host'})) { - print "Driver/target '$driver/$target' has no 'host' attribute, ignoring.\n"; + #print "\t-> Driver/target '$driver/$target' has no 'host' attribute, ignoring.\n"; return FALSE; } my $dir = new IO::Handle; if (!(opendir $dir, $$attributes{'host'}->{'value'}.'/device/fc_host')) { - print "Driver/target is not a fibre channel target, ignoring.\n"; + #print "\t-> Driver/target is not a fibre channel target, ignoring.\n"; return FALSE; } @@ -4112,7 +4128,7 @@ print "WARNING: Failed to open file '$lip' for writing.\n" if (!$io); - print "Issuing LIP on fibre channel driver/target '$driver/$target' ($host): "; + print "\t-> Issuing LIP on fibre channel driver/target '$driver/$target' ($host): "; my $bytes = syswrite($io, 1, 1); @@ -4125,8 +4141,8 @@ close $io; } else { - print "Fibre channel driver/target '$driver/$target' lacks the ability to ". - "issue LIPs, ignoring.\n"; + #print "Fibre channel driver/target '$driver/$target' lacks the ability to ". + # "issue LIPs, ignoring.\n"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-01-06 18:32:04
|
Revision: 3199 http://scst.svn.sourceforge.net/scst/?rev=3199&view=rev Author: bvassche Date: 2011-01-06 18:31:58 +0000 (Thu, 06 Jan 2011) Log Message: ----------- Make -write_config write device names in alphabetical order. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-01-06 18:29:17 UTC (rev 3198) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-01-06 18:31:58 UTC (rev 3199) @@ -1077,7 +1077,7 @@ my $devices = $CURRENT{'handler'}->{$handler}; my $device_buff; - foreach my $device (@{$devices}) { + foreach my $device (sort @{$devices}) { $device_buff .= "\tDEVICE $device"; $attributes = $SCST->deviceAttributes($device); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mga...@us...> - 2011-01-07 15:38:57
|
Revision: 3202 http://scst.svn.sourceforge.net/scst/?rev=3202&view=rev Author: mgandalf Date: 2011-01-07 15:38:51 +0000 (Fri, 07 Jan 2011) Log Message: ----------- - Expose -set_grp_attr argument in help output. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-01-06 20:17:38 UTC (rev 3201) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-01-07 15:38:51 UTC (rev 3202) @@ -58,6 +58,10 @@ -set_tgt_attr <target> : Sets target attribute(s) <p> to value <v>. -driver <driver> -attributes <p=v,...> + -set_grp_attr <group> : Sets group attribute(s) <p> to value <v>. + -driver <driver> + -target <target> + -attributes <p=v,...> -set_lun_attr <lun> : Sets LUN attribute(s) <p> to value <v>. -driver <driver> -target <target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mga...@us...> - 2011-05-09 20:03:13
|
Revision: 3443 http://scst.svn.sourceforge.net/scst/?rev=3443&view=rev Author: mgandalf Date: 2011-05-09 20:03:07 +0000 (Mon, 09 May 2011) Log Message: ----------- - Enable all hardware targets before adding virtual ones. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-05-08 11:59:05 UTC (rev 3442) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-05-09 20:03:07 UTC (rev 3443) @@ -2082,7 +2082,7 @@ if (defined($$attributes{'HW_TARGET'})) { immediateExit("Hardware target '$target' for driver '$driver' does not exist."); - } + } filterCreateAttributes($possible, $attributes, FALSE); @@ -2290,6 +2290,18 @@ my $target = shift; my $attributes = shift; + # Enable all hardware targets before creating virtual ones + my $targets = $SCST->targets($driver); + + foreach my $_target (@{$targets}) { + my $attributes = $SCST->targetAttributes($driver, $_target); + + if (defined($$attributes{'hw_target'}) && + !$$attributes{'enabled'}->{'value'}) { + enableTarget($driver, $_target); + } + } + print "\t-> Creating target '$target' for driver '$driver': "; my $rc = $SCST->addVirtualTarget($driver, $target, $attributes); print "done.\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mga...@us...> - 2011-05-13 19:06:02
|
Revision: 3454 http://scst.svn.sourceforge.net/scst/?rev=3454&view=rev Author: mgandalf Date: 2011-05-13 19:05:56 +0000 (Fri, 13 May 2011) Log Message: ----------- - Add LUN 0 warning. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-05-13 10:40:40 UTC (rev 3453) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-05-13 19:05:56 UTC (rev 3454) @@ -1658,6 +1658,12 @@ } } } + + if (!defined($$tgt{'LUN'}->{'0'})) { + print "\t->WARNING: No LUN 0 defined for driver/target '$driver/$target'. ". + "Many initiators require a LUN 0 to be defined.\n\n"; + $warnings++; + } } if (defined($$tgt{'GROUP'})) { @@ -1674,6 +1680,12 @@ } } } + + if (!defined($$tgt{'GROUP'}->{$group}->{'LUN'}->{'0'})) { + print "\t->WARNING: No LUN 0 defined for driver/target/group '$driver/$target/$group'. ". + "Many initiators require a LUN 0 to be defined.\n\n"; + $warnings++; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mga...@us...> - 2011-05-13 19:21:24
|
Revision: 3455 http://scst.svn.sourceforge.net/scst/?rev=3455&view=rev Author: mgandalf Date: 2011-05-13 19:21:16 +0000 (Fri, 13 May 2011) Log Message: ----------- - Fix a small type. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-05-13 19:05:56 UTC (rev 3454) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-05-13 19:21:16 UTC (rev 3455) @@ -1660,7 +1660,7 @@ } if (!defined($$tgt{'LUN'}->{'0'})) { - print "\t->WARNING: No LUN 0 defined for driver/target '$driver/$target'. ". + print "\t-> WARNING: No LUN 0 defined for driver/target '$driver/$target'. ". "Many initiators require a LUN 0 to be defined.\n\n"; $warnings++; } @@ -1682,7 +1682,7 @@ } if (!defined($$tgt{'GROUP'}->{$group}->{'LUN'}->{'0'})) { - print "\t->WARNING: No LUN 0 defined for driver/target/group '$driver/$target/$group'. ". + print "\t-> WARNING: No LUN 0 defined for driver/target/group '$driver/$target/$group'. ". "Many initiators require a LUN 0 to be defined.\n\n"; $warnings++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-19 06:21:55
|
Revision: 3593 http://scst.svn.sourceforge.net/scst/?rev=3593&view=rev Author: bvassche Date: 2011-06-19 06:21:49 +0000 (Sun, 19 Jun 2011) Log Message: ----------- scstadmin(sysfs): Make writing top-level non-key attributes work. Do not indent these attributes. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 06:11:03 UTC (rev 3592) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 06:21:49 UTC (rev 3593) @@ -1024,10 +1024,10 @@ if (!$$attributes{$attribute}->{'static'}) { if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (@{$$attributes{$attribute}->{'keys'}}) { + foreach my $key (%{$$attributes{$attribute}->{'keys'}}) { my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; $value = "\"$value\"" if ($value =~ / /); - print $io "\t$attribute $value\n" + print $io "$attribute $value\n" if (defined($value) && ($value ne '')); } } elsif ($nonkey) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-19 16:38:59
|
Revision: 3596 http://scst.svn.sourceforge.net/scst/?rev=3596&view=rev Author: bvassche Date: 2011-06-19 16:38:53 +0000 (Sun, 19 Jun 2011) Log Message: ----------- scstadmin: Fix a typo Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 06:22:10 UTC (rev 3595) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 16:38:53 UTC (rev 3596) @@ -29,7 +29,7 @@ [-driver <driver>] [-target <target>] - -list_scst_attr : List add attributes for SCST. + -list_scst_attr : List all attributes for SCST. -list_hnd_attr <hndlr> : List all attributes for a given handler. -list_dev_attr <device> : List all attributes for a given device. -list_drv_attr <driver> : List all attributes for a given driver. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-19 16:39:59
|
Revision: 3597 http://scst.svn.sourceforge.net/scst/?rev=3597&view=rev Author: bvassche Date: 2011-06-19 16:39:52 +0000 (Sun, 19 Jun 2011) Log Message: ----------- scstadmin: Escape a single quote in order not to confuse syntax highlighting editors Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 16:38:53 UTC (rev 3596) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 16:39:52 UTC (rev 3597) @@ -139,7 +139,7 @@ -driver <driver> -target <target> -group <group> - -replace_lun <lun> : Replaces a LUN's device with a different one. + -replace_lun <lun> : Replaces a LUN\'s device with a different one. -driver <driver> -target <target> -group <group> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-19 16:58:35
|
Revision: 3598 http://scst.svn.sourceforge.net/scst/?rev=3598&view=rev Author: bvassche Date: 2011-06-19 16:58:29 +0000 (Sun, 19 Jun 2011) Log Message: ----------- scstadmin: Use 1 instead of TRUE where an integer exit code is returned Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 16:39:52 UTC (rev 3597) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 16:58:29 UTC (rev 3598) @@ -999,7 +999,7 @@ if (!unlink $CONFIGFILE) { print "Failed to save current configuration, specified ". "file exists and cannot be deleted.\n"; - return TRUE; + return 1; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-19 17:30:47
|
Revision: 3599 http://scst.svn.sourceforge.net/scst/?rev=3599&view=rev Author: bvassche Date: 2011-06-19 17:30:41 +0000 (Sun, 19 Jun 2011) Log Message: ----------- scstadmin: Another return value consistency improvement Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 16:58:29 UTC (rev 3598) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 17:30:41 UTC (rev 3599) @@ -992,6 +992,7 @@ return FALSE; } +# Returns 0 upon success and 1 upon error. sub writeConfiguration { my $nonkey = shift; @@ -1525,7 +1526,7 @@ close $io; - return FALSE; + return 0; } sub checkConfiguration { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-19 18:43:37
|
Revision: 3600 http://scst.svn.sourceforge.net/scst/?rev=3600&view=rev Author: bvassche Date: 2011-06-19 18:43:31 +0000 (Sun, 19 Jun 2011) Log Message: ----------- scstadmin: Minor source code simplification Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 17:30:41 UTC (rev 3599) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-19 18:43:31 UTC (rev 3600) @@ -1430,14 +1430,8 @@ if ($lun_buff || $init_buff) { $group_buff .= " {\n"; - - if ($lun_buff) { - $group_buff .= $lun_buff; - } - - if ($init_buff) { - $group_buff .= $init_buff; - } + $group_buff .= $lun_buff; + $group_buff .= $init_buff; } my $grp_attributes = $SCST->groupAttributes($driver, $target, $group); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-22 19:18:45
|
Revision: 3606 http://scst.svn.sourceforge.net/scst/?rev=3606&view=rev Author: bvassche Date: 2011-06-22 19:18:39 +0000 (Wed, 22 Jun 2011) Log Message: ----------- scstadmin: Multiple -write_config bug fixes. Bug fixes: - Do not write out the line "# Non-key attributes" for the top level if -nonkey has not been specified. - If -nonkey has been specified, write out the device handler creation time attributes too (blocksize, o_direct, read_only, removable, ...). - If -nonkey has been specified, write out the LUN creation time attributes too (read_only). Also, simplify the -write_config implementation by introducing the Perl subroutines serializeKeyAttr() and serializeNkAttr(). Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-20 20:52:08 UTC (rev 3605) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-22 19:18:39 UTC (rev 3606) @@ -6,6 +6,7 @@ # Author: Mark R. Buechler # License: GPLv2 # Copyright (c) 2005-2010 Mark R. Buechler +# Copyright (C) 2011 Bart Van Assche <bva...@ac...> sub usage { @@ -992,6 +993,75 @@ return FALSE; } +# Serialize key attributes. +# $prefix: output prefix, e.g. "\t\t". +# $attributes: reference to a hash with attributes and their values. +# $attr_filter: if specified, reference to a hash with the names of which +# (static) attributes to serialize. +sub serializeKeyAttr { + my $prefix = shift; + my $attributes = shift; + my $attr_filter = shift; + my $result; + + foreach my $attribute (sort keys %{$attributes}) { + next if defined($$attributes{$attribute}->{'set'}); + next if ($$attributes{$attribute}->{'static'} && + !(defined($attr_filter) + && defined($$attr_filter{$attribute}))); + + if (defined($$attributes{$attribute}->{'keys'})) { + foreach my $key (sort keys %{$$attributes{$attribute}->{'keys'}}) { + my $value = + $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; + if ($value ne '') { + if ($value =~ / /) { + $value = "\"$value\""; + } + $result .= "$prefix$attribute $value\n"; + } + } + } elsif ($attribute eq 'enabled' || $attribute eq 'hw_target') { + my $value = $$attributes{$attribute}->{'value'}; + $result .= "$prefix$attribute $value\n"; + } + } + + return $result; +} + +# Serialize non-key attributes. +# $prefix: output prefix, e.g. "\t\t". +# $attributes: reference to a hash with attributes and their values. +# $attr_filter: if specified, reference to a hash with the names of which +# (static) attributes to serialize. +sub serializeNkAttr { + my $prefix = shift; + my $attributes = shift; + my $attr_filter = shift; + my $result; + + foreach my $attribute (sort keys %{$attributes}) { + if (!defined($$attributes{$attribute}->{'set'}) + && (!$$attributes{$attribute}->{'static'} + || defined($attr_filter) + && defined($$attr_filter{$attribute})) + && !defined($$attributes{$attribute}->{'keys'}) + && $attribute ne 'enabled' + && $attribute ne 'hw_target') { + my $value = $$attributes{$attribute}->{'value'}; + if ($value ne '') { + if ($value =~ / /) { + $value = "\"$value\""; + } + $result .= "$prefix$attribute $value\n"; + } + } + } + + return $result; +} + # Returns 0 upon success and 1 upon error. sub writeConfiguration { my $nonkey = shift; @@ -1015,134 +1085,47 @@ print $io "# Automatically generated by $Version.\n\n"; - my $attributes = $SCST->scstAttributes(); - immediateExit($SCST->errorString()); + { + my $attributes = $SCST->scstAttributes(); + immediateExit($SCST->errorString()); - my %nattrs; - - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); - - if (!$$attributes{$attribute}->{'static'}) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (%{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - print $io "$attribute $value\n" - if (defined($value) && ($value ne '')); - } - } elsif ($nonkey) { - my $value = $$attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $nattrs{$attribute} = $value - if (defined($value) && ($value ne '')); - } + print $io serializeKeyAttr("", $attributes); + if ($nonkey) { + my $nk = serializeNkAttr("", $attributes); + if ($nk) { + print $io "# Non-key attributes\n"; + print $io $nk; + } } + print $io "\n"; } - if ($nonkey && (scalar keys %nattrs)) { - print $io "# Non-key attributes\n"; - foreach my $attr (keys %nattrs) { - my $value = $nattrs{$attr}; - print $io "$attr $value\n"; - } - } - - print $io "\n"; - foreach my $handler (sort keys %{$CURRENT{'handler'}}) { my $handler_buff; my $handler_buff_nk; my $handler_attrs = $SCST->deviceCreateAttributes($handler); - $attributes = $SCST->handlerAttributes($handler); + my $attributes = $SCST->handlerAttributes($handler); - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); + $handler_buff = serializeKeyAttr("\t", $attributes); + $handler_buff_nk = serializeNkAttr("\t", $attributes) if ($nonkey); - if (!$$attributes{$attribute}->{'static'}) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (@{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $handler_buff .= "\t$attribute $value\n" if (defined($value)); - } - } elsif (($attribute eq 'enabled') || $nonkey) { - my $value = $$attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - if ($attribute eq 'enabled') { - $handler_buff .= "\t$attribute $value\n" if (defined($value)); - } else { - $handler_buff_nk .= "\t$attribute $value\n" if (defined($value)); - } - } - } - } - my $devices = $CURRENT{'handler'}->{$handler}; my $device_buff; foreach my $device (sort @{$devices}) { $device_buff .= "\tDEVICE $device"; - $attributes = $SCST->deviceAttributes($device); + my $attributes = $SCST->deviceAttributes($device); my $attribute_buff; my $attribute_buff_nk; - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); - if (!defined($$handler_attrs{$attribute})) { - if (!$$attributes{$attribute}->{'static'}) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $attribute_buff .= "\t\t$attribute $value\n" - if (defined($value)); - } - } elsif (($attribute eq 'enabled') || $nonkey) { - my $value = $$attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - if ($attribute eq 'enabled') { - $attribute_buff .= "\t\t$attribute $value\n" - if (defined($value)); - } else { - $attribute_buff_nk .= "\t\t$attribute $value\n" - if (defined($value)); - } - } - } - } - } - + $attribute_buff = serializeKeyAttr("\t\t", $attributes, $handler_attrs); + $attribute_buff_nk = serializeNkAttr("\t\t", $attributes, $handler_attrs) if ($nonkey); $attribute_buff .= "\n" if ($attribute_buff); $attribute_buff_nk .= "\n" if ($attribute_buff_nk); - if (!defined($$attributes{'scsi_device'})) { - my $create_buff; - - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); - - if (defined($$handler_attrs{$attribute})) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $create_buff .= "\t\t$attribute $value\n" - if (defined($value)); - } - # Shouldn't be any non-key create attributes - } - } - } - - if ($create_buff) { - $attribute_buff .= $create_buff; - } - } - if ($attribute_buff_nk) { $attribute_buff .= "\n" if ($attribute_buff); $attribute_buff .= "\t\t# Non-key attributes\n"; @@ -1183,30 +1166,9 @@ my $drv_attr_buff; my $drv_attr_buff_nk; - foreach my $attr (keys %{$drv_attrs}) { - next if ($$drv_attrs{$attr}->{'static'}); - next if ($$drv_attrs{$attr}->{'set'}); - if (defined($$drv_attrs{$attr}->{'keys'})) { - foreach my $key (keys %{$$drv_attrs{$attr}->{'keys'}}) { - my $value = $$drv_attrs{$attr}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $drv_attr_buff .= "\t$attr $value\n" - if (defined($value)); - } - } elsif (($attr eq 'enabled') || $nonkey) { - my $value = $$drv_attrs{$attr}->{'value'}; - $value = "\"$value\"" if ($value =~ /\s/); - if ($attr eq 'enabled') { - $drv_attr_buff .= "\t$attr $value\n" - if (defined($value)); - } else { - $drv_attr_buff_nk .= "\t$attr $value\n" - if (defined($value)); - } - } - } - + $drv_attr_buff = serializeKeyAttr("\t", $drv_attrs); + $drv_attr_buff_nk = serializeNkAttr("\t", $drv_attrs) if ($nonkey); $drv_attr_buff .= "\n" if ($drv_attr_buff); $drv_attr_buff_nk .= "\n" if ($drv_attr_buff_nk); @@ -1227,31 +1189,8 @@ $attribute_buff = "\t\tHW_TARGET\n\n"; } - foreach my $attr (keys %{$attributes}) { - next if ($$attributes{$attr}->{'static'} && - !defined($$tgt_attrs{$attr})); - next if ($$attributes{$attr}->{'set'}); - - if (defined($$attributes{$attr}->{'keys'})) { - foreach my $key (keys %{$$attributes{$attr}->{'keys'}}) { - my $value = $$attributes{$attr}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $attribute_buff .= "\t\t$attr $value\n" - if (defined($value)); - } - } elsif (($attr eq 'hw_target') || ($attr eq 'enabled') || $nonkey) { - my $value = $$attributes{$attr}->{'value'}; - $value = "\"$value\"" if ($value =~ /\s/); - if ($attr eq 'enabled') { - $attribute_buff .= "\t\t$attr $value\n" - if (defined($value)); - } else { - $attribute_buff_nk .= "\t\t$attr $value\n" - if (defined($value)); - } - } - } - + $attribute_buff .= serializeKeyAttr("\t\t", $attributes); + $attribute_buff_nk .= serializeNkAttr("\t\t", $attributes) if ($nonkey); $attribute_buff .= "\n" if ($attribute_buff); $attribute_buff_nk .= "\n" if ($attribute_buff_nk); @@ -1264,39 +1203,16 @@ $t_lun_buff .= "\t\tLUN $lun $lun_dev"; - $attributes = $SCST->lunAttributes($driver, $target, $lun); + my $attributes = $SCST->lunAttributes($driver, $target, $lun); + my $l_attribute_buff = + serializeKeyAttr("\t\t\t\t", + $attributes, + $lun_attrs); + my $l_attribute_buff_nk = + serializeNkAttr("\t\t\t\t", + $attributes, + $lun_attrs) if ($nonkey); - my $l_attribute_buff; - my $l_attribute_buff_nk; - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); - - if (!$$attributes{$attribute}->{'static'} || - defined($$lun_attrs{$attribute})) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $l_attribute_buff .= "\t\t\t$attribute $value\n" - if (defined($value)); - } - } elsif (($attribute eq 'enabled') || $nonkey) { - my $value = $$attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - if (defined($$lun_attrs{$attribute})) { - $l_attribute_buff .= "\t\t\t$attribute $value\n" - if (defined($value)); - } elsif ($attribute eq 'enabled') { - $l_attribute_buff .= "\t\t\t$attribute $value\n" - if (defined($value)); - } else { - $l_attribute_buff_nk .= "\t\t\t$attribute $value\n" - if (defined($value)); - } - } - } - } - if ($l_attribute_buff_nk) { $l_attribute_buff .= "\t\t\t\t# Non-key attributes\n"; $l_attribute_buff .= $l_attribute_buff_nk; @@ -1331,39 +1247,18 @@ $lun_buff .= "\t\t\tLUN $lun $lun_dev"; - $attributes = $SCST->lunAttributes($driver, $target, $lun, $group); + my $attributes = $SCST->lunAttributes($driver, $target, $lun, $group); - my $l_attribute_buff; - my $l_attribute_buff_nk; - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); + my $l_attribute_buff + = serializeKeyAttr("\t\t\t\t", + $attributes, + $lun_attrs); + my $l_attribute_buff_nk + = serializeNkAttr("\t\t\t\t", + $attributes, + $lun_attrs) + if ($nonkey); - if (!$$attributes{$attribute}->{'static'} || - defined($$lun_attrs{$attribute})) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $l_attribute_buff .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } - } elsif (($attribute eq 'enabled') || $nonkey) { - my $value = $$attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - if (defined($$lun_attrs{$attribute})) { - $l_attribute_buff .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } elsif ($attribute eq 'enabled') { - $l_attribute_buff .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } else { - $l_attribute_buff_nk .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } - } - } - } - if ($l_attribute_buff_nk) { $l_attribute_buff .= "\t\t\t\t# Non-key attributes\n"; $l_attribute_buff .= $l_attribute_buff_nk; @@ -1384,36 +1279,18 @@ foreach my $init (@{$inits}) { $init_buff .= "\n\t\t\tINITIATOR $init"; - $attributes = $SCST->initiatorAttributes($driver, $target, $group, $init); + my $attributes = $SCST->initiatorAttributes($driver, $target, $group, $init); - my $i_attribute_buff; - my $i_attribute_buff_nk; - foreach my $attribute (sort keys %{$attributes}) { - next if (defined($$attributes{$attribute}->{'set'})); + my $i_attribute_buff + = serializeKeyAttr("\t\t\t\t", + $attributes, + $ini_attrs); + my $i_attribute_buff_nk + = serializeNkAttr("\t\t\t\t", + $attributes, + $ini_attrs) + if ($nonkey); - if (!$$attributes{$attribute}->{'static'} || - defined($$ini_attrs{$attribute})) { - if (defined($$attributes{$attribute}->{'keys'})) { - foreach my $key (keys %{$$attributes{$attribute}->{'keys'}}) { - my $value = $$attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $i_attribute_buff .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } - } elsif (($attribute eq 'enabled') || $nonkey) { - my $value = $$attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - if ($attribute eq 'enabled') { - $i_attribute_buff .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } else { - $i_attribute_buff_nk .= "\t\t\t\t$attribute $value\n" - if (defined($value)); - } - } - } - } - if ($i_attribute_buff_nk) { $i_attribute_buff .= "\t\t\t\t# Non-key attributes\n"; $i_attribute_buff .= $i_attribute_buff_nk; @@ -1421,7 +1298,7 @@ if ($i_attribute_buff) { $init_buff .= " {\n"; - $init_buff .= $attribute_buff; + $init_buff .= $i_attribute_buff; $init_buff .= "\t\t\t}\n"; } else { $init_buff .= "\n"; @@ -1435,34 +1312,14 @@ } my $grp_attributes = $SCST->groupAttributes($driver, $target, $group); + my $g_attribute_buff + = serializeKeyAttr("\t\t\t", + $grp_attributes); + my $g_attribute_buff_nk + = serializeNkAttr("\t\t\t", + $grp_attributes) + if ($nonkey); - my $g_attribute_buff; - my $g_attribute_buff_nk; - foreach my $attribute (sort keys %{$grp_attributes}) { - next if (defined($$grp_attributes{$attribute}->{'set'})); - - if (!$$grp_attributes{$attribute}->{'static'}) { - if (defined($$grp_attributes{$attribute}->{'keys'})) { - foreach my $key (keys %{$$grp_attributes{$attribute}->{'keys'}}) { - my $value = $$grp_attributes{$attribute}->{'keys'}->{$key}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - $g_attribute_buff .= "\t\t\t$attribute $value\n" - if (defined($value)); - } - } elsif (($attribute eq 'enabled') || $nonkey) { - my $value = $$grp_attributes{$attribute}->{'value'}; - $value = "\"$value\"" if ($value =~ / /); - if ($attribute eq 'enabled') { - $g_attribute_buff .= "\t\t\t$attribute $value\n" - if (defined($value)); - } else { - $g_attribute_buff_nk .= "\t\t\t$attribute $value\n" - if (defined($value)); - } - } - } - } - if ($g_attribute_buff_nk) { $g_attribute_buff .= "\n" if ($g_attribute_buff); $g_attribute_buff .= "\t\t\t# Non-key attributes\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-06-30 18:40:35
|
Revision: 3646 http://scst.svn.sourceforge.net/scst/?rev=3646&view=rev Author: bvassche Date: 2011-06-30 18:40:29 +0000 (Thu, 30 Jun 2011) Log Message: ----------- scstadmin: Whitespace fixes for the -write_config changes introduced in r3606. Separate device handler key and non-key attributes with a single blank line instead of two. Indent <target>.<lun>.<attribute> with three tabs instead of four. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-30 01:01:17 UTC (rev 3645) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-06-30 18:40:29 UTC (rev 3646) @@ -1127,7 +1127,6 @@ $attribute_buff_nk .= "\n" if ($attribute_buff_nk); if ($attribute_buff_nk) { - $attribute_buff .= "\n" if ($attribute_buff); $attribute_buff .= "\t\t# Non-key attributes\n"; $attribute_buff .= $attribute_buff_nk; } @@ -1205,16 +1204,16 @@ my $attributes = $SCST->lunAttributes($driver, $target, $lun); my $l_attribute_buff = - serializeKeyAttr("\t\t\t\t", + serializeKeyAttr("\t\t\t", $attributes, $lun_attrs); my $l_attribute_buff_nk = - serializeNkAttr("\t\t\t\t", + serializeNkAttr("\t\t\t", $attributes, $lun_attrs) if ($nonkey); if ($l_attribute_buff_nk) { - $l_attribute_buff .= "\t\t\t\t# Non-key attributes\n"; + $l_attribute_buff .= "\t\t\t# Non-key attributes\n"; $l_attribute_buff .= $l_attribute_buff_nk; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-02 12:30:40
|
Revision: 3652 http://scst.svn.sourceforge.net/scst/?rev=3652&view=rev Author: bvassche Date: 2011-07-02 12:30:34 +0000 (Sat, 02 Jul 2011) Log Message: ----------- Send scstadmin help text to stdout instead of stderr such that it is easier to pipe to less Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-02 11:55:51 UTC (rev 3651) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-02 12:30:34 UTC (rev 3652) @@ -10,7 +10,7 @@ sub usage { - die <<"EndUsage"; + print <<"EndUsage"; $Version Usage: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-03 09:36:39
|
Revision: 3653 http://scst.svn.sourceforge.net/scst/?rev=3653&view=rev Author: bvassche Date: 2011-07-03 09:36:33 +0000 (Sun, 03 Jul 2011) Log Message: ----------- scstadmin: Add command-line options -h and --help Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-02 12:30:34 UTC (rev 3652) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-03 09:36:33 UTC (rev 3653) @@ -14,6 +14,8 @@ $Version Usage: + -h, -help, --help : Show this information. + General Operations -config <config> : Configure SCST given the specified <file>. -check_config <file> : Checks the saved configuration <file>. @@ -292,6 +294,7 @@ my $to; my $device; + my $show_usage; my $nonkey; my $force; @@ -365,10 +368,15 @@ 'to=s' => \$to, 'device=s' => \$device, + 'h' => \$show_usage, + 'help' => \$show_usage, + 'nonkey' => \$nonkey, 'noprompt' => \$_NOPROMPT_, 'force' => \$force, - 'debug' => \$_DEBUG_)) { + 'debug' => \$_DEBUG_) || + defined($show_usage)) + { usage(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-17 11:34:15
|
Revision: 3674 http://scst.svn.sourceforge.net/scst/?rev=3674&view=rev Author: bvassche Date: 2011-07-17 11:34:09 +0000 (Sun, 17 Jul 2011) Log Message: ----------- scstadmin: Fix a documentation inconsistency Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-16 03:41:06 UTC (rev 3673) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 11:34:09 UTC (rev 3674) @@ -17,7 +17,7 @@ -h, -help, --help : Show this information. General Operations - -config <config> : Configure SCST given the specified <file>. + -config <file> : Configure SCST given the specified <file>. -check_config <file> : Checks the saved configuration <file>. -write_config <file> : Writes the current configuration to <file>. -clear_config : Clear all SCST configuration. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-17 13:10:45
|
Revision: 3675 http://scst.svn.sourceforge.net/scst/?rev=3675&view=rev Author: bvassche Date: 2011-07-17 13:10:39 +0000 (Sun, 17 Jul 2011) Log Message: ----------- scstadmin -list_drv_attr: Do not print the error message "No such driver found" for target drivers without attributes Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 11:34:09 UTC (rev 3674) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:10:39 UTC (rev 3675) @@ -2794,11 +2794,6 @@ return TRUE if issueWarning($SCST->errorString()); - if (!scalar(keys %{$attributes})) { - print "No such driver '$driver' found.\n"; - return; - } - my $rc = listAttributes($attributes, $nonkey); return $rc if ($rc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-17 13:21:05
|
Revision: 3676 http://scst.svn.sourceforge.net/scst/?rev=3676&view=rev Author: bvassche Date: 2011-07-17 13:20:59 +0000 (Sun, 17 Jul 2011) Log Message: ----------- scstadmin: Fix documentation of -list_lun_attr and also the error message printed if -driver or -target is missing for -list_lun_attr. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:10:39 UTC (rev 3675) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:20:59 UTC (rev 3676) @@ -41,7 +41,7 @@ -list_lun_attr <lun> : List all attributes for a driver/target/lun. -driver <driver> -target <target> - -group <group> + [-group <group>] -list_ini_attr <ini> : List all attributes for a driver/target/initiator -driver <driver> -target <target> @@ -424,7 +424,7 @@ } if (defined($listLunAttr) && (($driver eq '') || ($target eq ''))) { - print "Please specify -driver -target and -group with -list_lun_attr.\n"; + print "Please specify -driver and -target with -list_lun_attr.\n"; usage(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-17 13:30:20
|
Revision: 3677 http://scst.svn.sourceforge.net/scst/?rev=3677&view=rev Author: bvassche Date: 2011-07-17 13:30:14 +0000 (Sun, 17 Jul 2011) Log Message: ----------- scstadmin: Add missing comma in an error message Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:20:59 UTC (rev 3676) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:30:14 UTC (rev 3677) @@ -429,7 +429,7 @@ } if (defined($listInitiatorAttr) && (($driver eq '') || ($target eq '') || ($group eq ''))) { - print "Please specify -driver -target and -group with -list_ini_attr.\n"; + print "Please specify -driver, -target and -group with -list_ini_attr.\n"; usage(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-17 13:54:34
|
Revision: 3678 http://scst.svn.sourceforge.net/scst/?rev=3678&view=rev Author: bvassche Date: 2011-07-17 13:54:28 +0000 (Sun, 17 Jul 2011) Log Message: ----------- scstadmin: Add information about -list_grp_attr in the scstadmin help text. Also, complain if no group name has been specified for -list_grp_attr. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:30:14 UTC (rev 3677) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:54:28 UTC (rev 3678) @@ -38,6 +38,9 @@ -list_drv_attr <driver> : List all attributes for a given driver. -list_tgt_attr <target> : List all attributes for a given driver/target. -driver <driver> + -list_grp_attr <group> : List all attributes for a given group. + -driver <driver> + -target <target> -list_lun_attr <lun> : List all attributes for a driver/target/lun. -driver <driver> -target <target> @@ -418,8 +421,9 @@ usage(); } - if (defined($listGroupAttr) && (($driver eq '') || ($target eq ''))) { - print "Please specify -driver and -target with -list_grp_attr.\n"; + if (defined($listGroupAttr) && (($driver eq '') || ($target eq '') || + ($listGroupAttr eq ''))) { + print "Please specify -driver, -target and group with -list_grp_attr.\n"; usage(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-17 14:07:24
|
Revision: 3679 http://scst.svn.sourceforge.net/scst/?rev=3679&view=rev Author: bvassche Date: 2011-07-17 14:07:18 +0000 (Sun, 17 Jul 2011) Log Message: ----------- scstadmin: Make clear that -group is optional for -set_lun_attr. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 13:54:28 UTC (rev 3678) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-17 14:07:18 UTC (rev 3679) @@ -71,7 +71,7 @@ -set_lun_attr <lun> : Sets LUN attribute(s) <p> to value <v>. -driver <driver> -target <target> - -group <group> + [-group <group>] -attributes <p=v,...> -set_ini_attr <ini> : Sets initiator attribute(s) <p> to value <v>. -driver <driver> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bva...@us...> - 2011-07-18 07:49:11
|
Revision: 3681 http://scst.svn.sourceforge.net/scst/?rev=3681&view=rev Author: bvassche Date: 2011-07-18 07:49:05 +0000 (Mon, 18 Jul 2011) Log Message: ----------- scstadmin: Only show usage information if -h or -help has been specified. Do not try to execute the specified command if there is a syntax error in the command line arguments. Modified Paths: -------------- trunk/scstadmin/scstadmin.sysfs/scstadmin Modified: trunk/scstadmin/scstadmin.sysfs/scstadmin =================================================================== --- trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-18 07:46:17 UTC (rev 3680) +++ trunk/scstadmin/scstadmin.sysfs/scstadmin 2011-07-18 07:49:05 UTC (rev 3681) @@ -377,10 +377,14 @@ 'nonkey' => \$nonkey, 'noprompt' => \$_NOPROMPT_, 'force' => \$force, - 'debug' => \$_DEBUG_) || - defined($show_usage)) + 'debug' => \$_DEBUG_)) { + exit 1; + } + + if (defined($show_usage)) { usage(); + exit 0; } $_DEBUG_ = TRUE if (defined($_DEBUG_)); @@ -408,142 +412,142 @@ if (($query_mode + $set_mode + $op_mode) > 1) { print "Please specify only one non-query operation at a time.\n"; - usage(); + exit 1; } if (defined($clearConfig) && !$force) { print "Please specify -force with -clear_config.\n"; - usage(); + exit 1; } if (defined($listTargetAttr) && ($driver eq '')) { print "Please specify -driver with -list_tgt_attr.\n"; - usage(); + exit 1; } if (defined($listGroupAttr) && (($driver eq '') || ($target eq '') || ($listGroupAttr eq ''))) { print "Please specify -driver, -target and group with -list_grp_attr.\n"; - usage(); + exit 1; } if (defined($listLunAttr) && (($driver eq '') || ($target eq ''))) { print "Please specify -driver and -target with -list_lun_attr.\n"; - usage(); + exit 1; } if (defined($listInitiatorAttr) && (($driver eq '') || ($target eq '') || ($group eq ''))) { print "Please specify -driver, -target and -group with -list_ini_attr.\n"; - usage(); + exit 1; } if (defined($setScstAttr) && ($attributes eq '')) { print "Please specify -attributes with -set_scst_attr.\n"; - usage(); + exit 1; } if (defined($setHandlerAttr) && ($attributes eq '')) { print "Please specify -attributes with -set_hnd_attr.\n"; - usage(); + exit 1; } if (defined($setDeviceAttr) && ($attributes eq '')) { print "Please specify -attributes with -set_dev_attr.\n"; - usage(); + exit 1; } if (defined($setDriverAttr) && ($attributes eq '')) { print "Please specify -attributes with -set_drv_attr.\n"; - usage(); + exit 1; } if (defined($setTargetAttr) && (($driver eq '') || ($attributes eq ''))) { print "Please specify -driver and -attributes with -set_tgt_attr.\n"; - usage(); + exit 1; } if (defined($setGroupAttr) && (($driver eq '') || ($target eq '') || ($attributes eq ''))) { print "Please specify -driver -target and -attributes with -set_grp_attr.\n"; - usage(); + exit 1; } if (defined($setLunAttr) && (($driver eq '') || ($target eq '') || ($attributes eq ''))) { print "Please specify -driver -target -group and -attributes with -set_lun_attr.\n"; - usage(); + exit 1; } if (defined($setInitiatorAttr) && (($driver eq '') || ($target eq '') || ($group eq '') || ($attributes eq ''))) { print "Please specify -driver -target -group and -attributes with -set_ini_attr.\n"; - usage(); + exit 1; } if (defined($addDriverAttr) && ($attributes eq '')) { print "Please specify -attributes with -add_drv_attr.\n"; - usage(); + exit 1; } if (defined($addTargetAttr) && (($driver eq '') || ($attributes eq ''))) { print "Please specify -driver and -attributes with -add_tgt_attr.\n"; - usage(); + exit 1; } if (defined($remDriverAttr) && ($attributes eq '')) { print "Please specify -attributes with -rem_drv_attr.\n"; - usage(); + exit 1; } if (defined($remTargetAttr) && (($driver eq '') || ($attributes eq ''))) { print "Please specify -driver and -attributes with -rem_tgt_attr.\n"; - usage(); + exit 1; } if ((defined($openDev) || defined($closeDev)) && ($handler eq '')) { print "Please specify -handler with -open_dev/-close_dev.\n"; - usage(); + exit 1; } if (defined($addTarget) && ($driver eq '')) { print "Please specify -driver with -add_target.\n"; - usage(); + exit 1; } if (defined($removeTarget) && ($driver eq '')) { print "Please specify -driver with -rem_target.\n"; - usage(); + exit 1; } if ((defined($addGroup) || defined($removeGroup)) && (($driver eq '') || ($target eq ''))) { print "Please specify -driver and -target with -add_group/-remove_group.\n"; - usage(); + exit 1; } if ((defined($addInitiator) || defined($removeInitiator) || defined($clearInitiators)) && (($target eq '') || ($driver eq '') || ($group eq ''))) { print "Please specify -driver -target and -group with ". "-add_init/-remove_init/-clear_inits.\n"; - usage(); + exit 1; } if (defined($moveInitiator) && (($driver eq '') || ($target eq '') || ($group eq '') || ($to eq ''))) { print "Please specify -driver -target -group and -to with -move_init.\n"; - usage(); + exit 1; } if ((defined($addLun) || defined($replaceLun)) && (($driver eq '') || ($target eq '') || ($device eq ''))) { print "Please specify -driver -target and -device with -add_lun/-replace_lun.\n"; - usage(); + exit 1; } if ((defined($clearLuns) || defined($removeLun)) && (($driver eq '') || ($target eq ''))) { print "Please specify -driver and -target with -rem_lun/-clear_luns.\n"; - usage(); + exit 1; } $applyConfig = $_DEF_CONFIG_ if (defined($applyConfig) && ($applyConfig eq '')); @@ -912,8 +916,7 @@ if (!$all_good) { print "No valid operations specified.\n"; - usage(); - exit TRUE; + exit 1; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |