scstadmin: Remove support for the "new" sysfs interface

Around 2011 a sysfs-tree-changes branch was created in the SourceForge
repository because Greg KH asked to rework the SCST sysfs interface. That
interface is called the "new" sysfs interface. The current and only used
API is called the "old" sysfs interface. Since the "new" sysfs interface
never had any users other than myself, remove support for that interface.

See also commit a66cbc4115 ("scstadmin: Add support for the sysfs
interface provided by the code on the sysfs-tree-changes branch").


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9151 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2020-09-13 03:12:26 +00:00
parent ad546b1e68
commit a3266ca8f2
@@ -21,28 +21,15 @@ use constant {
TRUE => 1, TRUE => 1,
FALSE => 0, FALSE => 0,
SCST_ROOT_OLD => '/sys/kernel/scst_tgt', SCST_ROOT => '/sys/kernel/scst_tgt',
SCST_ROOT_NEW => '/sys/devices/scst',
# Root-level # Root-level
SCST_SGV => 'sgv', SCST_SGV => 'sgv',
# Root level, old sysfs interface
SCST_HANDLERS => 'handlers', SCST_HANDLERS => 'handlers',
SCST_DEVICES => 'devices', SCST_DEVICES => 'devices',
SCST_TARGETS => 'targets', SCST_TARGETS => 'targets',
SCST_DEV_GROUPS => 'device_groups', SCST_DEV_GROUPS => 'device_groups',
SCST_QUEUE_RES => 'last_sysfs_mgmt_res', SCST_QUEUE_RES => 'last_sysfs_mgmt_res',
# Root level, new sysfs interface
IN_SCST_HANDLERS => 'device_driver',
IN_SCST_DEVICES => 'device',
IN_SCST_TARGETS => 'target_driver',
IN_SCST_DEV_GROUPS => 'device_groups',
SCST_ADD_TGT => 'add_target',
SCST_ADD_TGT_PARAMS => 'add_target_parameters',
SCST_TGTT_ATTR => 'driver_attributes',
SCST_TGT_ATTR => 'target_attributes',
SCST_ADD_DEV_PARAMS => 'add_device_parameters',
SCST_PARAM_ATTR => 'parameters',
# Device group specific # Device group specific
SCST_DG_DEVICES => 'devices', SCST_DG_DEVICES => 'devices',
@@ -301,82 +288,36 @@ my $_SCST_MIN_MAJOR_ = 2;
my $_SCST_MIN_MINOR_ = 0; my $_SCST_MIN_MINOR_ = 0;
my $_SCST_MIN_RELEASE_ = 0; my $_SCST_MIN_RELEASE_ = 0;
my $_new_sysfs_interface;
sub new_sysfs_interface {
if (!defined($_new_sysfs_interface)) {
$_new_sysfs_interface = !(-d SCST_ROOT_OLD) ? TRUE : FALSE;
}
return $_new_sysfs_interface;
}
my $_scst_root_dir;
sub SCST_ROOT_DIR { sub SCST_ROOT_DIR {
if (!defined($_scst_root_dir)) { return SCST_ROOT;
$_scst_root_dir = (-d SCST_ROOT_OLD ? SCST_ROOT_OLD :
SCST_ROOT_NEW);
}
return $_scst_root_dir;
} }
my $_scst_sgv_dir;
sub SCST_SGV_DIR { sub SCST_SGV_DIR {
if (!defined($_scst_sgv_dir)) { return SCST_ROOT . '/sgv';
$_scst_sgv_dir = SCST_ROOT_DIR() . '/sgv';
}
return $_scst_sgv_dir;
} }
my $_scst_queue_res_path = "";
sub SCST_QUEUE_RES_PATH { sub SCST_QUEUE_RES_PATH {
if ($_scst_queue_res_path eq "") { return SCST_ROOT . '/' . SCST_QUEUE_RES;
$_scst_queue_res_path = (-d SCST_ROOT_OLD ?
SCST_ROOT_OLD . '/' . SCST_QUEUE_RES :
undef);
}
return $_scst_queue_res_path;
} }
# Device handlers. # Device handlers.
my $_scst_handlers_dir;
sub SCST_HANDLERS_DIR { sub SCST_HANDLERS_DIR {
if (!defined($_scst_handlers_dir)) { return SCST_ROOT . '/' . SCST_HANDLERS;
$_scst_handlers_dir = (-d SCST_ROOT_OLD ?
SCST_ROOT_OLD . '/' . SCST_HANDLERS :
'/sys/bus/scst_tgt_dev/drivers');
}
return $_scst_handlers_dir;
} }
# Device instances. # Device instances.
my $_scst_devices_dir;
sub SCST_DEVICES_DIR { sub SCST_DEVICES_DIR {
if (!defined($_scst_devices_dir)) { return SCST_ROOT . '/' . SCST_DEVICES;
$_scst_devices_dir = (-d SCST_ROOT_OLD ?
SCST_ROOT_OLD . '/' . SCST_DEVICES :
'/sys/bus/scst_tgt_dev/devices');
}
return $_scst_devices_dir;
} }
# Target drivers. # Target drivers.
my $_scst_targets_dir;
sub SCST_TARGETS_DIR { sub SCST_TARGETS_DIR {
if (!defined($_scst_targets_dir)) { return SCST_ROOT . '/' . SCST_TARGETS;
$_scst_targets_dir = (-d SCST_ROOT_OLD ?
SCST_ROOT_OLD . '/' . SCST_TARGETS :
'/sys/bus/scst_target/drivers');
}
return $_scst_targets_dir;
} }
# ALUA Device groups. # ALUA Device groups.
my $_scst_dev_group_dir;
sub SCST_DEV_GROUP_DIR { sub SCST_DEV_GROUP_DIR {
if (!defined($_scst_dev_group_dir)) { return SCST_ROOT . '/' . SCST_DEV_GROUPS;
$_scst_dev_group_dir = make_path(SCST_ROOT_DIR(),
SCST_DEV_GROUPS);
}
return $_scst_dev_group_dir;
} }
sub new { sub new {
@@ -463,8 +404,7 @@ sub scstAttributes {
chomp $value; chomp $value;
my $is_key = <$io>; my $is_key = <$io>;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -790,8 +730,7 @@ sub aluaAttributes {
my $second_line = <$io>; my $second_line = <$io>;
$second_line = "" if (!defined($second_line)); $second_line = "" if (!defined($second_line));
if (new_sysfs_interface() && !$is_static if ($second_line =~ /\[key\]/) {
|| ($second_line =~ /\[key\]/)) {
my $key = 0; my $key = 0;
if ($attribute =~ /^([^\d]+)(\d+)$/) { if ($attribute =~ /^([^\d]+)(\d+)$/) {
$attribute = $1; $attribute = $1;
@@ -958,17 +897,6 @@ sub driverDynamicAttributes {
return (undef, "Too few arguments") if (!defined($driver)); return (undef, "Too few arguments") if (!defined($driver));
if (new_sysfs_interface()) {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
SCST_TGTT_ATTR), O_RDONLY;
if ($io) {
while (my $attribute = <$io>) {
chomp($attribute);
$attributes{$attribute} = '';
}
close $io;
}
} else {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver, my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
SCST_MGMT_IO), O_RDONLY; SCST_MGMT_IO), O_RDONLY;
@@ -998,7 +926,6 @@ sub driverDynamicAttributes {
$attributes{$attribute} = ''; $attributes{$attribute} = '';
} }
} }
}
return (\%attributes, undef); return (\%attributes, undef);
} }
@@ -1045,12 +972,7 @@ sub addDriverDynamicAttribute {
if (!defined($driver) || !defined($attribute) || !defined($value)); if (!defined($driver) || !defined($attribute) || !defined($value));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
}
$cmd .= "add_attribute $attribute $value"; $cmd .= "add_attribute $attribute $value";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1088,12 +1010,7 @@ sub removeDriverDynamicAttribute {
if (!defined($driver) || !defined($attribute) || !defined($value)); if (!defined($driver) || !defined($attribute) || !defined($value));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
}
$cmd .= "del_attribute $attribute $value"; $cmd .= "del_attribute $attribute $value";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1134,22 +1051,9 @@ sub targetExists {
sub driverIsVirtualCapable { sub driverIsVirtualCapable {
my $self = shift; my $self = shift;
my $driver = shift; my $driver = shift;
if (new_sysfs_interface()) {
my $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_ADD_TGT);
my $io = new IO::File $path, O_RDONLY;
if ($io) {
my $line = <$io>;
close $io;
chomp($line);
return $line eq '1';
}
return FALSE;
} else {
my $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); my $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
return (-w $path) ? TRUE : FALSE; return (-w $path) ? TRUE : FALSE;
} }
}
sub targetType { sub targetType {
my $self = shift; my $self = shift;
@@ -1195,12 +1099,7 @@ sub addVirtualTarget {
$o_string =~ s/\s$//; $o_string =~ s/\s$//;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
}
$cmd .= "add_target $target $o_string"; $cmd .= "add_target $target $o_string";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1241,17 +1140,6 @@ sub targetDynamicAttributes {
return (undef, "Too few arguments") if (!defined($driver)); return (undef, "Too few arguments") if (!defined($driver));
if (new_sysfs_interface()) {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
SCST_TGT_ATTR), O_RDONLY;
if ($io) {
while (my $attribute = <$io>) {
chomp($attribute);
$attributes{$attribute} = '';
}
close $io;
}
} else {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver, my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
SCST_MGMT_IO), O_RDONLY; SCST_MGMT_IO), O_RDONLY;
@@ -1281,7 +1169,6 @@ sub targetDynamicAttributes {
$attributes{$attribute} = ''; $attributes{$attribute} = '';
} }
} }
}
return (\%attributes, undef); return (\%attributes, undef);
} }
@@ -1330,12 +1217,7 @@ sub addTargetDynamicAttribute {
!defined($attribute) || !defined($value)); !defined($attribute) || !defined($value));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
}
$cmd .= "add_target_attribute $target $attribute $value"; $cmd .= "add_target_attribute $target $attribute $value";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1379,12 +1261,7 @@ sub removeTargetDynamicAttribute {
!defined($attribute) || !defined($value)); !defined($attribute) || !defined($value));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
}
$cmd .= "del_target_attribute $target $attribute $value"; $cmd .= "del_target_attribute $target $attribute $value";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1456,12 +1333,7 @@ sub removeVirtualTarget {
} }
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO); $path = make_path(SCST_TARGETS_DIR(), $driver, SCST_MGMT_IO);
}
$cmd .= "del_target $target"; $cmd .= "del_target $target";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1587,14 +1459,8 @@ sub addGroup {
!defined($group)); !defined($group));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, SCST_MGMT_IO);
}
$cmd .= "create $group"; $cmd .= "create $group";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1634,14 +1500,8 @@ sub removeGroup {
!defined($group)); !defined($group));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS) . " ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, SCST_MGMT_IO);
}
$cmd .= "del $group"; $cmd .= "del $group";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1678,12 +1538,7 @@ sub addDeviceGroup {
return SCST_C_DEV_GRP_ADD_FAIL if (!defined($group)); return SCST_C_DEV_GRP_ADD_FAIL if (!defined($group));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), SCST_MGMT_IO); $path = make_path(SCST_DEV_GROUP_DIR(), SCST_MGMT_IO);
}
$cmd .= "create $group"; $cmd .= "create $group";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1710,12 +1565,7 @@ sub removeDeviceGroup {
return SCST_C_DEV_GRP_REM_FAIL if (!defined($group)); return SCST_C_DEV_GRP_REM_FAIL if (!defined($group));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), SCST_MGMT_IO); $path = make_path(SCST_DEV_GROUP_DIR(), SCST_MGMT_IO);
}
$cmd .= "del $group"; $cmd .= "del $group";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1747,13 +1597,8 @@ sub addDeviceGroupDevice {
return SCST_C_DGRP_ADD_DEV_FAIL if (!defined($group) || !defined($device)); return SCST_C_DGRP_ADD_DEV_FAIL if (!defined($group) || !defined($device));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_DEVICES,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS, $group,
SCST_DG_DEVICES) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_DEVICES, SCST_MGMT_IO);
}
$cmd .= "add $device"; $cmd .= "add $device";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1803,13 +1648,8 @@ sub addTargetGroup {
!defined($tgroup)); !defined($tgroup));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS, $group,
SCST_DG_TGROUPS) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, SCST_MGMT_IO);
}
$cmd .= "add $tgroup"; $cmd .= "add $tgroup";
my $bytes = - ENONENT; my $bytes = - ENONENT;
@@ -1844,14 +1684,8 @@ sub addTargetGroupTarget {
!defined($tgt)); !defined($tgt));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS, $group,
SCST_DG_TGROUPS, $tgroup) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS,
$tgroup, SCST_MGMT_IO); $tgroup, SCST_MGMT_IO);
}
$cmd .= "add $tgt"; $cmd .= "add $tgt";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1886,13 +1720,8 @@ sub removeDeviceGroupDevice {
return SCST_C_DGRP_REM_DEV_FAIL if (!defined($group) || !defined($device)); return SCST_C_DGRP_REM_DEV_FAIL if (!defined($group) || !defined($device));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_DEVICES,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS, $group,
SCST_DG_DEVICES) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_DEVICES, SCST_MGMT_IO);
}
$cmd .= "del $device"; $cmd .= "del $device";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1930,13 +1759,8 @@ sub removeTargetGroup {
return SCST_C_DGRP_REM_GRP_FAIL if (!defined($group) || !defined($tgroup)); return SCST_C_DGRP_REM_GRP_FAIL if (!defined($group) || !defined($tgroup));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS, $group,
SCST_DG_TGROUPS) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, SCST_MGMT_IO);
}
$cmd .= "del $tgroup"; $cmd .= "del $tgroup";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -1971,14 +1795,8 @@ sub removeTargetGroupTarget {
return SCST_C_TGRP_REM_TGT_FAIL if (!defined($group) || !defined($tgroup) || !defined($tgt)); return SCST_C_TGRP_REM_TGT_FAIL if (!defined($group) || !defined($tgroup) || !defined($tgt));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEV_GROUPS, $group,
SCST_DG_TGROUPS, $tgroup) . " ";
} else {
$path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS, $path = make_path(SCST_DEV_GROUP_DIR(), $group, SCST_DG_TGROUPS,
$tgroup, SCST_MGMT_IO); $tgroup, SCST_MGMT_IO);
}
$cmd .= "del $tgt"; $cmd .= "del $tgt";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2020,16 +1838,8 @@ sub addInitiator {
!defined($group) || !defined($initiator)); !defined($group) || !defined($initiator));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); $group, SCST_INITIATORS, SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $group, SCST_INITIATORS) .
" ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_INITIATORS,
SCST_MGMT_IO);
}
$cmd .= "add $initiator"; $cmd .= "add $initiator";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2077,16 +1887,8 @@ sub removeInitiator {
return SCST_C_GRP_REM_INI_FAIL if (!defined($driver) || !defined($target) || !defined($group) || !defined($initiator)); return SCST_C_GRP_REM_INI_FAIL if (!defined($driver) || !defined($target) || !defined($group) || !defined($initiator));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); $group, SCST_INITIATORS, SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $group, SCST_INITIATORS) .
" ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_INITIATORS,
SCST_MGMT_IO);
}
$cmd .= "del $initiator"; $cmd .= "del $initiator";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2129,16 +1931,8 @@ sub moveInitiator {
my $initiator = shift; my $initiator = shift;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); $from, SCST_INITIATORS, SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $from, SCST_INITIATORS) .
" ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $from, SCST_INITIATORS,
SCST_MGMT_IO);
}
$cmd .= "move $initiator $to"; $cmd .= "move $initiator $to";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2187,16 +1981,8 @@ sub clearInitiators {
my $group = shift; my $group = shift;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); $group, SCST_INITIATORS, SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $group, SCST_INITIATORS) .
" ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_INITIATORS,
SCST_MGMT_IO);
}
$cmd .= "clear"; $cmd .= "clear";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2251,26 +2037,13 @@ sub addLun {
$o_string =~ s/\s$//; $o_string =~ s/\s$//;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
if (defined($group)) {
$cmd = "in " .
make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $group, SCST_LUNS) . " ";
} else {
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver,
$target, SCST_LUNS) . " ";
}
} else {
if (defined($group)) { if (defined($group)) {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target, $path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_LUNS, SCST_GROUPS, $group, SCST_LUNS, SCST_MGMT_IO);
SCST_MGMT_IO);
} else { } else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target, $path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_LUNS, SCST_MGMT_IO); SCST_LUNS, SCST_MGMT_IO);
} }
}
$cmd .= "add $device $lun $o_string"; $cmd .= "add $device $lun $o_string";
@@ -2330,17 +2103,6 @@ sub removeLun {
!defined($lun)); !defined($lun));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
if (defined($group)) {
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver,
$target, SCST_GROUPS, $group,
SCST_LUNS) . " ";
} else {
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver,
$target, SCST_LUNS) . " ";
}
} else {
if (defined($group)) { if (defined($group)) {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target, $path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_LUNS, SCST_GROUPS, $group, SCST_LUNS,
@@ -2349,7 +2111,6 @@ sub removeLun {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target, $path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_LUNS, SCST_MGMT_IO); SCST_LUNS, SCST_MGMT_IO);
} }
}
$cmd .= "del $lun"; $cmd .= "del $lun";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2442,26 +2203,8 @@ sub replaceLun {
$o_string =~ s/\s$//; $o_string =~ s/\s$//;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_LUNS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
if (defined($group)) {
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver,
$target, SCST_GROUPS,
$group, SCST_LUNS) . " ";
} else {
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver,
$target, SCST_LUNS) . " ";
}
} else {
if (defined($group)) {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_LUNS,
SCST_MGMT_IO); SCST_MGMT_IO);
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_LUNS, SCST_MGMT_IO);
}
}
$cmd .= "replace $device $lun $o_string"; $cmd .= "replace $device $lun $o_string";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2491,17 +2234,6 @@ sub clearLuns {
return $err if (!defined($driver) || !defined($target)); return $err if (!defined($driver) || !defined($target));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
if (defined($group)) {
$cmd = "in " .
make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $group, SCST_LUNS) . " ";
} else {
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver,
$target, SCST_LUNS) . " ";
}
} else {
if (defined($group)) { if (defined($group)) {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target, $path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_LUNS, SCST_GROUPS, $group, SCST_LUNS,
@@ -2510,7 +2242,6 @@ sub clearLuns {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target, $path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_LUNS, SCST_MGMT_IO); SCST_LUNS, SCST_MGMT_IO);
} }
}
$cmd .= "clear"; $cmd .= "clear";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -2547,7 +2278,7 @@ sub deviceHandler {
my $device = shift; my $device = shift;
my $handler = readlink(make_path(SCST_DEVICES_DIR(), $device, my $handler = readlink(make_path(SCST_DEVICES_DIR(), $device,
new_sysfs_interface() ? 'driver' : 'handler')); 'handler'));
$handler =~ s/.*\///; $handler =~ s/.*\///;
return $handler; return $handler;
} }
@@ -2558,8 +2289,8 @@ sub devices {
my @devices; my @devices;
my $dHandle = new IO::Handle; my $dHandle = new IO::Handle;
my $_path = new_sysfs_interface() || !defined($handler) ? my $_path = !defined($handler) ? SCST_DEVICES_DIR() :
SCST_DEVICES_DIR() : make_path(SCST_HANDLERS_DIR(), $handler); make_path(SCST_HANDLERS_DIR(), $handler);
if (!(opendir $dHandle, $_path)) { if (!(opendir $dHandle, $_path)) {
return (undef, "devices(): Unable to read directory '$_path': $!"); return (undef, "devices(): Unable to read directory '$_path': $!");
} }
@@ -2567,8 +2298,7 @@ sub devices {
foreach my $device (readdir($dHandle)) { foreach my $device (readdir($dHandle)) {
next if ($device eq '.' || $device eq '..'); next if ($device eq '.' || $device eq '..');
my $isdev = (new_sysfs_interface() || my $isdev = (-d make_path(SCST_DEVICES_DIR(), $device));
-d make_path(SCST_DEVICES_DIR(), $device));
if ($isdev && (!defined($handler) || if ($isdev && (!defined($handler) ||
$handler eq $self->deviceHandler($device))) { $handler eq $self->deviceHandler($device))) {
push @devices, $device; push @devices, $device;
@@ -2699,9 +2429,7 @@ sub deviceAttributes {
$value = "" if (!defined($value)); $value = "" if (!defined($value));
chomp $value; chomp $value;
$is_key = new_sysfs_interface() && $is_key = $is_key && $is_key =~ /\[key\]/;
(!$is_static || defined($$dca{$attribute}))
|| $is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -2785,8 +2513,7 @@ sub driverAttributes {
chomp $value; chomp $value;
my $is_key = <$io>; my $is_key = <$io>;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -2943,8 +2670,7 @@ sub targetAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -2982,18 +2708,8 @@ sub setTargetAttribute {
return TRUE if (!defined($attribute) || !defined($value)); return TRUE if (!defined($attribute) || !defined($value));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface() && $path = make_path(SCST_TARGETS_DIR(), $driver, $target, $attribute);
($attribute eq 'enabled' || $attribute eq 'cpu_mask')) {
$path = make_path(SCST_ROOT_DIR, SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target) .
" " . ($attribute eq 'enabled' ?
($value eq '1' ? 'enable' : 'disable') :
"set_$attribute $value");
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
$attribute);
$cmd = $value; $cmd = $value;
}
my $bytes = - ENOENT; my $bytes = - ENOENT;
my $io = new IO::File $path, O_WRONLY; my $io = new IO::File $path, O_WRONLY;
@@ -3078,8 +2794,7 @@ sub groupAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -3118,15 +2833,8 @@ sub setGroupAttribute {
return TRUE if (!defined($attribute) || !defined($value)); return TRUE if (!defined($attribute) || !defined($value));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface() && $attribute eq 'cpu_mask') { $path = make_path(SCST_TARGETS_DIR(), $driver, $target, SCST_GROUPS,
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO); $group, $attribute);
$cmd = "in " . make_path(IN_SCST_TARGETS, $driver, $target,
SCST_GROUPS, $group) .
" set_$attribute ";
} else {
$path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, $attribute);
}
$cmd .= $value; $cmd .= $value;
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -3234,10 +2942,7 @@ sub lunAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && $is_key = $is_key && $is_key =~ /\[key\]/;
(!$is_static ||
defined($$luncrattr{$attribute})) ||
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -3389,8 +3094,7 @@ sub initiatorAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -3512,8 +3216,7 @@ sub deviceGroupAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -3593,8 +3296,7 @@ sub targetGroupAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -3683,8 +3385,7 @@ sub targetGroupTargetAttributes {
my $is_key = <$io>; my $is_key = <$io>;
close $io; close $io;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -3962,8 +3663,7 @@ sub handlerAttributes {
chomp $value; chomp $value;
my $is_key = <$io>; my $is_key = <$io>;
$is_key = new_sysfs_interface() && !$is_static || $is_key = $is_key && $is_key =~ /\[key\]/;
$is_key && $is_key =~ /\[key\]/;
my $key = 0; my $key = 0;
if ($is_key) { if ($is_key) {
@@ -4121,16 +3821,6 @@ sub deviceCreateAttributes {
my %attributes = ( ); my %attributes = ( );
my $errorString; my $errorString;
if (new_sysfs_interface()) {
my $io = new IO::File make_path(SCST_HANDLERS_DIR(), $handler,
SCST_ADD_DEV_PARAMS), O_RDONLY;
while (my $attribute = <$io>) {
chomp($attribute);
$attributes{$attribute} = '';
}
close $io;
} else {
my $io = new IO::File make_path(SCST_HANDLERS_DIR(), $handler, my $io = new IO::File make_path(SCST_HANDLERS_DIR(), $handler,
SCST_MGMT_IO), O_RDONLY; SCST_MGMT_IO), O_RDONLY;
@@ -4160,7 +3850,6 @@ sub deviceCreateAttributes {
$attributes{$attribute} = ''; $attributes{$attribute} = '';
} }
} }
}
return (\%attributes, undef); return (\%attributes, undef);
} }
@@ -4184,12 +3873,7 @@ sub openDevice {
$o_string =~ s/\s$//; $o_string =~ s/\s$//;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_HANDLERS, $handler) . " ";
} else {
$path = make_path(SCST_HANDLERS_DIR(), $handler, SCST_MGMT_IO); $path = make_path(SCST_HANDLERS_DIR(), $handler, SCST_MGMT_IO);
}
$cmd .= "add_device $device $o_string"; $cmd .= "add_device $device $o_string";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -4232,12 +3916,7 @@ sub closeDevice {
!defined($device)); !defined($device));
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface()) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_HANDLERS, $handler) . " ";
} else {
$path = make_path(SCST_HANDLERS_DIR(), $handler, SCST_MGMT_IO); $path = make_path(SCST_HANDLERS_DIR(), $handler, SCST_MGMT_IO);
}
$cmd .= "del_device $device"; $cmd .= "del_device $device";
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -4272,15 +3951,7 @@ sub setDeviceAttribute {
my $value = shift; my $value = shift;
my ($path, $cmd); my ($path, $cmd);
if (new_sysfs_interface() &&
($attribute eq 'filename' ||
$attribute eq 'threads_num' ||
$attribute eq 'threads_pool_type')) {
$path = make_path(SCST_ROOT_DIR(), SCST_MGMT_IO);
$cmd = "in " . make_path(IN_SCST_DEVICES, $device) . " set_$attribute ";
} else {
$path = make_path(SCST_DEVICES_DIR(), $device, $attribute); $path = make_path(SCST_DEVICES_DIR(), $device, $attribute);
}
$cmd .= $value; $cmd .= $value;
my $bytes = - ENOENT; my $bytes = - ENOENT;
@@ -4341,15 +4012,6 @@ sub targetCreateAttributes {
my %attributes = ( ); my %attributes = ( );
my $errorString; my $errorString;
if (new_sysfs_interface()) {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
SCST_ADD_TGT_PARAMS), O_RDONLY;
while (my $attribute = <$io>) {
chomp($attribute);
$attributes{$attribute} = '';
}
close $io;
} else {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver, my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
SCST_MGMT_IO), O_RDONLY; SCST_MGMT_IO), O_RDONLY;
@@ -4379,7 +4041,6 @@ sub targetCreateAttributes {
$attributes{$attribute} = ''; $attributes{$attribute} = '';
} }
} }
}
return (\%attributes, undef); return (\%attributes, undef);
} }
@@ -4535,28 +4196,6 @@ sub lunCreateAttributes {
my $_path; my $_path;
if (new_sysfs_interface()) {
if (defined($group)) {
if ($self->groupExists($driver, $target, $group) != TRUE) {
return ("lunCreateAttributes(): Group '$group' ".
"does not exist");
}
$_path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_LUNS,
SCST_PARAM_ATTR);
} else {
$_path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_LUNS, SCST_PARAM_ATTR);
}
my $io = new IO::File $_path, O_RDONLY;
while (my $attribute = <$io>) {
chomp($attribute);
$attributes{$attribute} = '';
}
close $io;
} else {
if (defined($group)) { if (defined($group)) {
$_path = make_path(SCST_TARGETS_DIR(), $driver, $target, $_path = make_path(SCST_TARGETS_DIR(), $driver, $target,
SCST_GROUPS, $group, SCST_LUNS, SCST_GROUPS, $group, SCST_LUNS,
@@ -4600,7 +4239,6 @@ sub lunCreateAttributes {
$attributes{$attribute} = ''; $attributes{$attribute} = '';
} }
} }
}
return (\%attributes, undef); return (\%attributes, undef);
} }
@@ -4655,9 +4293,6 @@ sub initiatorCreateAttributes {
my %attributes = ( ); my %attributes = ( );
my $errorString; my $errorString;
if (new_sysfs_interface()) {
# Do nothing - there are no initiator attributes (yet).
} else {
my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver, my $io = new IO::File make_path(SCST_TARGETS_DIR(), $driver,
$target, SCST_GROUPS, $group, $target, SCST_GROUPS, $group,
SCST_INITIATORS, SCST_MGMT_IO), SCST_INITIATORS, SCST_MGMT_IO),
@@ -4695,7 +4330,6 @@ sub initiatorCreateAttributes {
$attributes{$attribute} = ''; $attributes{$attribute} = '';
} }
} }
}
return (\%attributes, undef); return (\%attributes, undef);
} }