diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp index 7172460..d566e3b 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp @@ -674,9 +674,10 @@ uint64_t FileManager::Open(const char* pathname, int flags, uint32_t mode) { }; fd = ::syscall(SYSCALL_DEF(openat2), Path.FD, Path.Path, &how, sizeof(how)); - if (fd == -1 && errno == EXDEV) { - // This means a magic symlink (/proc/foo) was involved. In this case we - // just punt and do the access without RESOLVE_IN_ROOT. + if (fd == -1 && (errno == EXDEV || errno == ENOSYS)) { + // EXDEV: a magic symlink (/proc/foo) was involved. ENOSYS: no openat2 here (proot). + // Either way, do the access without RESOLVE_IN_ROOT; GetEmulatedFDPath has already + // followed absolute symlinks inside the rootfs. fd = ::syscall(SYSCALL_DEF(openat), Path.FD, Path.Path, flags, mode); } } @@ -927,9 +928,10 @@ uint64_t FileManager::Openat([[maybe_unused]] int dirfs, const char* pathname, i .resolve = (Path.FD == AT_FDCWD) ? 0u : RESOLVE_IN_ROOT, // AT_FDCWD means it's a thunk and not via RootFS }; fd = ::syscall(SYSCALL_DEF(openat2), Path.FD, Path.Path, &how, sizeof(how)); - if (fd == -1 && errno == EXDEV) { - // This means a magic symlink (/proc/foo) was involved. In this case we - // just punt and do the access without RESOLVE_IN_ROOT. + if (fd == -1 && (errno == EXDEV || errno == ENOSYS)) { + // EXDEV: a magic symlink (/proc/foo) was involved. ENOSYS: no openat2 here (proot). + // Either way, do the access without RESOLVE_IN_ROOT; GetEmulatedFDPath has already + // followed absolute symlinks inside the rootfs. fd = ::syscall(SYSCALL_DEF(openat), Path.FD, Path.Path, flags, mode); } } @@ -967,6 +969,9 @@ uint64_t FileManager::Openat2(int dirfs, const char* pathname, FEX::HLE::open_ho // This means a magic symlink (/proc/foo) was involved. In this case we // just punt and do the access without RESOLVE_IN_ROOT. fd = ::syscall(SYSCALL_DEF(openat2), Path.FD, Path.Path, how, usize); + } else if (fd == -1 && errno == ENOSYS && how->resolve == 0) { + // No openat2 here (proot): the plain openat inside the rootfs, as above. + fd = ::syscall(SYSCALL_DEF(openat), Path.FD, Path.Path, (int)how->flags, (int)how->mode); } }