- Add the ability to specify options (ie: READ_ONLY) in assignments in scst.conf.
[mirror/scst/.git] / scstadmin / scstadmin
index b887f29..cd1881c 100755 (executable)
@@ -552,6 +552,8 @@ sub writeConfiguration {
 
        print $io "# Automatically generated by $Version.\n\n";
 
+       print $io "# NOTE: Options are pipe (|) seperated.\n\n";
+
        # Device information
        foreach my $handler (sort keys %HANDLERS) {
                print $io "[HANDLER ".$_REVERSE_MAP_{$handler}."]\n";
@@ -600,7 +602,7 @@ sub writeConfiguration {
        # Assignments configuration
        foreach my $group (sort keys %ASSIGNMENTS) {
                print $io "[ASSIGNMENT $group]\n";
-               print $io "#DEVICE <device name>,<lun>\n";
+               print $io "#DEVICE <device name>,<lun>,<options>\n";
 
                my $pointer = $ASSIGNMENTS{$group};
                foreach my $device (sort keys %{$pointer}) {
@@ -674,9 +676,9 @@ sub applyConfiguration {
        # Cache device association configuration
        foreach my $group (keys %{$$config{'ASSIGNMENT'}}) {
                foreach my $device (@{$$config{'ASSIGNMENT'}->{$group}->{'DEVICE'}}) {
-                       my($vname, $lun) = split(/\,/, $device);
+                       my($vname, $arg) = split(/\,/, $device, 2);
                        $vname = cleanupString($vname);
-                       $used_assignments{$group}->{$vname} = $lun;
+                       $used_assignments{$group}->{$vname} = $arg;
                }
        }
 
@@ -943,7 +945,8 @@ sub applyConfiguration {
                }
 
                foreach my $vname (keys %{$used_assignments{$group}}) {
-                       my $lun = $used_assignments{$group}->{$vname};
+                       my $arg = $used_assignments{$group}->{$vname};
+                       my($lun, $options) = split(/\,/, $arg);
                        my $_assignments = $ASSIGNMENTS{$group};
 
                        if (defined($$_assignments{$vname}) && ($$_assignments{$vname} == $lun)) {
@@ -958,7 +961,7 @@ sub applyConfiguration {
                                        print "\t-> New device assignment for '$vname' to group '$group' at LUN $lun.\n";
                                        $changes++;
                                } else {
-                                       if (assignDevice($group, $vname, $lun)) {
+                                       if (assignDevice($group, $vname, $lun, $options)) {
                                                $errs++;
                                        } else {
                                                $changes++;