feature: Add FsAccess and Derived class in Sysman Kmd Interface

- The FsAccess, ProcFsAccess and SysfsAccess classes have been added in
a file in the Sysman Shared directory. The instances of these classes
are maintained in the Sysman Kmd Interface classes.
- Added functions for opendir, readdir and closedir in the shared code.
- Added a ULT in the sysman directory to cover these new functions from
the shared code.

Related-To: LOCI-4689

Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
Bari, Pratik
2023-08-09 09:03:06 +00:00
committed by Compute-Runtime-Automation
parent e77e49853b
commit f9e4381c1e
15 changed files with 879 additions and 93 deletions

View File

@@ -58,6 +58,9 @@ int mkstempCalled = 0;
int renameCalled = 0;
int pathFileExistsCalled = 0;
int flockCalled = 0;
int opendirCalled = 0;
int readdirCalled = 0;
int closedirCalled = 0;
std::vector<void *> mmapVector(64);
std::vector<void *> mmapCapturedExtendedPointers(64);
@@ -92,6 +95,9 @@ int (*sysCallsStat)(const std::string &filePath, struct stat *statbuf) = nullptr
int (*sysCallsMkstemp)(char *fileName) = nullptr;
int (*sysCallsMkdir)(const std::string &dir) = nullptr;
bool (*sysCallsPathExists)(const std::string &path) = nullptr;
DIR *(*sysCallsOpendir)(const char *name) = nullptr;
struct dirent *(*sysCallsReaddir)(DIR *dir) = nullptr;
int (*sysCallsClosedir)(DIR *dir) = nullptr;
int mkdir(const std::string &path) {
if (sysCallsMkdir != nullptr) {
@@ -413,5 +419,32 @@ int stat(const std::string &filePath, struct stat *statbuf) {
return 0;
}
DIR *opendir(const char *name) {
opendirCalled++;
if (sysCallsOpendir != nullptr) {
return sysCallsOpendir(name);
}
return nullptr;
}
struct dirent *readdir(DIR *dir) {
readdirCalled++;
if (sysCallsReaddir != nullptr) {
return sysCallsReaddir(dir);
}
return nullptr;
}
int closedir(DIR *dir) {
closedirCalled++;
if (sysCallsClosedir != nullptr) {
return sysCallsClosedir(dir);
}
return 0;
}
} // namespace SysCalls
} // namespace NEO

View File

@@ -41,6 +41,9 @@ extern int (*sysCallsUnlink)(const std::string &pathname);
extern int (*sysCallsStat)(const std::string &filePath, struct stat *statbuf);
extern int (*sysCallsMkstemp)(char *fileName);
extern bool (*sysCallsPathExists)(const std::string &path);
extern DIR *(*sysCallsOpendir)(const char *name);
extern struct dirent *(*sysCallsReaddir)(DIR *dir);
extern int (*sysCallsClosedir)(DIR *dir);
extern int flockRetVal;
extern int closeFuncRetVal;