2020-02-05 17:43:02 +01:00
|
|
|
/*
|
2021-02-17 22:17:01 +01:00
|
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
2020-02-05 17:43:02 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/linux/sys_calls.h"
|
2020-02-05 17:43:02 +01:00
|
|
|
|
2021-02-23 14:03:54 +01:00
|
|
|
#include <dlfcn.h>
|
2020-02-07 14:32:02 +01:00
|
|
|
#include <fcntl.h>
|
2021-02-17 22:17:01 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <stdio.h>
|
2020-02-13 13:26:40 +01:00
|
|
|
#include <sys/ioctl.h>
|
2021-02-17 22:17:01 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/sysmacros.h>
|
2020-02-05 17:43:02 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
namespace SysCalls {
|
|
|
|
|
int close(int fileDescriptor) {
|
|
|
|
|
return ::close(fileDescriptor);
|
|
|
|
|
}
|
2020-02-07 14:32:02 +01:00
|
|
|
int open(const char *file, int flags) {
|
|
|
|
|
return ::open(file, flags);
|
|
|
|
|
}
|
2020-02-13 13:26:40 +01:00
|
|
|
int ioctl(int fileDescriptor, unsigned long int request, void *arg) {
|
|
|
|
|
return ::ioctl(fileDescriptor, request, arg);
|
|
|
|
|
}
|
2021-02-17 22:17:01 +01:00
|
|
|
|
2021-02-23 14:03:54 +01:00
|
|
|
void *dlopen(const char *filename, int flag) {
|
|
|
|
|
return ::dlopen(filename, flag);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-17 22:17:01 +01:00
|
|
|
int access(const char *pathName, int mode) {
|
|
|
|
|
return ::access(pathName, mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int readlink(const char *path, char *buf, size_t bufsize) {
|
|
|
|
|
return static_cast<int>(::readlink(path, buf, bufsize));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getDevicePath(int deviceFd, char *buf, size_t &bufSize) {
|
|
|
|
|
struct stat st;
|
|
|
|
|
if (fstat(deviceFd, &st)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snprintf(buf, bufSize, "/sys/dev/char/%d:%d",
|
|
|
|
|
major(st.st_rdev), minor(st.st_rdev));
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-02-05 17:43:02 +01:00
|
|
|
} // namespace SysCalls
|
|
|
|
|
} // namespace NEO
|