Skip to content

Commit

Permalink
Merge pull request #751 from FEX-Emu/skmp/fix-fchmodat-faccessat
Browse files Browse the repository at this point in the history
Syscalls: chmodat, faccessat glibc interface differs from kernel
  • Loading branch information
Sonicadvance1 authored Feb 2, 2021
2 parents 4d05438 + 3eed439 commit 0aaed41
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Source/Tests/LinuxSyscalls/FileManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sys/uio.h>
#include <sys/vfs.h>
#include <unistd.h>
#include <sys/syscall.h>

namespace FEX::HLE {

Expand Down Expand Up @@ -83,15 +84,15 @@ uint64_t FileManager::Access(const char *pathname, [[maybe_unused]] int mode) {
return ::access(pathname, mode);
}

uint64_t FileManager::FAccessat(int dirfd, const char *pathname, int mode, int flags) {
uint64_t FileManager::FAccessat(int dirfd, const char *pathname, int mode) {
auto Path = GetEmulatedPath(pathname);
if (!Path.empty()) {
uint64_t Result = ::faccessat(dirfd, Path.c_str(), mode, flags);
uint64_t Result = ::syscall(SYS_faccessat, dirfd, Path.c_str(), mode);
if (Result != -1)
return Result;
}

return ::faccessat(dirfd, pathname, mode, flags);
return ::syscall(SYS_faccessat, dirfd, pathname, mode);
}

uint64_t FileManager::Readlink(const char *pathname, char *buf, size_t bufsiz) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/LinuxSyscalls/FileManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FileManager final {
uint64_t Stat(const char *pathname, void *buf);
uint64_t Lstat(const char *path, void *buf);
uint64_t Access(const char *pathname, int mode);
uint64_t FAccessat(int dirfd, const char *pathname, int mode, int flags);
uint64_t FAccessat(int dirfd, const char *pathname, int mode);
uint64_t Readlink(const char *pathname, char *buf, size_t bufsiz);
uint64_t Chmod(const char *pathname, mode_t mode);
uint64_t Readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
Expand Down
9 changes: 5 additions & 4 deletions Source/Tests/LinuxSyscalls/Syscalls/FD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <sys/eventfd.h>
#include <sys/syscall.h>

namespace FEX::HLE {
static int RemapFlags(int flags) {
Expand Down Expand Up @@ -217,13 +218,13 @@ namespace FEX::HLE {
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL(fchmodat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode, int flags) -> uint64_t {
uint64_t Result = fchmodat(dirfd, pathname, mode, flags);
REGISTER_SYSCALL_IMPL(fchmodat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, mode_t mode) -> uint64_t {
uint64_t Result = syscall(SYS_fchmodat, dirfd, pathname, mode);
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL(faccessat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, int mode, int flags) -> uint64_t {
uint64_t Result = FEX::HLE::_SyscallHandler->FM.FAccessat(dirfd, pathname, mode, flags);
REGISTER_SYSCALL_IMPL(faccessat, [](FEXCore::Core::InternalThreadState *Thread, int dirfd, const char *pathname, int mode) -> uint64_t {
uint64_t Result = FEX::HLE::_SyscallHandler->FM.FAccessat(dirfd, pathname, mode);
SYSCALL_ERRNO();
});

Expand Down
1 change: 0 additions & 1 deletion unittests/gvisor-tests/Known_Failures
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ aio_test
alarm_test
arch_prctl_test
bad_test
chmod_test
chown_test
clock_nanosleep_test
concurrency_test
Expand Down

0 comments on commit 0aaed41

Please sign in to comment.