# Author: Mark R. Buechler
# License: GPLv2
-# Copyright (c) 2005-2007 Mark R. Buechler
+# Copyright (c) 2005-2008 Mark R. Buechler
use 5.005;
use IO::Handle;
use IO::File;
use strict;
-use Carp;
+use Carp qw(cluck);
my $TRUE = 1;
my $FALSE = 0;
$IOTYPE_VIRTUAL = 101;
$IOTYPE_PERFORMANCE = 102;
-$VERSION = 0.7.4;
+$VERSION = 0.7.5;
my $_SCST_MIN_MAJOR_ = 0;
my $_SCST_MIN_MINOR_ = 9;
my %_HANDLER_ALIASES_ = ('vdisk_blk' => 'vdisk');
my %_AVAILABLE_OPTIONS_ = ('WRITE_THROUGH' => 'WRITE_THROUGH',
+ 'WT' => 'WRITE_THROUGH',
'O_DIRECT' => 'O_DIRECT',
+ 'DR' => 'O_DIRECT',
'READ_ONLY' => 'READ_ONLY',
+ 'RO' => 'READ_ONLY',
'NULLIO' => 'NULLIO',
+ 'NIO' => 'NULLIO',
'NV_CACHE' => 'NV_CACHE',
'NV' => 'NV_CACHE',
'BLOCKIO' => 'BLOCKIO',
- 'BIO' => 'BLOCKIO');
+ 'BIO' => 'BLOCKIO',
+ 'REMOVABLE' => 'REMOVABLE',
+ 'RM' => 'REMOVABLE');
sub new {
my $this = shift;
my $io = new IO::File $handler_io, O_RDONLY;
if (!$io) {
- print "WARNING: handlerDevices(): Failed to open handler IO $handler_io, assuming disabled.\n";
+ cluck("WARNING: handlerDevices(): Failed to open handler IO $handler_io, assuming disabled");
return \%devices; # Return an empty hash
}
next;
}
- my ($vname, $size, $blocksize, $options, $path) = split(/\s+/, $line);
+ my ($vname, $size, $blocksize, $options, $path) =
+ ($line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(.*?)\s+(\S+)\s*$/);
- if ($options =~ /^\//) {
- $path = $options;
- $options = "";
+ my $options_t;
+ foreach my $option (split(/\s/, cleanupString($options))) {
+ if (defined($_AVAILABLE_OPTIONS_{$option})) {
+ $options_t .= $_AVAILABLE_OPTIONS_{$option}.',';
+ } else {
+ cluck("WARNING: Unknown option '$option', please update your SCST module");
+ }
}
- $devices{$vname}->{'OPTIONS'} = cleanupString($options);
+ $options_t =~ s/\,$//;
+
+ $devices{$vname}->{'OPTIONS'} = $options_t;
+
$devices{$vname}->{'SIZE'} = cleanupString($size);
$devices{$vname}->{'PATH'} = cleanupString($path);
$devices{$vname}->{'BLOCKSIZE'} = cleanupString($blocksize);
}
$options = cleanupString($options);
+ $options =~ s/,/ /g;
my $cmd = "open $device $path $blocksize $options\n";
my $io = new IO::File $handler_io, O_WRONLY;
if (!$io) {
- print "WARNING: SCST/SCST.pm: Failed to open handler IO $handler_io, assuming disabled.\n";
+ cluck("WARNING: SCST/SCST.pm: Failed to open handler IO $handler_io, assuming disabled");
return $FALSE;
}
my $self = shift;
my $options = shift;
my $o_string;
+ my $b_string;
+ my $bad = $FALSE;
return undef, $TRUE if (!$options);
- foreach my $option (split(/\s+/, $options)) {
+ foreach my $option (split(/[\s+|\,]/, $options)) {
my $map = $_AVAILABLE_OPTIONS_{$option};
- return undef, $FALSE if (!$map);
- $o_string .= ",$map";
+
+ if (!$map) {
+ $bad = $TRUE;
+ $b_string .= ",$option";
+ } else {
+ $o_string .= ",$map";
+ }
+ }
+
+ if ($bad) {
+ $b_string =~ s/^\,//;
+ return $b_string, $FALSE;
}
$o_string =~ s/^\,//;
#!/usr/bin/perl
-$Version = 'SCST Configurator v1.0.1';
+$Version = 'SCST Configurator v1.0.2';
# Configures SCST
#
disk, vdisk, disk_perf, cdrom, vcdrom, changer, modisk, modisk_perf, tape, tape_perf
Available Options for create and open:
- WRITE_THROUGH, READ_ONLY, O_DIRECT, NULLIO, NV_CACHE, BIO
-
+ WRITE_THROUGH, READ_ONLY, O_DIRECT, NULLIO, NV_CACHE, BLOCK_IO, REMOVABLE
+
Examples:
Enable target mode for fibre card specifying its WWN
scstadmin -enable 50:06:0B:00:00:39:71:78
$showSessions = $TRUE if (defined($showSessions));
$enable =~ tr/A-Z/a-z/; $disable =~ tr/A-Z/a-z/;
+ $options =~ tr/a-z/A-Z/ if ($options);
if ((defined($showSessions) + defined($addDev) + defined($removeDev) +
defined($addUser) + defined($enable) + defined($disable) +
foreach my $device (sort keys %{$devices}) {
my $options = $$devices{$device}->{'OPTIONS'};
- $options =~ s/\,/\|/;
+
+ $options =~ s/\,/\|/g;
print $io "DEVICE $device,".$$devices{$device}->{'PATH'};
print $io ",$options";
}
}
- print "Applying configurations additions..\n" if (!$check);
+ print "Applying configuration additions..\n" if (!$check);
print "\n";
readWorkingConfig() if ($force);
foreach my $device (@{$$config{'HANDLER'}->{$_handler}->{'DEVICE'}}) {
my($vname, $path, $options, $blocksize) = split(/\,/, $device);
$path = cleanupString($path);
- $options =~ s/\s+//; $options =~ s/\|/,/;
+ $options =~ s/\s+//g;
if (defined($$DEVICES{$vname}) && ($_HANDLER_MAP_{$_handler} == $$DEVICES{$vname})) {
next;
my $options = shift;
my $blocksize = shift;
- $options =~ s/\,/ /;
-
my $_handler = $_HANDLER_MAP_{$handler};
my $htype = $SCST->handlerType($_handler);