Revert "[Sysman]: Remove not used functions in fsAccess"

This reverts commit d47c1de7aa.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2023-03-02 08:53:43 +01:00
committed by Compute-Runtime-Automation
parent 5d04c15297
commit 8bce514403
4 changed files with 32 additions and 0 deletions

View File

@@ -199,6 +199,15 @@ bool FsAccess::fileExists(const std::string file) {
return true; return true;
} }
ze_result_t FsAccess::getFileMode(const std::string file, ::mode_t &mode) {
struct stat sb;
if (0 != stat(file.c_str(), &sb)) {
return getResult(errno);
}
mode = sb.st_mode;
return ZE_RESULT_SUCCESS;
}
ze_result_t FsAccess::readSymLink(const std::string path, std::string &val) { ze_result_t FsAccess::readSymLink(const std::string path, std::string &val) {
// returns the value of symlink at path // returns the value of symlink at path
char buf[PATH_MAX]; char buf[PATH_MAX];
@@ -407,6 +416,11 @@ ze_result_t SysfsAccess::canWrite(const std::string file) {
return FsAccess::canWrite(fullPath(file)); return FsAccess::canWrite(fullPath(file));
} }
ze_result_t SysfsAccess::getFileMode(const std::string file, ::mode_t &mode) {
// Prepend sysfs directory path and call the base getFileMode
return FsAccess::getFileMode(fullPath(file), mode);
}
ze_result_t SysfsAccess::read(const std::string file, std::string &val) { ze_result_t SysfsAccess::read(const std::string file, std::string &val) {
// Prepend sysfs directory path and call the base read // Prepend sysfs directory path and call the base read
return FsAccess::read(fullPath(file).c_str(), val); return FsAccess::read(fullPath(file).c_str(), val);

View File

@@ -33,6 +33,7 @@ class FsAccess {
virtual ze_result_t canRead(const std::string file); virtual ze_result_t canRead(const std::string file);
virtual ze_result_t canWrite(const std::string file); virtual ze_result_t canWrite(const std::string file);
virtual ze_result_t getFileMode(const std::string file, ::mode_t &mode);
virtual ze_result_t read(const std::string file, uint64_t &val); virtual ze_result_t read(const std::string file, uint64_t &val);
virtual ze_result_t read(const std::string file, std::string &val); virtual ze_result_t read(const std::string file, std::string &val);
@@ -89,6 +90,7 @@ class SysfsAccess : protected FsAccess {
ze_result_t canRead(const std::string file) override; ze_result_t canRead(const std::string file) override;
ze_result_t canWrite(const std::string file) override; ze_result_t canWrite(const std::string file) override;
ze_result_t getFileMode(const std::string file, ::mode_t &mode) override;
ze_result_t read(const std::string file, std::string &val) override; ze_result_t read(const std::string file, std::string &val) override;
ze_result_t read(const std::string file, int32_t &val) override; ze_result_t read(const std::string file, int32_t &val) override;

View File

@@ -198,6 +198,15 @@ bool FsAccess::fileExists(const std::string file) {
return true; return true;
} }
ze_result_t FsAccess::getFileMode(const std::string file, ::mode_t &mode) {
struct stat sb;
if (0 != stat(file.c_str(), &sb)) {
return getResult(errno);
}
mode = sb.st_mode;
return ZE_RESULT_SUCCESS;
}
ze_result_t FsAccess::readSymLink(const std::string path, std::string &val) { ze_result_t FsAccess::readSymLink(const std::string path, std::string &val) {
// returns the value of symlink at path // returns the value of symlink at path
char buf[PATH_MAX]; char buf[PATH_MAX];
@@ -406,6 +415,11 @@ ze_result_t SysfsAccess::canWrite(const std::string file) {
return FsAccess::canWrite(fullPath(file)); return FsAccess::canWrite(fullPath(file));
} }
ze_result_t SysfsAccess::getFileMode(const std::string file, ::mode_t &mode) {
// Prepend sysfs directory path and call the base getFileMode
return FsAccess::getFileMode(fullPath(file), mode);
}
ze_result_t SysfsAccess::read(const std::string file, std::string &val) { ze_result_t SysfsAccess::read(const std::string file, std::string &val) {
// Prepend sysfs directory path and call the base read // Prepend sysfs directory path and call the base read
return FsAccess::read(fullPath(file).c_str(), val); return FsAccess::read(fullPath(file).c_str(), val);

View File

@@ -32,6 +32,7 @@ class FsAccess {
virtual ze_result_t canRead(const std::string file); virtual ze_result_t canRead(const std::string file);
virtual ze_result_t canWrite(const std::string file); virtual ze_result_t canWrite(const std::string file);
virtual ze_result_t getFileMode(const std::string file, ::mode_t &mode);
virtual ze_result_t read(const std::string file, uint64_t &val); virtual ze_result_t read(const std::string file, uint64_t &val);
virtual ze_result_t read(const std::string file, std::string &val); virtual ze_result_t read(const std::string file, std::string &val);
@@ -88,6 +89,7 @@ class SysfsAccess : protected FsAccess {
ze_result_t canRead(const std::string file) override; ze_result_t canRead(const std::string file) override;
ze_result_t canWrite(const std::string file) override; ze_result_t canWrite(const std::string file) override;
ze_result_t getFileMode(const std::string file, ::mode_t &mode) override;
ze_result_t read(const std::string file, std::string &val) override; ze_result_t read(const std::string file, std::string &val) override;
ze_result_t read(const std::string file, int32_t &val) override; ze_result_t read(const std::string file, int32_t &val) override;