mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
* chore(i18n): translate every missing string in all locales Adds the 87 strings the bottom-screen Dashboard and in-game stats pages introduced to all 32 locales, plus the 51 older settings strings Japanese and the 50 Chinese locales were still missing. Every locale now has all 3456 translatable strings with the same placeholders as English. Also translates 36 entries that were still English where the language does not use the English word, and makes es-419 touch_app_id use the same %1$s placeholder as English. * chore(patches): drop comments from the lines downstream patches add Removes comment lines and trailing comments from lines our patches add, with hunk headers recounted. Lines that a later patch uses as context and the upstream backport 0123 are left as they are. The gamescope, FEX, proot and xodus series still apply to their pinned sources, and the patched trees differ only in those comments. test_hud_frames now finds the HUD writer by its first declaration. * docs: credit Greenlight, Better xCloud, viture-v2, GameNative and DiRTTelemetryErrorFix These were credited only in source headers and NOTICE files. * chore: remove source comments and unused functions Removes explanatory comments from first-party Kotlin, Java, C, C++, Rust, TypeScript, Python, shell, Gradle, CMake and workflow files. License and attribution headers stay, and vendored third-party trees, generated files and license files are untouched. A shellcheck directive is kept, and udevmon's fallthrough comments became fallthrough attributes. Syntax trees and token streams match the previous sources apart from the comments and Python docstrings. Module docstrings that argparse prints are kept, and device-smoke.sh prints the same --help text from a heredoc. Also removes 37 functions and 4 fields that nothing referenced. * chore: remove comments from the Syncthing integration and the latest main sources * docs: credit Syncthing and the syncthing-android fork * chore(i18n): translate the Syncthing strings in all locales The 107 strings the Syncthing integration added are now in all 32 locales. sync_web_path_locked names the Syncthing tab by its label. * docs: credit @xXJSONDeruloXx for the HUD metric readers The CPU, GPU load, thermal and battery readers come from their PerformanceHudView pull requests #777, #877, #991, #1406 and #1573. The FusionHUD credit line is unchanged. * docs: credit the HUD metric readers to @xXJSONDeruloXx's work
198 lines
6.0 KiB
Diff
198 lines
6.0 KiB
Diff
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
|
|
index 7172460..2c80dca 100644
|
|
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
|
|
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
|
|
@@ -29,6 +29,7 @@ $end_info$
|
|
#include <algorithm>
|
|
#include <errno.h>
|
|
#include <cstring>
|
|
+#include <linux/magic.h>
|
|
#include <linux/openat2.h>
|
|
#include <fcntl.h>
|
|
#include <filesystem>
|
|
@@ -632,6 +633,157 @@ static bool ShouldSkipOpenInEmu(int flags) {
|
|
return false;
|
|
}
|
|
|
|
+static bool IsOnProcFS(int DirFD, const char* Pathname) {
|
|
+ int FD = ::openat(DirFD, Pathname, O_PATH | O_NOFOLLOW | O_CLOEXEC);
|
|
+ if (FD == -1) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ struct statfs Buffer {};
|
|
+ const bool Result = fstatfs(FD, &Buffer) == 0 && Buffer.f_type == PROC_SUPER_MAGIC;
|
|
+ close(FD);
|
|
+ return Result;
|
|
+}
|
|
+
|
|
+static int OpenatWithoutOpenat2(int DirFD, const char* Pathname, int Flags, uint32_t Mode) {
|
|
+ if (DirFD == AT_FDCWD) {
|
|
+ return ::syscall(SYSCALL_DEF(openat), DirFD, Pathname, Flags, Mode);
|
|
+ }
|
|
+
|
|
+ constexpr uint32_t MaxSymlinks = 40;
|
|
+ uint32_t Symlinks {};
|
|
+ std::optional<dev_t> RootDev {};
|
|
+
|
|
+ const bool NoFollow = (Flags & O_NOFOLLOW) || (Flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL);
|
|
+
|
|
+ char Resolved[PATH_MAX];
|
|
+ size_t ResolvedLen {};
|
|
+
|
|
+ std::array<char[PATH_MAX], 2> Pending;
|
|
+ uint32_t PendingIndex {};
|
|
+ const char* Remaining = Pathname;
|
|
+
|
|
+ for (;;) {
|
|
+ while (*Remaining == '/') {
|
|
+ ++Remaining;
|
|
+ }
|
|
+
|
|
+ if (*Remaining == 0) {
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ const char* Component = Remaining;
|
|
+ const char* ComponentEnd = Component;
|
|
+ while (*ComponentEnd != 0 && *ComponentEnd != '/') {
|
|
+ ++ComponentEnd;
|
|
+ }
|
|
+ const size_t ComponentLen = ComponentEnd - Component;
|
|
+
|
|
+ Remaining = ComponentEnd;
|
|
+ while (*Remaining == '/') {
|
|
+ ++Remaining;
|
|
+ }
|
|
+ const bool Last = *Remaining == 0;
|
|
+ const bool TrailingSlash = Last && Remaining != ComponentEnd;
|
|
+
|
|
+ if (ComponentLen == 1 && Component[0] == '.') {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ if (ComponentLen == 2 && Component[0] == '.' && Component[1] == '.') {
|
|
+ while (ResolvedLen > 0 && Resolved[ResolvedLen - 1] != '/') {
|
|
+ --ResolvedLen;
|
|
+ }
|
|
+ if (ResolvedLen > 0) {
|
|
+ --ResolvedLen;
|
|
+ }
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ const size_t Separator = ResolvedLen > 0 ? 1 : 0;
|
|
+ const size_t CandidateLen = ResolvedLen + Separator + ComponentLen;
|
|
+ if (CandidateLen + 1 >= PATH_MAX) {
|
|
+ errno = ENAMETOOLONG;
|
|
+ return -1;
|
|
+ }
|
|
+ if (Separator) {
|
|
+ Resolved[ResolvedLen] = '/';
|
|
+ }
|
|
+ memcpy(&Resolved[ResolvedLen + Separator], Component, ComponentLen);
|
|
+ Resolved[CandidateLen] = 0;
|
|
+
|
|
+ struct stat Buffer {};
|
|
+ const bool Follow = !Last || TrailingSlash || !NoFollow;
|
|
+ const int StatResult = Follow ? fstatat(DirFD, Resolved, &Buffer, AT_SYMLINK_NOFOLLOW) : -1;
|
|
+
|
|
+ if (StatResult == 0 && S_ISLNK(Buffer.st_mode)) {
|
|
+ if (++Symlinks > MaxSymlinks) {
|
|
+ errno = ELOOP;
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (!RootDev) {
|
|
+ struct stat Root {};
|
|
+ if (fstat(DirFD, &Root) != 0) {
|
|
+ return -1;
|
|
+ }
|
|
+ RootDev = Root.st_dev;
|
|
+ }
|
|
+
|
|
+ if (Buffer.st_dev != *RootDev && IsOnProcFS(DirFD, Resolved)) {
|
|
+ return ::syscall(SYSCALL_DEF(openat), DirFD, Pathname, Flags, Mode);
|
|
+ }
|
|
+
|
|
+ char* Target = Pending[PendingIndex];
|
|
+ const ssize_t TargetLen = readlinkat(DirFD, Resolved, Target, PATH_MAX);
|
|
+ if (TargetLen <= 0) {
|
|
+ if (TargetLen == 0) {
|
|
+ errno = ENOENT;
|
|
+ }
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ const size_t RestLen = strlen(ComponentEnd);
|
|
+ if (static_cast<size_t>(TargetLen) + RestLen >= PATH_MAX) {
|
|
+ errno = ENAMETOOLONG;
|
|
+ return -1;
|
|
+ }
|
|
+ memcpy(&Target[TargetLen], ComponentEnd, RestLen + 1);
|
|
+
|
|
+ if (Target[0] == '/') {
|
|
+ ResolvedLen = 0;
|
|
+ }
|
|
+ Remaining = Target;
|
|
+ PendingIndex ^= 1;
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ if (Last) {
|
|
+ ResolvedLen = CandidateLen;
|
|
+ if (TrailingSlash) {
|
|
+ Resolved[ResolvedLen++] = '/';
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ if (StatResult != 0) {
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (!S_ISDIR(Buffer.st_mode)) {
|
|
+ errno = ENOTDIR;
|
|
+ return -1;
|
|
+ }
|
|
+ ResolvedLen = CandidateLen;
|
|
+ }
|
|
+
|
|
+ if (ResolvedLen == 0) {
|
|
+ Resolved[ResolvedLen++] = '.';
|
|
+ }
|
|
+ Resolved[ResolvedLen] = 0;
|
|
+ return ::syscall(SYSCALL_DEF(openat), DirFD, Resolved, Flags, Mode);
|
|
+}
|
|
+
|
|
bool FileManager::ReplaceEmuFd(int fd, int flags, uint32_t mode) {
|
|
char Tmp[PATH_MAX + 1];
|
|
|
|
@@ -678,6 +830,8 @@ uint64_t FileManager::Open(const char* pathname, int flags, uint32_t mode) {
|
|
// 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(openat), Path.FD, Path.Path, flags, mode);
|
|
+ } else if (fd == -1 && errno == ENOSYS) {
|
|
+ fd = OpenatWithoutOpenat2(Path.FD, Path.Path, flags, mode);
|
|
}
|
|
}
|
|
|
|
@@ -931,6 +1085,8 @@ uint64_t FileManager::Openat([[maybe_unused]] int dirfs, const char* pathname, i
|
|
// 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(openat), Path.FD, Path.Path, flags, mode);
|
|
+ } else if (fd == -1 && errno == ENOSYS) {
|
|
+ fd = OpenatWithoutOpenat2(Path.FD, Path.Path, flags, mode);
|
|
}
|
|
}
|
|
|
|
@@ -967,6 +1123,8 @@ 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) {
|
|
+ fd = OpenatWithoutOpenat2(Path.FD, Path.Path, how->flags, how->mode);
|
|
}
|
|
}
|
|
|