mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
Merge commit 'e1a7d527fd412b6bd78833e01fe80f515e324971' into merge/main-into-non-adreno-all
# Conflicts: # .github/workflows/build.yml # app/build.gradle # app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt # app/src/main/java/com/droiddeck/launcher/gpu/DriverPairs.kt # app/src/main/java/com/droiddeck/launcher/gpu/GpuInfo.kt # app/src/main/java/com/droiddeck/launcher/gpu/TurnipDriver.java # app/src/main/java/com/droiddeck/launcher/gpu/TurnipReleases.kt # app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java # app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt # app/src/main/java/com/droiddeck/launcher/session/SessionService.kt # app/src/main/res/values/strings.xml # app/src/test/java/com/droiddeck/launcher/ui/ComponentsPageProfileTest.kt # tools/build_local.sh # tools/gamescope/PATCHES.md # tools/gamescope/release.env # tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env # tools/linuxfs/preload/netif.c # tools/linuxfs/preload/opens.c # tools/release/runtime_inputs.py
This commit is contained in:
commit
e7b523d653
574 files changed
+41749
-2616
No files matched your search
@@ -406,6 +406,7 @@ int bl_kgsl_poll(int (*real)(int, unsigned long, void *), int fd, unsigned long
|
||||
void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int bl_ntsync_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int bl_drm_gem_close(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int bl_venc_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int bl_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
void *arg, void *caller, int *rc) __attribute__((visibility("hidden")));
|
||||
|
||||
@@ -419,6 +420,7 @@ int ioctl(int fd, unsigned long request, ...) {
|
||||
|
||||
int rc;
|
||||
if (bl_ntsync_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (bl_venc_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (bl_drm_gem_close(fd, request, arg, &rc)) return rc;
|
||||
if (real == NULL) real = (ioctl_fn) dlsym(RTLD_NEXT, "ioctl");
|
||||
if (bl_winebus_rumble_ioctl(real, fd, request, arg, __builtin_return_address(0), &rc)) return rc;
|
||||
@@ -504,19 +506,55 @@ static void write_table(FILE *out, const char *table, const struct link *link) {
|
||||
}
|
||||
}
|
||||
|
||||
static const char *denied_table(const char *path) {
|
||||
static const char *const tables[] = { "route", "ipv6_route", "if_inet6", "dev", "arp" };
|
||||
#define CARRIER_TABLE 5
|
||||
|
||||
static const char *const net_tables[] = { "route", "ipv6_route", "if_inet6", "dev", "arp", "carrier" };
|
||||
static long long net_denied_at[sizeof(net_tables) / sizeof(net_tables[0])];
|
||||
|
||||
#define CARRIER_SLOTS 8
|
||||
|
||||
static struct { char path[64]; long long at; } carrier_denied[CARRIER_SLOTS];
|
||||
|
||||
static int denied_recently(int table, const char *path) {
|
||||
if (table != CARRIER_TABLE) return fresh(&net_denied_at[table]);
|
||||
int hit = 0;
|
||||
pthread_mutex_lock(&link_lock);
|
||||
for (int i = 0; i < CARRIER_SLOTS && !hit; i++) {
|
||||
hit = strcmp(carrier_denied[i].path, path) == 0 && fresh(&carrier_denied[i].at);
|
||||
}
|
||||
pthread_mutex_unlock(&link_lock);
|
||||
return hit;
|
||||
}
|
||||
|
||||
static void remember_denial(int table, const char *path) {
|
||||
if (table != CARRIER_TABLE) {
|
||||
__atomic_store_n(&net_denied_at[table], now_ns(), __ATOMIC_RELAXED);
|
||||
return;
|
||||
}
|
||||
if (strlen(path) >= sizeof(carrier_denied[0].path)) return;
|
||||
pthread_mutex_lock(&link_lock);
|
||||
int slot = 0;
|
||||
for (int i = 0; i < CARRIER_SLOTS; i++) {
|
||||
if (strcmp(carrier_denied[i].path, path) == 0) { slot = i; break; }
|
||||
if (carrier_denied[i].at < carrier_denied[slot].at) slot = i;
|
||||
}
|
||||
snprintf(carrier_denied[slot].path, sizeof(carrier_denied[slot].path), "%s", path);
|
||||
carrier_denied[slot].at = now_ns();
|
||||
pthread_mutex_unlock(&link_lock);
|
||||
}
|
||||
|
||||
static int denied_table(const char *path) {
|
||||
if (strncmp(path, "/proc/net/", 10) == 0) {
|
||||
for (size_t i = 0; i < sizeof(tables) / sizeof(tables[0]); i++) {
|
||||
if (strcmp(path + 10, tables[i]) == 0) return tables[i];
|
||||
for (int i = 0; i < CARRIER_TABLE; i++) {
|
||||
if (strcmp(path + 10, net_tables[i]) == 0) return i;
|
||||
}
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
size_t len = strlen(path);
|
||||
if (strncmp(path, "/sys/class/net/", 15) == 0 && len > 8 && strcmp(path + len - 8, "/carrier") == 0) {
|
||||
return "carrier";
|
||||
return CARRIER_TABLE;
|
||||
}
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static FILE *synthesize(const char *table) {
|
||||
@@ -551,11 +589,16 @@ static FILE *open_stream(fopen_fn real, const char *path, const char *mode, cons
|
||||
return copy;
|
||||
}
|
||||
path = bl_oom_adj_redirect(path, mode && (mode[0] == 'w' || mode[0] == 'a' || strchr(mode, '+')));
|
||||
FILE *f = real(path, mode);
|
||||
if (f || path == NULL || mode == NULL || mode[0] != 'r') return f;
|
||||
int table = path && mode && mode[0] == 'r' ? denied_table(path) : -1;
|
||||
FILE *f;
|
||||
if (table >= 0 && denied_recently(table, path) && (f = synthesize(net_tables[table])) != NULL) return f;
|
||||
f = real(path, mode);
|
||||
if (f || table < 0) return f;
|
||||
int saved = errno;
|
||||
const char *table = denied_table(path);
|
||||
if (table && (f = synthesize(table)) != NULL) return f;
|
||||
if ((f = synthesize(net_tables[table])) != NULL) {
|
||||
if (saved == EACCES) remember_denial(table, path);
|
||||
return f;
|
||||
}
|
||||
errno = saved;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user