- Remove unused references to handler IOs that don't exist and cleanup the write
authormgandalf <mgandalf@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 17 Sep 2009 21:04:39 +0000 (21:04 +0000)
committermgandalf <mgandalf@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 17 Sep 2009 21:04:39 +0000 (21:04 +0000)
  configuration function to only write vdisk and vcdrom devices. All other devices
  are automatically claimed by their handler module. I'm not sure how this will work
  with devices we wish to change handlers for.

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1110 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scstadmin/ChangeLog
scstadmin/scst-0.8.21/lib/SCST/SCST.pm
scstadmin/scstadmin

index 204bb20..f5560d6 100644 (file)
@@ -3,6 +3,10 @@ Changes for 1.0.9
 - Move a user from one group to another when applying the configuration instead
   of deleting from one and adding to another the same user.
 - Add the ability to specify options (ie: READ_ONLY) in assignments in scst.conf.
+- Remove unused references to handler IOs that don't exist and cleanup the write
+  configuration function to only write vdisk and vcdrom devices. All other devices
+  are automatically claimed by their handler module. I'm not sure how this will work
+  with devices we wish to change handlers for.
 - Minor fix to readConfig() which wasn't fully allowing for empty groups.
 
 Changes for 1.0.8
index 60a2d13..b845d3b 100644 (file)
@@ -12,17 +12,8 @@ use Carp qw(cluck);
 
 my $_SCST_DIR_           = '/proc/scsi_tgt';
 my $_SCST_IO_            = $_SCST_DIR_.'/scsi_tgt';
-my $_SCST_CDROM_IO_      = $_SCST_DIR_.'/dev_cdrom/dev_cdrom';
-my $_SCST_CHANGER_IO_    = $_SCST_DIR_.'/dev_changer/dev_changer';
-my $_SCST_DISK_IO_       = $_SCST_DIR_.'/dev_disk/dev_disk';
-my $_SCST_DISKP_IO_      = $_SCST_DIR_.'/dev_disk_perf/dev_disk_perf';
-my $_SCST_MODISK_IO_     = $_SCST_DIR_.'/dev_modisk/dev_modisk';
-my $_SCST_MODISKP_IO_    = $_SCST_DIR_.'/dev_modisk_perf/dev_modisk_perf';
-my $_SCST_TAPE_IO_       = $_SCST_DIR_.'/dev_tape/dev_tape';
-my $_SCST_TAPEP_IO_      = $_SCST_DIR_.'/dev_tape_perf/dev_tape_perf';
 my $_SCST_VDISK_IO_      = $_SCST_DIR_.'/vdisk/vdisk';
 my $_SCST_VCDROM_IO_     = $_SCST_DIR_.'/vcdrom/vcdrom';
-my $_SCST_PROCESSOR_IO_  = $_SCST_DIR_.'/dev_processor/dev_processor';
 my $_SCST_GROUPS_DIR_    = $_SCST_DIR_.'/groups';
 my $_SCST_SGV_STATS_     = $_SCST_DIR_.'/sgv';
 my $_SCST_SESSIONS_      = $_SCST_DIR_.'/sessions';
@@ -58,17 +49,8 @@ my $_SCST_MIN_MAJOR_   = 1;
 my $_SCST_MIN_MINOR_   = 0;
 my $_SCST_MIN_RELEASE_ = 2;
 
-my %_IO_MAP_ = ($CDROM_TYPE => $_SCST_CDROM_IO_,
-               $CHANGER_TYPE => $_SCST_CHANGER_IO_,
-               $DISK_TYPE => $_SCST_DISK_IO_,
-               $VDISK_TYPE => $_SCST_VDISK_IO_,
-               $VCDROM_TYPE => $_SCST_VCDROM_IO_,
-               $DISKPERF_TYPE => $_SCST_DISKP_IO_,
-               $MODISK_TYPE => $_SCST_MODISK_IO_,
-               $MODISKPERF_TYPE => $_SCST_MODISKP_IO_,
-               $TAPE_TYPE => $_SCST_TAPE_IO_,
-               $TAPEPERF_TYPE => $_SCST_TAPEP_IO_,
-               $PROCESSOR_TYPE => $_SCST_PROCESSOR_IO_);
+my %_IO_MAP_ = ($VDISK_TYPE => $_SCST_VDISK_IO_,
+               $VCDROM_TYPE => $_SCST_VCDROM_IO_);
 
 my %_TYPE_MAP_ = ('dev_cdrom' => $CDROM_TYPE,
                  'dev_changer' => $CHANGER_TYPE,
@@ -417,7 +399,7 @@ sub handlerDevices {
        my $io = new IO::File $handler_io, O_RDONLY;
 
        if (!$io) {
-               cluck("WARNING: handlerDevices(): Failed to open handler IO $handler_io, assuming disabled");
+               print "\nWARNING: handlerDevices(): Failed to open handler IO $handler_io, assuming disabled.\n\n";
                return \%devices; # Return an empty hash
        }
 
index cd1881c..b610ec7 100755 (executable)
@@ -556,35 +556,32 @@ sub writeConfiguration {
 
        # Device information
        foreach my $handler (sort keys %HANDLERS) {
-               print $io "[HANDLER ".$_REVERSE_MAP_{$handler}."]\n";
-
                if ($SCST->handlerType($handler) == $SCST::SCST::IOTYPE_VIRTUAL) {
+                       print $io "[HANDLER ".$_REVERSE_MAP_{$handler}."]\n";
                        print $io "#DEVICE <vdisk name>,<device path>";
                        if ($handler == $SCST::SCST::VDISK_TYPE) {
                                print $io ",<options>,<block size>\n";
                        } else {
                                print $io "\n";
                        }
-               } else {
-                       print $io "#DEVICE <H:C:I:L>\n";
-               }
 
-               my $devices = $SCST->handlerDevices($handler);
+                       my $devices = $SCST->handlerDevices($handler);
 
-               immediateExit($SCST->errorString());
+                       immediateExit($SCST->errorString());
 
-               foreach my $device (sort keys %{$devices}) {
-                       my $options = $$devices{$device}->{'OPTIONS'};
+                       foreach my $device (sort keys %{$devices}) {
+                               my $options = $$devices{$device}->{'OPTIONS'};
 
-                       $options =~ s/\,/\|/g;
+                               $options =~ s/\,/\|/g;
+
+                               print $io "DEVICE $device,".$$devices{$device}->{'PATH'};
+                               print $io ",$options";
+                               print $io ",".$$devices{$device}->{'BLOCKSIZE'};
+                               print $io "\n";
+                       }
 
-                       print $io "DEVICE $device,".$$devices{$device}->{'PATH'};
-                       print $io ",$options";
-                       print $io ",".$$devices{$device}->{'BLOCKSIZE'};
                        print $io "\n";
                }
-
-               print $io "\n";
        }
 
        # User configuration
@@ -1725,6 +1722,27 @@ sub findUserGroupInCurrent {
        return undef;
 }
 
+sub findDeviceGroup {
+       my $device = shift;
+       my $config = shift;
+
+       foreach my $group (keys %{$$config{'ASSIGNMENT'}}) {
+               foreach my $device (@{$$config{'ASSIGNMENT'}->{$group}->{'DEVICE'}}) {
+                       my($vname, $arg) = split(/\,/, $device, 2);
+                       $vname = cleanupString($vname);
+                       return $group if ($vname eq $device);
+               }
+       }
+
+       return undef;
+}
+
+sub findDeviceGroupInCurrent {
+       my $device = shift;
+
+       return undef;
+}
+
 sub cleanupString {
        my $string = shift;