Add ioctl to filemanagement

This commit is contained in:
Ryan Houdek 2019-10-09 17:32:49 -07:00 committed by Stefanos Kornilios Mitsis Poiitidis
parent e59a6fcd5d
commit 47d91e05f0
2 changed files with 18 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#include "Interface/HLE/FileManagement.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <unistd.h>
namespace FEXCore {
@ -12,6 +13,7 @@ class STDFD final : public FD {
public:
STDFD(FEXCore::Context::Context *ctx, int32_t fd, const char *pathname, int32_t flags, mode_t mode)
: FD (ctx, fd, pathname, flags, mode) {
HostFD = fd;
}
ssize_t writev(int fd, void *iov, int iovcnt) override {
@ -49,10 +51,6 @@ public:
LogMan::Msg::ERR("%s", reinterpret_cast<char*>(buf));
return count;
}
uint64_t read(int fd, void *buf, size_t count) {
return ::read(HostFD, buf, count);
}
};
uint64_t FD::read(int fd, void *buf, size_t count) {
@ -96,6 +94,10 @@ int FD::close(int fd) {
return ::close(HostFD);
}
int FD::ioctl(int fd, uint64_t request, void *args) {
return ::ioctl(HostFD, request, args);
}
FileManager::FileManager(FEXCore::Context::Context *ctx)
: CTX {ctx} {
@ -227,6 +229,15 @@ uint64_t FileManager::Openat([[maybe_unused]] int dirfs, const char *pathname, i
return fd;
}
uint64_t FileManager::Ioctl(int fd, uint64_t request, void *args) {
auto FD = FDMap.find(fd);
if (FD == FDMap.end()) {
return -1;
}
return FD->second->ioctl(fd, request, args);
}
int32_t FileManager::FindHostFD(int fd) {
auto FD = FDMap.find(fd);
if (FD == FDMap.end()) {

View File

@ -30,6 +30,7 @@ public:
int openat(int dirfd, const char *pathname, int flags, mode_t mode);
int fstat(int fd, struct stat *buf);
int close(int fd);
int ioctl(int fd, uint64_t request, void *args);
int GetHostFD() const { return HostFD; }
@ -61,6 +62,8 @@ public:
uint64_t Access(const char *pathname, int mode);
uint64_t Readlink(const char *pathname, char *buf, size_t bufsiz);
uint64_t Openat(int dirfs, const char *pathname, int flags, uint32_t mode);
uint64_t Ioctl(int fd, uint64_t request, void *args);
int32_t FindHostFD(int fd);