mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 07:08:04 +08:00
Modify canRead and CanWrite functions of fsaccess class
Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
12ab2961b1
commit
52e9dd26a6
@@ -168,23 +168,25 @@ ze_result_t FsAccess::write(const std::string file, const std::string val) {
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::canRead(const std::string file) {
|
||||
if (access(file.c_str(), F_OK)) {
|
||||
struct stat sb;
|
||||
if (statSyscall(file.c_str(), &sb) != 0) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
if (access(file.c_str(), R_OK)) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
if (sb.st_mode & S_IRUSR) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
ze_result_t FsAccess::canWrite(const std::string file) {
|
||||
if (access(file.c_str(), F_OK)) {
|
||||
struct stat sb;
|
||||
if (statSyscall(file.c_str(), &sb) != 0) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
if (access(file.c_str(), W_OK)) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
if (sb.st_mode & S_IWUSR) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
bool FsAccess::fileExists(const std::string file) {
|
||||
|
||||
@@ -55,6 +55,7 @@ class FsAccess {
|
||||
protected:
|
||||
FsAccess();
|
||||
decltype(&NEO::SysCalls::access) accessSyscall = NEO::SysCalls::access;
|
||||
decltype(&stat) statSyscall = stat;
|
||||
};
|
||||
|
||||
class ProcfsAccess : private FsAccess {
|
||||
|
||||
Reference in New Issue
Block a user