perf: fast path answers Steam's pre-2.33 stat calls and stays off without the patched proot (#466)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-09 03:14:29 +00:00
1 parent d6ba3d27d8
commit 7c758c817f
3 files changed
+36 -4

No files matched your search

+4 -1
View File
@@ -262,7 +262,10 @@ int ftruncate(int fd, off_t length) {
int known = 0;
if (steam_client()) {
if (next_fstat == NULL) next_fstat = dlsym(RTLD_NEXT, "fstat");
known = next_fstat != NULL && next_fstat(fd, &st) == 0 && S_ISREG(st.st_mode) && staging_file(fd);
/* staging_file() reads /proc/self/fd, a round trip through proot: skip it for a shrink, which
* is passed through untouched either way. */
known = next_fstat != NULL && next_fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
length >= st.st_size && staging_file(fd);
}
int result = 0, call_errno = entry_errno;
if (!known || length <= st.st_size || !cannot_reserve((long long)st.st_dev)) {