scstadmin: Fix the readOnly() subroutine

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9157 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2020-09-14 01:54:26 +00:00
parent c121a6ded8
commit 7e3fe7a80e
2 changed files with 6 additions and 2 deletions

View File

@@ -359,7 +359,11 @@ sub readOnly {
my ($path) = @_;
my $mode = (stat($path))[2];
return ($mode & S_IWUSR) != 0;
if (!defined($mode)) {
cluck("invalid path $path");
return undef;
}
return ($mode & S_IWUSR) == 0;
}
sub scstVersion {

View File

@@ -30,7 +30,7 @@ ok($SCST->setScstAttribute('no-such-attribute', '1'),
$SCST->SCST_C_BAD_ATTRIBUTES);
ok($SCST->setScstAttribute('last_sysfs_mgmt_res', '1'),
$SCST->SCST_C_SETATTR_FAIL);
$SCST->SCST_C_ATTRIBUTE_STATIC);
my $threads = getScstThreadCount($SCST);
ok(ref(\$threads), "SCALAR");