mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
Our proot answers openat2 with ENOSYS. FEX opened every rootfs path with openat2(RESOLVE_IN_ROOT) and only fell back on EXDEV, so in a session every x86 file lookup missed the rootfs and hit the arm64 guest: bash under FEX could not find libtinfo. GetEmulatedFDPath already follows absolute symlinks inside the rootfs, so a plain openat relative to the rootfs fd is the same lookup. The rootfs also gets an empty ld.so.preload, so the guest's arm64 preloads are not tried.
43 lines
2.5 KiB
Diff
43 lines
2.5 KiB
Diff
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);
|
|
}
|
|
}
|
|
|