mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
chore: consistent code branding (#2800)
* chore: consistent code branding * fix: carry legacy overrides, queues and live sync rows across the rename * fix: keep queued legacy overrides on a failed rename and separate merged queue entries
This commit is contained in:
1 parent
ad9348879d
commit
eabcfc7b74
229 files changed
+2584
-2468
No files matched your search
@@ -19,7 +19,7 @@
|
||||
typedef int (*spawn_fn)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]);
|
||||
__attribute__((visibility("hidden")))
|
||||
char *const *bl_webhelper_argv(const char *path, char *const argv[], char *const envp[]);
|
||||
char *const *dd_webhelper_argv(const char *path, char *const argv[], char *const envp[]);
|
||||
|
||||
#if defined(__aarch64__) || defined(BINFMT_TEST)
|
||||
|
||||
@@ -29,7 +29,7 @@ static int flag(const char *name) {
|
||||
}
|
||||
|
||||
static int handing_off(void) {
|
||||
return flag("BL_DESKTOP") || flag("BL_BINFMT");
|
||||
return flag("DD_DESKTOP") || flag("DD_BINFMT");
|
||||
}
|
||||
|
||||
static int foreign(const char *path, int error) {
|
||||
@@ -105,36 +105,36 @@ static int spawn_handler(pid_t *pid, const char *path, const posix_spawn_file_ac
|
||||
return real(pid, BINFMT_HANDLER, fa, attr, args, envp);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before(const char *path, char *const argv[], char *const envp[]) {
|
||||
__attribute__((visibility("hidden"))) void dd_binfmt_before(const char *path, char *const argv[], char *const envp[]) {
|
||||
if (handing_off() && foreign(path, ENOEXEC)) hand_off(path, argv, envp);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error) {
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error) {
|
||||
if (wanted(path, error)) hand_off(path, argv, envp);
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before_search(const char *file, char *const argv[], char *const envp[]) {
|
||||
__attribute__((visibility("hidden"))) void dd_binfmt_before_search(const char *file, char *const argv[], char *const envp[]) {
|
||||
char path[PATH_MAX];
|
||||
if (handing_off() && lookup(file, path, sizeof path)) bl_binfmt_before(path, argv, envp);
|
||||
if (handing_off() && lookup(file, path, sizeof path)) dd_binfmt_before(path, argv, envp);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_after_search(const char *file, char *const argv[], char *const envp[], int error) {
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_after_search(const char *file, char *const argv[], char *const envp[], int error) {
|
||||
char path[PATH_MAX];
|
||||
if (handing_off() && lookup(file, path, sizeof path)) return bl_binfmt_retry(path, argv, envp, error);
|
||||
if (handing_off() && lookup(file, path, sizeof path)) return dd_binfmt_retry(path, argv, envp, error);
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_runnable(const char *path, int mode) {
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_runnable(const char *path, int mode) {
|
||||
if (mode != X_OK || !handing_off()) return 0;
|
||||
int runs = foreign(path, EACCES) != 0;
|
||||
errno = EACCES;
|
||||
return runs;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
const posix_spawnattr_t *attr, char *const argv[], char *const envp[],
|
||||
spawn_fn real) {
|
||||
if (handing_off() && foreign(path, ENOEXEC)) return spawn_handler(pid, path, fa, attr, argv, envp, real);
|
||||
@@ -145,54 +145,54 @@ __attribute__((visibility("hidden"))) int bl_binfmt_spawn(pid_t *pid, const char
|
||||
int execvpe(const char *file, char *const argv[], char *const envp[]) {
|
||||
char resolved[PATH_MAX];
|
||||
const char *path = lookup(file, resolved, sizeof resolved) ? resolved : file;
|
||||
char *const *adjusted = bl_webhelper_argv(path, argv, envp);
|
||||
char *const *adjusted = dd_webhelper_argv(path, argv, envp);
|
||||
static int (*real)(const char *, char *const[], char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[], char *const[]))dlsym(RTLD_NEXT, "execvpe");
|
||||
bl_binfmt_before_search(file, (char *const *)adjusted, envp);
|
||||
dd_binfmt_before_search(file, (char *const *)adjusted, envp);
|
||||
real(file, (char *const *)adjusted, envp);
|
||||
return bl_binfmt_after_search(file, (char *const *)adjusted, envp, errno);
|
||||
return dd_binfmt_after_search(file, (char *const *)adjusted, envp, errno);
|
||||
}
|
||||
|
||||
int posix_spawnp(pid_t *pid, const char *file, const posix_spawn_file_actions_t *fa, const posix_spawnattr_t *attr,
|
||||
char *const argv[], char *const envp[]) {
|
||||
char path[PATH_MAX];
|
||||
int found = lookup(file, path, sizeof path);
|
||||
char *const *adjusted = bl_webhelper_argv(found ? path : file, argv, envp);
|
||||
char *const *adjusted = dd_webhelper_argv(found ? path : file, argv, envp);
|
||||
static spawn_fn real, spawn;
|
||||
if (!real) real = (spawn_fn)dlsym(RTLD_NEXT, "posix_spawnp");
|
||||
if (!spawn) spawn = (spawn_fn)dlsym(RTLD_NEXT, "posix_spawn");
|
||||
if (!handing_off() || !found) return real(pid, file, fa, attr, (char *const *)adjusted, envp);
|
||||
return bl_binfmt_spawn(pid, path, fa, attr, (char *const *)adjusted, envp, spawn);
|
||||
return dd_binfmt_spawn(pid, path, fa, attr, (char *const *)adjusted, envp, spawn);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_runnable(const char *path, int mode) {
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_runnable(const char *path, int mode) {
|
||||
(void)path, (void)mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before(const char *path, char *const argv[], char *const envp[]) {
|
||||
__attribute__((visibility("hidden"))) void dd_binfmt_before(const char *path, char *const argv[], char *const envp[]) {
|
||||
(void)path, (void)argv, (void)envp;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error) {
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error) {
|
||||
(void)path, (void)argv, (void)envp;
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before_search(const char *file, char *const argv[], char *const envp[]) {
|
||||
__attribute__((visibility("hidden"))) void dd_binfmt_before_search(const char *file, char *const argv[], char *const envp[]) {
|
||||
(void)file, (void)argv, (void)envp;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_after_search(const char *file, char *const argv[], char *const envp[], int error) {
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_after_search(const char *file, char *const argv[], char *const envp[], int error) {
|
||||
(void)file, (void)argv, (void)envp;
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
const posix_spawnattr_t *attr, char *const argv[], char *const envp[],
|
||||
spawn_fn real) {
|
||||
return real(pid, path, fa, attr, argv, envp);
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__aarch64__) || defined(BL_CLOCK_ANY_ARCH)
|
||||
#if defined(__aarch64__) || defined(DD_CLOCK_ANY_ARCH)
|
||||
|
||||
#ifndef CP_CTL
|
||||
#define CP_CTL "/tmp/.bl-clock"
|
||||
#define CP_CTL "/tmp/.dd-clock"
|
||||
#endif
|
||||
#ifndef FUTEX_LOCK_PI2
|
||||
#define FUTEX_LOCK_PI2 13
|
||||
@@ -255,7 +255,7 @@ int timerfd_settime(int fd, int flags, const struct itimerspec *value, struct it
|
||||
return cp_tfd_settime(fd, flags, cp_timer(fd, flags, value, &moved), old);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_clock_syscall(long number, const long *args, long (*real)(long, ...), long *ret) {
|
||||
__attribute__((visibility("hidden"))) int dd_clock_syscall(long number, const long *args, long (*real)(long, ...), long *ret) {
|
||||
struct timespec moved;
|
||||
struct itimerspec timer;
|
||||
int64_t shift;
|
||||
@@ -302,7 +302,7 @@ __attribute__((visibility("hidden"))) int bl_clock_syscall(long number, const lo
|
||||
|
||||
#else
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_clock_syscall(long number, const long *args, long (*real)(long, ...), long *ret) {
|
||||
__attribute__((visibility("hidden"))) int dd_clock_syscall(long number, const long *args, long (*real)(long, ...), long *ret) {
|
||||
(void)number;
|
||||
(void)args;
|
||||
(void)real;
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
#define STORE "/.droiddeck-descriptors"
|
||||
#define ENTRY_MAX (PATH_MAX * 2)
|
||||
|
||||
int bl_is_wineserver(void) __attribute__((visibility("hidden")));
|
||||
int dd_is_wineserver(void) __attribute__((visibility("hidden")));
|
||||
|
||||
static int store_seen;
|
||||
|
||||
static int kept(const char *name) {
|
||||
return name != NULL && strcmp(name, DESCRIPTOR) == 0 && bl_is_wineserver();
|
||||
return name != NULL && strcmp(name, DESCRIPTOR) == 0 && dd_is_wineserver();
|
||||
}
|
||||
|
||||
static int store_root(char *out, size_t size) {
|
||||
@@ -226,7 +226,7 @@ int fremovexattr(int fd, const char *name) {
|
||||
static int tracked(const char *path, char *out, size_t size) {
|
||||
int saved = errno, found;
|
||||
|
||||
found = bl_is_wineserver() && store_exists() && resolved(path, out, size) == 0;
|
||||
found = dd_is_wineserver() && store_exists() && resolved(path, out, size) == 0;
|
||||
errno = saved;
|
||||
return found;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ static void follow(const char *from, const char *to) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_descriptor_unlink(const char *path, int (*real)(const char *)) {
|
||||
int dd_descriptor_unlink(const char *path, int (*real)(const char *)) {
|
||||
char target[PATH_MAX];
|
||||
int known = tracked(path, target, sizeof(target)), result = real(path);
|
||||
|
||||
@@ -268,7 +268,7 @@ int bl_descriptor_unlink(const char *path, int (*real)(const char *)) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_descriptor_rmdir(const char *path, int (*real)(const char *)) {
|
||||
int dd_descriptor_rmdir(const char *path, int (*real)(const char *)) {
|
||||
char target[PATH_MAX];
|
||||
int known = tracked(path, target, sizeof(target)), result = real(path);
|
||||
|
||||
@@ -277,12 +277,12 @@ int bl_descriptor_rmdir(const char *path, int (*real)(const char *)) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_descriptor_remove(const char *path, int (*real)(const char *)) {
|
||||
return bl_descriptor_rmdir(path, real);
|
||||
int dd_descriptor_remove(const char *path, int (*real)(const char *)) {
|
||||
return dd_descriptor_rmdir(path, real);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_descriptor_rename(const char *from, const char *to, int (*real)(const char *, const char *)) {
|
||||
int dd_descriptor_rename(const char *from, const char *to, int (*real)(const char *, const char *)) {
|
||||
char old[PATH_MAX], new[PATH_MAX];
|
||||
int known = tracked(from, old, sizeof(old)), result = real(from, to);
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ static void after_fork(void) {
|
||||
static int enabled(void) {
|
||||
static int cached = -1;
|
||||
if (cached < 0) {
|
||||
const char *off = getenv("BL_NO_DIR_CACHE");
|
||||
const char *off = getenv("DD_NO_DIR_CACHE");
|
||||
cached = strcmp(program_invocation_short_name, "steam") == 0 &&
|
||||
(strstr(program_invocation_name, "steamrtarm64") != NULL ||
|
||||
strstr(program_invocation_name, "steamrt64") != NULL) && !(off && strcmp(off, "1") == 0);
|
||||
@@ -816,9 +816,9 @@ static void end(struct expect *x, int nx) {
|
||||
give(&lock);
|
||||
}
|
||||
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int dd_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int (*real)(int, const char *, int, mode_t)) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int dd_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int (*real)(int, const char *, int, mode_t)) {
|
||||
struct side s;
|
||||
if (!(flags & O_CREAT) || (dirfd != AT_FDCWD && (path == NULL || path[0] != '/')) || !watching(path) || !split(path, &s))
|
||||
@@ -860,17 +860,17 @@ int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
}
|
||||
|
||||
ONE_PATH(mkdir, ADDED, IN_CREATE, next_mkdir(path, mode), mode_t mode)
|
||||
int bl_descriptor_unlink(const char *path, int (*real)(const char *)) __attribute__((visibility("hidden")));
|
||||
int bl_descriptor_rmdir(const char *path, int (*real)(const char *)) __attribute__((visibility("hidden")));
|
||||
int bl_descriptor_remove(const char *path, int (*real)(const char *)) __attribute__((visibility("hidden")));
|
||||
int bl_descriptor_rename(const char *from, const char *to, int (*real)(const char *, const char *))
|
||||
int dd_descriptor_unlink(const char *path, int (*real)(const char *)) __attribute__((visibility("hidden")));
|
||||
int dd_descriptor_rmdir(const char *path, int (*real)(const char *)) __attribute__((visibility("hidden")));
|
||||
int dd_descriptor_remove(const char *path, int (*real)(const char *)) __attribute__((visibility("hidden")));
|
||||
int dd_descriptor_rename(const char *from, const char *to, int (*real)(const char *, const char *))
|
||||
__attribute__((visibility("hidden")));
|
||||
|
||||
static int moved(const char *from, const char *to) { return bl_descriptor_rename(from, to, next_rename); }
|
||||
static int moved(const char *from, const char *to) { return dd_descriptor_rename(from, to, next_rename); }
|
||||
|
||||
ONE_PATH(rmdir, REMOVED, IN_DELETE, bl_descriptor_rmdir(path, next_rmdir))
|
||||
ONE_PATH(unlink, REMOVED, IN_DELETE, bl_descriptor_unlink(path, next_unlink))
|
||||
ONE_PATH(remove, REMOVED, IN_DELETE, bl_descriptor_remove(path, next_remove))
|
||||
ONE_PATH(rmdir, REMOVED, IN_DELETE, dd_descriptor_rmdir(path, next_rmdir))
|
||||
ONE_PATH(unlink, REMOVED, IN_DELETE, dd_descriptor_unlink(path, next_unlink))
|
||||
ONE_PATH(remove, REMOVED, IN_DELETE, dd_descriptor_remove(path, next_remove))
|
||||
|
||||
#define TWO_PATHS(name, gone, event, call) \
|
||||
int name(const char *from, const char *to) { \
|
||||
@@ -900,8 +900,8 @@ ONE_PATH(remove, REMOVED, IN_DELETE, bl_descriptor_remove(path, next_remove))
|
||||
return r; \
|
||||
}
|
||||
|
||||
int bl_link_lock(const char *oldpath, const char *newpath, int result) __attribute__((visibility("hidden")));
|
||||
static int link_or_lock(const char *from, const char *to) { return bl_link_lock(from, to, next_link(from, to)); }
|
||||
int dd_link_lock(const char *oldpath, const char *newpath, int result) __attribute__((visibility("hidden")));
|
||||
static int link_or_lock(const char *from, const char *to) { return dd_link_lock(from, to, next_link(from, to)); }
|
||||
|
||||
TWO_PATHS(rename, 1, IN_MOVED_TO, moved)
|
||||
TWO_PATHS(link, 0, IN_CREATE, link_or_lock)
|
||||
@@ -938,8 +938,8 @@ static int listed_absent(const char *dir, const char *name, long long now) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_dircache_absent(const char *path) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_absent(const char *path) {
|
||||
int dd_dircache_absent(const char *path) __attribute__((visibility("hidden")));
|
||||
int dd_dircache_absent(const char *path) {
|
||||
struct side s;
|
||||
if (!watching(path) || !split(path, &s)) return 0;
|
||||
for (const char *c = s.name; *c; c++)
|
||||
@@ -957,15 +957,15 @@ int bl_dircache_absent(const char *path) {
|
||||
|
||||
#else
|
||||
|
||||
int bl_dircache_absent(const char *path) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_absent(const char *path) {
|
||||
int dd_dircache_absent(const char *path) __attribute__((visibility("hidden")));
|
||||
int dd_dircache_absent(const char *path) {
|
||||
(void)path;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int dd_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int (*real)(int, const char *, int, mode_t)) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int dd_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int (*real)(int, const char *, int, mode_t)) {
|
||||
return real(dirfd, path, flags, mode);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ static int is_kgsl(int fd) {
|
||||
struct stat st;
|
||||
pthread_mutex_lock(&lock);
|
||||
if (kgsl_state == 0) {
|
||||
const char *standin = getenv("BL_DRM_STANDIN");
|
||||
const char *standin = getenv("DD_DRM_STANDIN");
|
||||
kgsl_state = stat("/dev/kgsl-3d0", &st) == 0 || (standin && *standin && stat(standin, &st) == 0) ? 1 : -1;
|
||||
if (kgsl_state > 0) kgsl_dev = st.st_rdev;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ static int is_kgsl(int fd) {
|
||||
}
|
||||
|
||||
/* Keep the opt-in separate from GPU detection: manual ICDs must retain native DRM behavior. */
|
||||
struct bl_drm_version {
|
||||
struct dd_drm_version {
|
||||
int major, minor, patch;
|
||||
size_t name_len;
|
||||
char *name;
|
||||
@@ -61,21 +61,21 @@ struct bl_drm_version {
|
||||
size_t desc_len;
|
||||
char *desc;
|
||||
};
|
||||
#define BL_DRM_VERSION _IOWR('d', 0x00, struct bl_drm_version)
|
||||
#define DD_DRM_VERSION _IOWR('d', 0x00, struct dd_drm_version)
|
||||
|
||||
static int is_powervr(int fd) {
|
||||
const char *enabled = getenv("BL_POWERVR_DRM_HANDLES");
|
||||
const char *enabled = getenv("DD_POWERVR_DRM_HANDLES");
|
||||
if (!enabled || strcmp(enabled, "1")) return 0;
|
||||
const char *path = getenv("BL_POWERVR_RENDER_NODE");
|
||||
const char *path = getenv("DD_POWERVR_RENDER_NODE");
|
||||
if (!path || !*path) return 0;
|
||||
struct stat node, candidate;
|
||||
if (stat(path, &node) || fstat(fd, &candidate) ||
|
||||
!S_ISCHR(candidate.st_mode) || !S_ISCHR(node.st_mode) ||
|
||||
candidate.st_rdev != node.st_rdev) return 0;
|
||||
char name[16] = {0};
|
||||
struct bl_drm_version version = {.name_len = sizeof(name) - 1, .name = name};
|
||||
struct dd_drm_version version = {.name_len = sizeof(name) - 1, .name = name};
|
||||
/* Bypass the preload's ioctl dispatcher to avoid recursively entering this hook. */
|
||||
return syscall(SYS_ioctl, fd, BL_DRM_VERSION, &version) == 0 &&
|
||||
return syscall(SYS_ioctl, fd, DD_DRM_VERSION, &version) == 0 &&
|
||||
version.name_len == 3 && !memcmp(name, "pvr", 3);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ static int same_file_description(int a, int b) {
|
||||
}
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
const char *standin = getenv("BL_DRM_STANDIN");
|
||||
const char *standin = getenv("DD_DRM_STANDIN");
|
||||
ret = standin && *standin ? same_by_flock(a, b) : 0;
|
||||
}
|
||||
errno = saved_errno;
|
||||
@@ -324,7 +324,7 @@ int drmCloseBufferHandle(int fd, uint32_t handle) {
|
||||
return fn ? fn(fd, handle) : -ENOSYS;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_drm_gem_close(int fd, unsigned long request, void *arg, int *rc) {
|
||||
__attribute__((visibility("hidden"))) int dd_drm_gem_close(int fd, unsigned long request, void *arg, int *rc) {
|
||||
if (request != GEM_CLOSE || !arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ static int (*fs_real_shm_unlink)(const char *);
|
||||
static void *(*fs_real_mmap)(void *, size_t, int, int, int, off_t);
|
||||
static void *(*fs_real_mmap64)(void *, size_t, int, int, int, off64_t);
|
||||
static int (*fs_real_munmap)(void *, size_t);
|
||||
__attribute__((visibility("hidden"))) int bl_noexec_retry(int prot, int flags, int fd);
|
||||
__attribute__((visibility("hidden"))) int dd_noexec_retry(int prot, int flags, int fd);
|
||||
|
||||
static int fs_on(void) {
|
||||
if (fs_state < 0) {
|
||||
const char *e = getenv("BL_FSYNC");
|
||||
const char *e = getenv("DD_FSYNC");
|
||||
fs_state = e && e[0] == '1';
|
||||
}
|
||||
return fs_state;
|
||||
@@ -511,14 +511,14 @@ static long fs_wake(uint32_t key, int n) {
|
||||
return woken;
|
||||
}
|
||||
|
||||
void bl_fsync_fds_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
void bl_fsync_fds_closed(unsigned int first, unsigned int last) {
|
||||
void dd_fsync_fds_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
void dd_fsync_fds_closed(unsigned int first, unsigned int last) {
|
||||
int fd = __atomic_load_n(&fs_fd, __ATOMIC_ACQUIRE);
|
||||
if (fd >= 0 && (unsigned int)fd >= first && (unsigned int)fd <= last) __atomic_store_n(&fs_fd, -1, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
int bl_fsync_syscall(long number, const long *args, long *ret) __attribute__((visibility("hidden")));
|
||||
int bl_fsync_syscall(long number, const long *args, long *ret) {
|
||||
int dd_fsync_syscall(long number, const long *args, long *ret) __attribute__((visibility("hidden")));
|
||||
int dd_fsync_syscall(long number, const long *args, long *ret) {
|
||||
if (number == SYS_futex_waitv) {
|
||||
if (!fs_on()) return 0;
|
||||
if (!args[0] && !args[1]) {
|
||||
@@ -617,15 +617,15 @@ int shm_unlink(const char *name) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int bl_venc_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off,
|
||||
int dd_venc_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off,
|
||||
void *(*real)(void *, size_t, int, int, int, off_t), void **out) __attribute__((weak, visibility("hidden")));
|
||||
|
||||
void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off) {
|
||||
void *p;
|
||||
if (!fs_real_mmap) fs_real_mmap = (void *(*)(void *, size_t, int, int, int, off_t))dlsym(RTLD_NEXT, "mmap");
|
||||
if (bl_venc_mmap && bl_venc_mmap(addr, len, prot, flags, fd, off, fs_real_mmap, &p)) return p;
|
||||
if (dd_venc_mmap && dd_venc_mmap(addr, len, prot, flags, fd, off, fs_real_mmap, &p)) return p;
|
||||
p = fs_real_mmap(addr, len, prot, flags, fd, off);
|
||||
if (p == MAP_FAILED && bl_noexec_retry(prot, flags, fd)) p = fs_real_mmap(addr, len, prot & ~PROT_EXEC, flags, fd, off);
|
||||
if (p == MAP_FAILED && dd_noexec_retry(prot, flags, fd)) p = fs_real_mmap(addr, len, prot & ~PROT_EXEC, flags, fd, off);
|
||||
if (p != MAP_FAILED && __builtin_expect(fs_fd >= 0, 0)) fs_track(p, len, flags, fd, off);
|
||||
return p;
|
||||
}
|
||||
@@ -633,10 +633,10 @@ void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off) {
|
||||
void *mmap64(void *addr, size_t len, int prot, int flags, int fd, off64_t off) {
|
||||
void *p;
|
||||
if (!fs_real_mmap64) fs_real_mmap64 = (void *(*)(void *, size_t, int, int, int, off64_t))dlsym(RTLD_NEXT, "mmap64");
|
||||
if (bl_venc_mmap && bl_venc_mmap(addr, len, prot, flags, fd, off, (void *(*)(void *, size_t, int, int, int, off_t))fs_real_mmap64, &p))
|
||||
if (dd_venc_mmap && dd_venc_mmap(addr, len, prot, flags, fd, off, (void *(*)(void *, size_t, int, int, int, off_t))fs_real_mmap64, &p))
|
||||
return p;
|
||||
p = fs_real_mmap64(addr, len, prot, flags, fd, off);
|
||||
if (p == MAP_FAILED && bl_noexec_retry(prot, flags, fd)) p = fs_real_mmap64(addr, len, prot & ~PROT_EXEC, flags, fd, off);
|
||||
if (p == MAP_FAILED && dd_noexec_retry(prot, flags, fd)) p = fs_real_mmap64(addr, len, prot & ~PROT_EXEC, flags, fd, off);
|
||||
if (p != MAP_FAILED && __builtin_expect(fs_fd >= 0, 0)) fs_track(p, len, flags, fd, off);
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static struct pad *pad_for_syslink(const char *path) {
|
||||
|
||||
static void *next_symbol(const char *name) { return dlsym(RTLD_NEXT, name); }
|
||||
|
||||
char *bl_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *))
|
||||
char *dd_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *))
|
||||
__attribute__((visibility("hidden")));
|
||||
|
||||
static int caller_is_winebus(void *caller) {
|
||||
@@ -178,7 +178,7 @@ static int caller_is_winebus(void *caller) {
|
||||
return strstr(info.dli_fname, "winebus.so") != NULL;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd,
|
||||
__attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd,
|
||||
unsigned long request, void *arg, void *caller,
|
||||
int *rc) {
|
||||
struct ff_effect *effect = arg;
|
||||
@@ -204,7 +204,7 @@ char *realpath(const char *path, char *resolved) {
|
||||
}
|
||||
if (real_realpath == NULL) real_realpath = next_symbol("realpath");
|
||||
if (real_realpath == NULL) return NULL;
|
||||
return bl_cached_realpath(path, resolved, real_realpath);
|
||||
return dd_cached_realpath(path, resolved, real_realpath);
|
||||
}
|
||||
|
||||
void *udev_device_new_from_syspath(void *udev, const char *syspath) {
|
||||
|
||||
@@ -28,7 +28,7 @@ static const struct {
|
||||
{0x44050A21, 0x44050A31},
|
||||
};
|
||||
|
||||
void bl_kgsl_chip_id_fixup(unsigned long request, void *arg, int rc) {
|
||||
void dd_kgsl_chip_id_fixup(unsigned long request, void *arg, int rc) {
|
||||
if (rc != 0 || request != IOCTL_KGSL_DEVICE_GETPROPERTY || arg == NULL) return;
|
||||
struct kgsl_device_getproperty *prop = arg;
|
||||
if (prop->type != KGSL_PROP_DEVICE_INFO || prop->value == NULL
|
||||
|
||||
@@ -69,7 +69,7 @@ static int read_retired(int (*real)(int, unsigned long, void *), int fd,
|
||||
}
|
||||
|
||||
/* Quest refuses some KGSL ioctls, and Mesa 27 turns a failed timestamp read into VK_ERROR_UNKNOWN. */
|
||||
__attribute__((visibility("hidden"))) void bl_kgsl_track(int (*real)(int, unsigned long, void *),
|
||||
__attribute__((visibility("hidden"))) void dd_kgsl_track(int (*real)(int, unsigned long, void *),
|
||||
int fd, unsigned long request, void *arg,
|
||||
int *rc) {
|
||||
int saved = errno;
|
||||
@@ -113,12 +113,12 @@ static int enabled(void) {
|
||||
const char *off;
|
||||
|
||||
if (cached >= 0) return cached;
|
||||
off = getenv("BL_NO_KGSL_POLL_FIX");
|
||||
off = getenv("DD_NO_KGSL_POLL_FIX");
|
||||
cached = !(off != NULL && off[0] == '1');
|
||||
return cached;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_kgsl_poll(int (*real)(int, unsigned long, void *),
|
||||
__attribute__((visibility("hidden"))) int dd_kgsl_poll(int (*real)(int, unsigned long, void *),
|
||||
int fd, unsigned long request, void *arg,
|
||||
int *rc) {
|
||||
const struct kgsl_device_waittimestamp_ctxtid *wait = arg;
|
||||
|
||||
@@ -19,7 +19,7 @@ static int lock_name(const char *path) {
|
||||
return n > 2 && strcmp(path + n - 2, "-l") == 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_link_lock(const char *oldpath, const char *newpath, int result) {
|
||||
__attribute__((visibility("hidden"))) int dd_link_lock(const char *oldpath, const char *newpath, int result) {
|
||||
static int (*real_symlink)(const char *, const char *);
|
||||
if (result == 0 || !refused(errno)) return result;
|
||||
if (moves_instead()) return renameat2(AT_FDCWD, oldpath, AT_FDCWD, newpath, RENAME_NOREPLACE);
|
||||
@@ -32,7 +32,7 @@ __attribute__((visibility("hidden"))) int bl_link_lock(const char *oldpath, cons
|
||||
int link(const char *oldpath, const char *newpath) {
|
||||
static int (*real_link)(const char *, const char *);
|
||||
if (real_link == NULL) real_link = dlsym(RTLD_NEXT, "link");
|
||||
return bl_link_lock(oldpath, newpath, real_link(oldpath, newpath));
|
||||
return dd_link_lock(oldpath, newpath, real_link(oldpath, newpath));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ static int is_lock_query(int cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
int bl_nl_before_dup(int fd, void **state) __attribute__((visibility("hidden")));
|
||||
void bl_nl_after_dup(void *state, int fd) __attribute__((visibility("hidden")));
|
||||
int dd_nl_before_dup(int fd, void **state) __attribute__((visibility("hidden")));
|
||||
void dd_nl_after_dup(void *state, int fd) __attribute__((visibility("hidden")));
|
||||
|
||||
static int fcntl_with(int (**real_fcntl)(int, int, ...), const char *name, int fd, int cmd, void *arg) {
|
||||
int result;
|
||||
@@ -74,9 +74,9 @@ static int fcntl_with(int (**real_fcntl)(int, int, ...), const char *name, int f
|
||||
}
|
||||
void *nl_state = NULL;
|
||||
int duplicate = cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC;
|
||||
if (duplicate && bl_nl_before_dup(fd, &nl_state) != 0) return -1;
|
||||
if (duplicate && dd_nl_before_dup(fd, &nl_state) != 0) return -1;
|
||||
result = (*real_fcntl)(fd, cmd, arg);
|
||||
if (duplicate) bl_nl_after_dup(nl_state, result);
|
||||
if (duplicate) dd_nl_after_dup(nl_state, result);
|
||||
if (result >= 0 || !unsupported(errno)) return result;
|
||||
if (is_lock_command(cmd)) return 0;
|
||||
if (is_lock_query(cmd) && arg != NULL) {
|
||||
|
||||
+26
-26
@@ -20,7 +20,7 @@
|
||||
static const char *net_dir(void) {
|
||||
static char dir[256];
|
||||
if (!dir[0]) {
|
||||
const char *base = getenv("BL_SYSV_DIR");
|
||||
const char *base = getenv("DD_SYSV_DIR");
|
||||
snprintf(dir, sizeof(dir), "%s/net", base && *base ? base : "/dev/shm/wnsysv");
|
||||
char parent[256];
|
||||
snprintf(parent, sizeof(parent), "%s", dir);
|
||||
@@ -110,18 +110,18 @@ typedef int (*connect_fn)(int, const struct sockaddr *, socklen_t);
|
||||
typedef int (*accept4_fn)(int, struct sockaddr *, socklen_t *, int);
|
||||
static unsigned guarded_port(void);
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_udevmon_stand_in(int fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_bind(int fd, const struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_udevmon_stand_in(int fd);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_bind(int fd, const struct sockaddr *addr,
|
||||
socklen_t len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_connect(int fd, const struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_connect(int fd, const struct sockaddr *addr,
|
||||
socklen_t len, int *rc);
|
||||
|
||||
int bind(int fd, const struct sockaddr *addr, socklen_t len) {
|
||||
static bind_fn real;
|
||||
int nl_rc;
|
||||
if (!real) real = (bind_fn)dlsym(RTLD_NEXT, "bind");
|
||||
if (bl_nl_bind(fd, addr, len, &nl_rc)) return nl_rc;
|
||||
if (bl_udevmon_stand_in(fd)) {
|
||||
if (dd_nl_bind(fd, addr, len, &nl_rc)) return nl_rc;
|
||||
if (dd_udevmon_stand_in(fd)) {
|
||||
if (addr == NULL || len < sizeof(struct sockaddr_nl) || addr->sa_family != AF_NETLINK) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@@ -183,7 +183,7 @@ static void bind_before_loopback_connect(int fd, const struct sockaddr *addr, so
|
||||
static unsigned guarded_port(void) {
|
||||
static int port = -1;
|
||||
if (port < 0) {
|
||||
const char *value = getenv("BL_CDP_GUARD");
|
||||
const char *value = getenv("DD_CDP_GUARD");
|
||||
port = value && *value ? atoi(value) : 0;
|
||||
if (port < 0 || port > 65535) port = 0;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ static int guest_peer(int fd) {
|
||||
int connect(int fd, const struct sockaddr *addr, socklen_t len) {
|
||||
static connect_fn real;
|
||||
int nl_rc;
|
||||
if (bl_nl_connect(fd, addr, len, &nl_rc)) return nl_rc;
|
||||
if (dd_nl_connect(fd, addr, len, &nl_rc)) return nl_rc;
|
||||
if (!real) real = (connect_fn)dlsym(RTLD_NEXT, "connect");
|
||||
bind_before_loopback_connect(fd, addr, len);
|
||||
unsigned peer = loopback_family(addr, len) ? addr_port(addr, len) : 0;
|
||||
@@ -267,13 +267,13 @@ int accept(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
extern char **environ;
|
||||
typedef int (*spawn_fn)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]);
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before(const char *path, char *const argv[], char *const envp[]);
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error);
|
||||
__attribute__((visibility("hidden"))) void bl_binfmt_before_search(const char *file, char *const argv[], char *const envp[]);
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_after_search(const char *file, char *const argv[], char *const envp[], int error);
|
||||
__attribute__((visibility("hidden"))) void dd_binfmt_before(const char *path, char *const argv[], char *const envp[]);
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_retry(const char *path, char *const argv[], char *const envp[], int error);
|
||||
__attribute__((visibility("hidden"))) void dd_binfmt_before_search(const char *file, char *const argv[], char *const envp[]);
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_after_search(const char *file, char *const argv[], char *const envp[], int error);
|
||||
__attribute__((visibility("hidden")))
|
||||
char *const *bl_webhelper_argv(const char *path, char *const argv[], char *const envp[]);
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
char *const *dd_webhelper_argv(const char *path, char *const argv[], char *const envp[]);
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
const posix_spawnattr_t *attr, char *const argv[], char *const envp[],
|
||||
spawn_fn real);
|
||||
|
||||
@@ -320,7 +320,7 @@ static int maybe_answer_lsof(const char *path, char *const argv[]) {
|
||||
}
|
||||
|
||||
static char **web_helper_redirect(const char *path, char *const argv[], const char **launcher) {
|
||||
const char *want = getenv("BL_X64_ARM_WEBHELPER");
|
||||
const char *want = getenv("DD_X64_ARM_WEBHELPER");
|
||||
if (!want || !*want || !path) return NULL;
|
||||
const char *base = strrchr(path, '/');
|
||||
if (strcmp(base ? base + 1 : path, "steamwebhelper") != 0) return NULL;
|
||||
@@ -342,7 +342,7 @@ static char **web_helper_redirect(const char *path, char *const argv[], const ch
|
||||
}
|
||||
|
||||
int execve(const char *path, char *const argv_in[], char *const envp[]) {
|
||||
char *const *argv = bl_webhelper_argv(path, argv_in, envp);
|
||||
char *const *argv = dd_webhelper_argv(path, argv_in, envp);
|
||||
static int (*real)(const char *, char *const[], char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[], char *const[]))dlsym(RTLD_NEXT, "execve");
|
||||
maybe_answer_lsof(path, argv);
|
||||
@@ -352,9 +352,9 @@ int execve(const char *path, char *const argv_in[], char *const envp[]) {
|
||||
real(launcher, redirected, envp);
|
||||
free(redirected);
|
||||
}
|
||||
bl_binfmt_before(path, argv, envp);
|
||||
dd_binfmt_before(path, argv, envp);
|
||||
real(path, argv, envp);
|
||||
return bl_binfmt_retry(path, argv, envp, errno);
|
||||
return dd_binfmt_retry(path, argv, envp, errno);
|
||||
}
|
||||
|
||||
static int answer_lsof_via_spawn(const char *path, char *const argv[], pid_t *pid) {
|
||||
@@ -373,17 +373,17 @@ static int answer_lsof_via_spawn(const char *path, char *const argv[], pid_t *pi
|
||||
}
|
||||
|
||||
int execvp(const char *file, char *const argv_in[]) {
|
||||
char *const *argv = bl_webhelper_argv(file, argv_in, environ);
|
||||
char *const *argv = dd_webhelper_argv(file, argv_in, environ);
|
||||
static int (*real)(const char *, char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[]))dlsym(RTLD_NEXT, "execvp");
|
||||
maybe_answer_lsof(file, argv);
|
||||
bl_binfmt_before_search(file, argv, environ);
|
||||
dd_binfmt_before_search(file, argv, environ);
|
||||
real(file, argv);
|
||||
return bl_binfmt_after_search(file, argv, environ, errno);
|
||||
return dd_binfmt_after_search(file, argv, environ, errno);
|
||||
}
|
||||
|
||||
int execv(const char *path, char *const argv_in[]) {
|
||||
char *const *argv = bl_webhelper_argv(path, argv_in, environ);
|
||||
char *const *argv = dd_webhelper_argv(path, argv_in, environ);
|
||||
static int (*real)(const char *, char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[]))dlsym(RTLD_NEXT, "execv");
|
||||
maybe_answer_lsof(path, argv);
|
||||
@@ -393,9 +393,9 @@ int execv(const char *path, char *const argv_in[]) {
|
||||
real(launcher, redirected);
|
||||
free(redirected);
|
||||
}
|
||||
bl_binfmt_before(path, argv, environ);
|
||||
dd_binfmt_before(path, argv, environ);
|
||||
real(path, argv);
|
||||
return bl_binfmt_retry(path, argv, environ, errno);
|
||||
return dd_binfmt_retry(path, argv, environ, errno);
|
||||
}
|
||||
|
||||
int posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa,
|
||||
@@ -407,6 +407,6 @@ int posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *
|
||||
}
|
||||
static spawn_fn real;
|
||||
if (!real) real = (spawn_fn)dlsym(RTLD_NEXT, "posix_spawn");
|
||||
char *const *adjusted = bl_webhelper_argv(path, argv, envp);
|
||||
return bl_binfmt_spawn(pid, path, fa, attr, (char *const *)adjusted, envp, real);
|
||||
char *const *adjusted = dd_webhelper_argv(path, argv, envp);
|
||||
return dd_binfmt_spawn(pid, path, fa, attr, (char *const *)adjusted, envp, real);
|
||||
}
|
||||
@@ -411,19 +411,19 @@ static int is_link_query(unsigned long request) {
|
||||
|| request == SIOCGIFBRDADDR;
|
||||
}
|
||||
|
||||
void bl_kgsl_chip_id_fixup(unsigned long request, void *arg, int rc);
|
||||
void dd_kgsl_chip_id_fixup(unsigned long request, void *arg, int rc);
|
||||
#include "../../quest/kgsl_compat.h"
|
||||
int bl_kgsl_poll(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
int dd_kgsl_poll(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
void bl_kgsl_track(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
void dd_kgsl_track(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
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_vdec_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,
|
||||
int dd_ntsync_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int dd_drm_gem_close(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int dd_venc_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int dd_vdec_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
void *arg, void *caller, int *rc) __attribute__((visibility("hidden")));
|
||||
int bl_writewatch_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request, void *arg,
|
||||
int dd_writewatch_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request, void *arg,
|
||||
int *rc) __attribute__((visibility("hidden")));
|
||||
|
||||
int ioctl(int fd, unsigned long request, ...) {
|
||||
@@ -435,16 +435,16 @@ int ioctl(int fd, unsigned long request, ...) {
|
||||
va_end(ap);
|
||||
|
||||
int rc;
|
||||
if (bl_ntsync_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (bl_venc_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (bl_vdec_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (bl_drm_gem_close(fd, request, arg, &rc)) return rc;
|
||||
if (dd_ntsync_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (dd_venc_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (dd_vdec_ioctl(fd, request, arg, &rc)) return rc;
|
||||
if (dd_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;
|
||||
if (bl_writewatch_ioctl(real, fd, request, arg, &rc)) return rc;
|
||||
if (!bl_kgsl_poll(real, fd, request, arg, &rc)) rc = quest_kgsl_ioctl(real, fd, request, arg);
|
||||
bl_kgsl_track(real, fd, request, arg, &rc);
|
||||
bl_kgsl_chip_id_fixup(request, arg, rc);
|
||||
if (dd_winebus_rumble_ioctl(real, fd, request, arg, __builtin_return_address(0), &rc)) return rc;
|
||||
if (dd_writewatch_ioctl(real, fd, request, arg, &rc)) return rc;
|
||||
if (!dd_kgsl_poll(real, fd, request, arg, &rc)) rc = quest_kgsl_ioctl(real, fd, request, arg);
|
||||
dd_kgsl_track(real, fd, request, arg, &rc);
|
||||
dd_kgsl_chip_id_fixup(request, arg, rc);
|
||||
if (arg == NULL || !is_link_query(request)) return rc;
|
||||
int saved = errno;
|
||||
if (answer_ifreq(request, (struct ifreq *) arg, rc)) return 0;
|
||||
@@ -595,19 +595,19 @@ static FILE *synthesize(const char *table) {
|
||||
return out;
|
||||
}
|
||||
|
||||
int bl_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
int dd_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
|
||||
const char *bl_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
|
||||
const char *dd_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
|
||||
|
||||
static FILE *open_stream(fopen_fn real, const char *path, const char *mode, const void *caller) {
|
||||
int status = mode && mode[0] == 'r' && !strchr(mode, '+')
|
||||
? bl_status_without_tracer(path, O_RDONLY | O_CLOEXEC, caller) : -1;
|
||||
? dd_status_without_tracer(path, O_RDONLY | O_CLOEXEC, caller) : -1;
|
||||
if (status >= 0) {
|
||||
FILE *copy = fdopen(status, "r");
|
||||
if (copy == NULL) close(status);
|
||||
return copy;
|
||||
}
|
||||
path = bl_oom_adj_redirect(path, mode && (mode[0] == 'w' || mode[0] == 'a' || strchr(mode, '+')));
|
||||
path = dd_oom_adj_redirect(path, mode && (mode[0] == 'w' || mode[0] == 'a' || strchr(mode, '+')));
|
||||
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;
|
||||
@@ -705,9 +705,9 @@ struct nl_reply {
|
||||
int overflow;
|
||||
};
|
||||
|
||||
static const char nl_client_magic[12] = "bl-nl-c-v1";
|
||||
static const char nl_peer_magic[12] = "bl-nl-p-v1";
|
||||
static const char nl_reservation_magic[12] = "bl-nl-r-v1";
|
||||
static const char nl_client_magic[12] = "dd-nl-c-v1";
|
||||
static const char nl_peer_magic[12] = "dd-nl-p-v1";
|
||||
static const char nl_reservation_magic[12] = "dd-nl-r-v1";
|
||||
static struct nl_socket *nl_sockets;
|
||||
static struct nl_fd *nl_fds;
|
||||
static struct nl_fd_page *nl_fd_pages[NL_FD_BUCKETS];
|
||||
@@ -1206,36 +1206,36 @@ static unsigned nl_port_of(int fd) {
|
||||
return port;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_nl_socket(int type, int *fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_bind(int fd, const struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_socket(int type, int *fd);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_bind(int fd, const struct sockaddr *addr,
|
||||
socklen_t len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getsockname(int fd, struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_getsockname(int fd, struct sockaddr *addr,
|
||||
socklen_t *len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_owns(int fd);
|
||||
__attribute__((visibility("hidden"))) void bl_nl_closed(int fd);
|
||||
__attribute__((visibility("hidden"))) void bl_nl_range_closed(unsigned int first, unsigned int last);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_before_dup(int fd, void **state);
|
||||
__attribute__((visibility("hidden"))) void bl_nl_after_dup(void *state, int fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_connect(int fd, const struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_owns(int fd);
|
||||
__attribute__((visibility("hidden"))) void dd_nl_closed(int fd);
|
||||
__attribute__((visibility("hidden"))) void dd_nl_range_closed(unsigned int first, unsigned int last);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_before_dup(int fd, void **state);
|
||||
__attribute__((visibility("hidden"))) void dd_nl_after_dup(void *state, int fd);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_connect(int fd, const struct sockaddr *addr,
|
||||
socklen_t len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getpeername(int fd, struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_getpeername(int fd, struct sockaddr *addr,
|
||||
socklen_t *len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_setsockopt(int fd, int level, int option,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_setsockopt(int fd, int level, int option,
|
||||
const void *value, socklen_t len,
|
||||
int (*real)(int, int, int, const void *, socklen_t),
|
||||
int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getsockopt(int fd, int level, int option,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_getsockopt(int fd, int level, int option,
|
||||
void *value, socklen_t *len,
|
||||
int (*real)(int, int, int, void *, socklen_t *),
|
||||
int *rc);
|
||||
__attribute__((visibility("hidden"))) void bl_nl_received(struct msghdr *msg);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_recvmsg(int fd, struct msghdr *msg, int flags,
|
||||
__attribute__((visibility("hidden"))) void dd_nl_received(struct msghdr *msg);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_recvmsg(int fd, struct msghdr *msg, int flags,
|
||||
ssize_t (*real)(int, struct msghdr *, int),
|
||||
ssize_t *rc);
|
||||
|
||||
int bl_nl_owns(int fd) { return nl_peer_of(fd) >= 0; }
|
||||
int dd_nl_owns(int fd) { return nl_peer_of(fd) >= 0; }
|
||||
|
||||
int bl_nl_socket(int type, int *fd) {
|
||||
int dd_nl_socket(int type, int *fd) {
|
||||
int kind = type & 0xf;
|
||||
*fd = -1;
|
||||
if (type & ~(0xf | SOCK_CLOEXEC | SOCK_NONBLOCK)) {
|
||||
@@ -1342,10 +1342,10 @@ static int nl_autobind(int fd) {
|
||||
return nl_bind_port(fd, 0, 1);
|
||||
}
|
||||
|
||||
int bl_nl_bind(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
||||
int dd_nl_bind(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
||||
const struct sockaddr_nl *nl;
|
||||
if (addr && len >= sizeof(sa_family_t) && addr->sa_family == AF_NETLINK) nl_discover(fd);
|
||||
if (!bl_nl_owns(fd)) return 0;
|
||||
if (!dd_nl_owns(fd)) return 0;
|
||||
if (addr == NULL || len < sizeof(struct sockaddr_nl) || addr->sa_family != AF_NETLINK) {
|
||||
errno = EINVAL;
|
||||
*rc = -1;
|
||||
@@ -1361,10 +1361,10 @@ int bl_nl_bind(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bl_nl_getsockname(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
||||
int dd_nl_getsockname(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
||||
struct sockaddr_nl nl;
|
||||
socklen_t size;
|
||||
if (!bl_nl_owns(fd)) return 0;
|
||||
if (!dd_nl_owns(fd)) return 0;
|
||||
if (addr == NULL || len == NULL) {
|
||||
errno = EFAULT;
|
||||
*rc = -1;
|
||||
@@ -1380,13 +1380,13 @@ int bl_nl_getsockname(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bl_nl_closed(int fd) {
|
||||
void dd_nl_closed(int fd) {
|
||||
if (!nl_tracked(fd)) return;
|
||||
if (nl_foreign()) return;
|
||||
bl_nl_range_closed((unsigned int) fd, (unsigned int) fd);
|
||||
dd_nl_range_closed((unsigned int) fd, (unsigned int) fd);
|
||||
}
|
||||
|
||||
void bl_nl_range_closed(unsigned int first, unsigned int last) {
|
||||
void dd_nl_range_closed(unsigned int first, unsigned int last) {
|
||||
if (__atomic_load_n(&nl_fd_count, __ATOMIC_ACQUIRE) == 0) return;
|
||||
if (nl_foreign()) return;
|
||||
pthread_mutex_lock(&nl_sockets_lock);
|
||||
@@ -1400,7 +1400,7 @@ void bl_nl_range_closed(unsigned int first, unsigned int last) {
|
||||
pthread_mutex_unlock(&nl_sockets_lock);
|
||||
}
|
||||
|
||||
int bl_nl_before_dup(int fd, void **state) {
|
||||
int dd_nl_before_dup(int fd, void **state) {
|
||||
*state = NULL;
|
||||
if (!nl_tracked(fd)) return 0;
|
||||
if (nl_foreign()) return 0;
|
||||
@@ -1421,7 +1421,7 @@ int bl_nl_before_dup(int fd, void **state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bl_nl_after_dup(void *state, int fd) {
|
||||
void dd_nl_after_dup(void *state, int fd) {
|
||||
int saved = errno;
|
||||
struct nl_fd *reserved = state;
|
||||
if (reserved == NULL && !nl_tracked(fd)) {
|
||||
@@ -1456,9 +1456,9 @@ int dup(int fd) {
|
||||
static int (*real)(int);
|
||||
void *state;
|
||||
if (real == NULL) real = (int (*)(int)) dlsym(RTLD_NEXT, "dup");
|
||||
if (bl_nl_before_dup(fd, &state) != 0) return -1;
|
||||
if (dd_nl_before_dup(fd, &state) != 0) return -1;
|
||||
int result = real(fd);
|
||||
bl_nl_after_dup(state, result);
|
||||
dd_nl_after_dup(state, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1470,9 +1470,9 @@ static int nl_destination(const struct sockaddr *addr, socklen_t len) {
|
||||
return destination->nl_pid == 0 ? 0 : -ECONNREFUSED;
|
||||
}
|
||||
|
||||
int bl_nl_connect(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
||||
int dd_nl_connect(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
||||
if (addr && len >= sizeof(sa_family_t) && addr->sa_family == AF_NETLINK) nl_discover(fd);
|
||||
if (!bl_nl_owns(fd)) return 0;
|
||||
if (!dd_nl_owns(fd)) return 0;
|
||||
int disconnect = addr && len >= sizeof(sa_family_t) && addr->sa_family == AF_UNSPEC;
|
||||
int error = disconnect ? 0 : nl_destination(addr, len);
|
||||
if (error) {
|
||||
@@ -1493,8 +1493,8 @@ static void nl_source_name(struct sockaddr *addr, socklen_t *len) {
|
||||
*len = sizeof(source);
|
||||
}
|
||||
|
||||
int bl_nl_getpeername(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
||||
if (!bl_nl_owns(fd)) return 0;
|
||||
int dd_nl_getpeername(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
||||
if (!dd_nl_owns(fd)) return 0;
|
||||
if (addr == NULL || len == NULL) {
|
||||
errno = EFAULT;
|
||||
*rc = -1;
|
||||
@@ -1505,7 +1505,7 @@ int bl_nl_getpeername(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bl_nl_setsockopt(int fd, int level, int option, const void *value, socklen_t len,
|
||||
int dd_nl_setsockopt(int fd, int level, int option, const void *value, socklen_t len,
|
||||
int (*real)(int, int, int, const void *, socklen_t), int *rc) {
|
||||
if (level == SOL_NETLINK) nl_discover(fd);
|
||||
int peer = nl_peer_of(fd);
|
||||
@@ -1542,7 +1542,7 @@ int bl_nl_setsockopt(int fd, int level, int option, const void *value, socklen_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bl_nl_getsockopt(int fd, int level, int option, void *value, socklen_t *len,
|
||||
int dd_nl_getsockopt(int fd, int level, int option, void *value, socklen_t *len,
|
||||
int (*real)(int, int, int, void *, socklen_t *), int *rc) {
|
||||
if (level != SOL_SOCKET || (option != SO_TYPE && option != SO_DOMAIN && option != SO_PROTOCOL))
|
||||
return 0;
|
||||
@@ -1580,7 +1580,7 @@ int bl_nl_getsockopt(int fd, int level, int option, void *value, socklen_t *len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bl_nl_received(struct msghdr *msg) {
|
||||
void dd_nl_received(struct msghdr *msg) {
|
||||
for (struct cmsghdr *control = CMSG_FIRSTHDR(msg); control; control = CMSG_NXTHDR(msg, control)) {
|
||||
if (control->cmsg_len < CMSG_LEN(0)) break;
|
||||
if (control->cmsg_level != SOL_SOCKET || control->cmsg_type != SCM_RIGHTS) continue;
|
||||
@@ -1593,11 +1593,11 @@ void bl_nl_received(struct msghdr *msg) {
|
||||
}
|
||||
}
|
||||
|
||||
int bl_nl_recvmsg(int fd, struct msghdr *msg, int flags,
|
||||
int dd_nl_recvmsg(int fd, struct msghdr *msg, int flags,
|
||||
ssize_t (*real)(int, struct msghdr *, int), ssize_t *rc) {
|
||||
ssize_t result;
|
||||
socklen_t capacity = 0;
|
||||
if (!bl_nl_owns(fd)) return 0;
|
||||
if (!dd_nl_owns(fd)) return 0;
|
||||
if (msg && msg->msg_name) capacity = msg->msg_namelen;
|
||||
result = real(fd, msg, flags);
|
||||
if (result >= 0 && msg && msg->msg_name) {
|
||||
@@ -1614,7 +1614,7 @@ ssize_t recvfrom(int fd, void *buffer, size_t length, int flags,
|
||||
if (real == NULL)
|
||||
real = (ssize_t (*)(int, void *, size_t, int, struct sockaddr *, socklen_t *))
|
||||
dlsym(RTLD_NEXT, "recvfrom");
|
||||
int owned = bl_nl_owns(fd);
|
||||
int owned = dd_nl_owns(fd);
|
||||
socklen_t capacity = owned && addr && addrlen ? *addrlen : 0;
|
||||
ssize_t result = real(fd, buffer, length, flags, addr, addrlen);
|
||||
if (result >= 0 && owned && addr && addrlen) {
|
||||
@@ -2108,7 +2108,7 @@ static ssize_t sendmsg_request(int fd, const struct msghdr *msg, int flags) {
|
||||
|
||||
ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) {
|
||||
static ssize_t (*real)(int, const struct msghdr *, int);
|
||||
if (bl_nl_owns(fd)) {
|
||||
if (dd_nl_owns(fd)) {
|
||||
int error = msg && msg->msg_name ? nl_destination(msg->msg_name, msg->msg_namelen) : 0;
|
||||
if (error) {
|
||||
errno = -error;
|
||||
@@ -2128,7 +2128,7 @@ ssize_t sendto(int fd, const void *buffer, size_t length, int flags,
|
||||
const struct sockaddr *addr, socklen_t addrlen) {
|
||||
static ssize_t (*real)(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
||||
ssize_t rc;
|
||||
if (bl_nl_owns(fd)) {
|
||||
if (dd_nl_owns(fd)) {
|
||||
int error = addr ? nl_destination(addr, addrlen) : 0;
|
||||
if (error) {
|
||||
errno = -error;
|
||||
@@ -2149,7 +2149,7 @@ ssize_t sendto(int fd, const void *buffer, size_t length, int flags,
|
||||
ssize_t send(int fd, const void *buffer, size_t length, int flags) {
|
||||
static ssize_t (*real)(int, const void *, size_t, int);
|
||||
ssize_t rc;
|
||||
if (bl_nl_owns(fd) && deliver(fd, buffer, length, flags, &rc)) return rc;
|
||||
if (dd_nl_owns(fd) && deliver(fd, buffer, length, flags, &rc)) return rc;
|
||||
if (real == NULL) real = (ssize_t (*)(int, const void *, size_t, int)) dlsym(RTLD_NEXT, "send");
|
||||
if (real == NULL) {
|
||||
errno = ENOSYS;
|
||||
@@ -2161,7 +2161,7 @@ ssize_t send(int fd, const void *buffer, size_t length, int flags) {
|
||||
ssize_t write(int fd, const void *buffer, size_t length) {
|
||||
static ssize_t (*real)(int, const void *, size_t);
|
||||
ssize_t rc;
|
||||
if (bl_nl_owns(fd) && deliver(fd, buffer, length, 0, &rc)) return rc;
|
||||
if (dd_nl_owns(fd) && deliver(fd, buffer, length, 0, &rc)) return rc;
|
||||
if (real == NULL) real = (ssize_t (*)(int, const void *, size_t)) dlsym(RTLD_NEXT, "write");
|
||||
if (real == NULL) {
|
||||
errno = ENOSYS;
|
||||
@@ -2172,7 +2172,7 @@ ssize_t write(int fd, const void *buffer, size_t length) {
|
||||
|
||||
ssize_t writev(int fd, const struct iovec *iov, int iovcnt) {
|
||||
static ssize_t (*real)(int, const struct iovec *, int);
|
||||
if (iovcnt >= 0 && bl_nl_owns(fd)) {
|
||||
if (iovcnt >= 0 && dd_nl_owns(fd)) {
|
||||
struct msghdr msg = { .msg_iov = (struct iovec *) iov, .msg_iovlen = (size_t) iovcnt };
|
||||
return sendmsg_request(fd, &msg, 0);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ static int in_fex(void) {
|
||||
return known;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_noexec_retry(int prot, int flags, int fd) {
|
||||
__attribute__((visibility("hidden"))) int dd_noexec_retry(int prot, int flags, int fd) {
|
||||
int error = errno;
|
||||
struct statvfs vfs;
|
||||
int retry = (error == EACCES || error == EPERM) && (prot & PROT_EXEC) && fd >= 0 && !(flags & MAP_ANONYMOUS) &&
|
||||
@@ -146,7 +146,7 @@ int mprotect(void *addr, size_t len, int prot) {
|
||||
|
||||
#else
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_noexec_retry(int prot, int flags, int fd) {
|
||||
__attribute__((visibility("hidden"))) int dd_noexec_retry(int prot, int flags, int fd) {
|
||||
(void)prot, (void)flags, (void)fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ static int (*ns_real_close)(int);
|
||||
|
||||
static int ns_on(void) {
|
||||
if (ns_state < 0) {
|
||||
const char *e = getenv("BL_SYNC");
|
||||
const char *e = getenv("DD_SYNC");
|
||||
ns_state = e && e[0] == '1';
|
||||
}
|
||||
return ns_state;
|
||||
@@ -276,7 +276,7 @@ static __thread struct ns_cs ns_cs;
|
||||
static uintptr_t ns_handlers[_NSIG];
|
||||
static uint8_t ns_siginfo[_NSIG];
|
||||
|
||||
int bl_from_ntdll(const void *caller) __attribute__((visibility("hidden")));
|
||||
int dd_from_ntdll(const void *caller) __attribute__((visibility("hidden")));
|
||||
|
||||
static int ns_deferrable(int sig) {
|
||||
return sig > 0 && sig < _NSIG && sig != SIGKILL && sig != SIGSTOP && sig != SIGSEGV && sig != SIGBUS && sig != SIGILL
|
||||
@@ -383,7 +383,7 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *old) {
|
||||
struct sigaction mine;
|
||||
const struct sigaction *use = act;
|
||||
if (act && act->sa_handler != SIG_DFL && act->sa_handler != SIG_IGN && !(act->sa_flags & SA_RESETHAND) &&
|
||||
bl_from_ntdll(__builtin_return_address(0))) {
|
||||
dd_from_ntdll(__builtin_return_address(0))) {
|
||||
mine = *act;
|
||||
mine.sa_sigaction = ns_trampoline;
|
||||
mine.sa_flags |= SA_SIGINFO;
|
||||
@@ -1373,8 +1373,8 @@ static int ns_dev_ioctl(struct ns_dev *d, unsigned long req, void *arg, int *fd)
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
int bl_ntsync_ioctl(int fd, unsigned long req, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int bl_ntsync_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
int dd_ntsync_ioctl(int fd, unsigned long req, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int dd_ntsync_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
if (_IOC_TYPE(req) != 'N' || _IOC_NR(req) < 0x80 || _IOC_NR(req) > 0x8d) return 0;
|
||||
if (!__atomic_load_n(&ns_ndev, __ATOMIC_ACQUIRE) && !ns_on()) return 0;
|
||||
uint64_t e = ns_lookup(fd);
|
||||
@@ -1393,8 +1393,8 @@ int bl_ntsync_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bl_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_ntsync_open(const char *path, int flags) {
|
||||
int dd_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int dd_ntsync_open(const char *path, int flags) {
|
||||
if (!path || strcmp(path, "/dev/ntsync") != 0 || !ns_on()) return -2;
|
||||
int fd = (int)syscall(SYS_openat, AT_FDCWD, path, flags, 0);
|
||||
if (fd >= 0) return fd;
|
||||
@@ -1440,41 +1440,41 @@ static void ns_received(struct msghdr *msg) {
|
||||
}
|
||||
}
|
||||
|
||||
int bl_udevmon_recvmsg(int fd, struct msghdr *msg, int flags, ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
int dd_udevmon_recvmsg(int fd, struct msghdr *msg, int flags, ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
ssize_t *result) __attribute__((visibility("hidden")));
|
||||
int bl_nl_recvmsg(int fd, struct msghdr *msg, int flags, ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
int dd_nl_recvmsg(int fd, struct msghdr *msg, int flags, ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
ssize_t *result) __attribute__((visibility("hidden")));
|
||||
void bl_nl_received(struct msghdr *msg) __attribute__((visibility("hidden")));
|
||||
void bl_nl_closed(int fd) __attribute__((visibility("hidden")));
|
||||
void bl_nl_range_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
int bl_nl_before_dup(int fd, void **state) __attribute__((visibility("hidden")));
|
||||
void bl_nl_after_dup(void *state, int fd) __attribute__((visibility("hidden")));
|
||||
void dd_nl_received(struct msghdr *msg) __attribute__((visibility("hidden")));
|
||||
void dd_nl_closed(int fd) __attribute__((visibility("hidden")));
|
||||
void dd_nl_range_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
int dd_nl_before_dup(int fd, void **state) __attribute__((visibility("hidden")));
|
||||
void dd_nl_after_dup(void *state, int fd) __attribute__((visibility("hidden")));
|
||||
|
||||
ssize_t recvmsg(int fd, struct msghdr *msg, int flags) {
|
||||
static ssize_t (*real)(int, struct msghdr *, int);
|
||||
if (!real) real = (ssize_t (*)(int, struct msghdr *, int))dlsym(RTLD_NEXT, "recvmsg");
|
||||
ssize_t answered;
|
||||
if (msg && bl_nl_recvmsg(fd, msg, flags, real, &answered)) return answered;
|
||||
if (msg && bl_udevmon_recvmsg(fd, msg, flags, real, &answered)) return answered;
|
||||
if (msg && dd_nl_recvmsg(fd, msg, flags, real, &answered)) return answered;
|
||||
if (msg && dd_udevmon_recvmsg(fd, msg, flags, real, &answered)) return answered;
|
||||
ssize_t r = real(fd, msg, flags);
|
||||
if (r >= 0 && msg && msg->msg_control && msg->msg_controllen) {
|
||||
int saved = errno;
|
||||
bl_nl_received(msg);
|
||||
dd_nl_received(msg);
|
||||
if (ns_on()) ns_received(msg);
|
||||
errno = saved;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void bl_fsync_fds_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
void bl_venc_closed(int fd) __attribute__((visibility("hidden")));
|
||||
void bl_vdec_closed(int fd) __attribute__((visibility("hidden")));
|
||||
void dd_fsync_fds_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
void dd_venc_closed(int fd) __attribute__((visibility("hidden")));
|
||||
void dd_vdec_closed(int fd) __attribute__((visibility("hidden")));
|
||||
|
||||
int close(int fd) {
|
||||
if (fd >= 0) bl_fsync_fds_closed((unsigned int)fd, (unsigned int)fd);
|
||||
bl_venc_closed(fd);
|
||||
bl_vdec_closed(fd);
|
||||
bl_nl_closed(fd);
|
||||
if (fd >= 0) dd_fsync_fds_closed((unsigned int)fd, (unsigned int)fd);
|
||||
dd_venc_closed(fd);
|
||||
dd_vdec_closed(fd);
|
||||
dd_nl_closed(fd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && fd >= 0 && fd < NS_FDS && __atomic_load_n(&t[fd], __ATOMIC_ACQUIRE)) ns_forget(fd);
|
||||
int saved = errno;
|
||||
@@ -1492,12 +1492,12 @@ int dup2(int oldfd, int newfd) {
|
||||
if (!real) real = (int (*)(int, int))dlsym(RTLD_NEXT, "dup2");
|
||||
if (oldfd == newfd) return real(oldfd, newfd);
|
||||
void *nl_state;
|
||||
if (bl_nl_before_dup(oldfd, &nl_state) != 0) return -1;
|
||||
if (oldfd != newfd && newfd >= 0) bl_fsync_fds_closed((unsigned int)newfd, (unsigned int)newfd);
|
||||
if (dd_nl_before_dup(oldfd, &nl_state) != 0) return -1;
|
||||
if (oldfd != newfd && newfd >= 0) dd_fsync_fds_closed((unsigned int)newfd, (unsigned int)newfd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && oldfd != newfd && newfd >= 0 && newfd < NS_FDS && __atomic_load_n(&t[newfd], __ATOMIC_ACQUIRE)) ns_forget(newfd);
|
||||
int result = real(oldfd, newfd);
|
||||
bl_nl_after_dup(nl_state, result);
|
||||
dd_nl_after_dup(nl_state, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1506,12 +1506,12 @@ int dup3(int oldfd, int newfd, int flags) {
|
||||
if (!real) real = (int (*)(int, int, int))dlsym(RTLD_NEXT, "dup3");
|
||||
if (oldfd == newfd) return real(oldfd, newfd, flags);
|
||||
void *nl_state;
|
||||
if (bl_nl_before_dup(oldfd, &nl_state) != 0) return -1;
|
||||
if (oldfd != newfd && newfd >= 0) bl_fsync_fds_closed((unsigned int)newfd, (unsigned int)newfd);
|
||||
if (dd_nl_before_dup(oldfd, &nl_state) != 0) return -1;
|
||||
if (oldfd != newfd && newfd >= 0) dd_fsync_fds_closed((unsigned int)newfd, (unsigned int)newfd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && oldfd != newfd && newfd >= 0 && newfd < NS_FDS && __atomic_load_n(&t[newfd], __ATOMIC_ACQUIRE)) ns_forget(newfd);
|
||||
int result = real(oldfd, newfd, flags);
|
||||
bl_nl_after_dup(nl_state, result);
|
||||
dd_nl_after_dup(nl_state, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1526,7 +1526,7 @@ int close_range(unsigned int first, unsigned int last, int flags) {
|
||||
static int (*real)(unsigned int, unsigned int, int);
|
||||
if (!real) real = (int (*)(unsigned int, unsigned int, int))dlsym(RTLD_NEXT, "close_range");
|
||||
if (!(flags & CLOSE_RANGE_CLOEXEC)) {
|
||||
bl_fsync_fds_closed(first, last);
|
||||
dd_fsync_fds_closed(first, last);
|
||||
ns_forget_range(first, last);
|
||||
}
|
||||
if (!real) {
|
||||
@@ -1534,7 +1534,7 @@ int close_range(unsigned int first, unsigned int last, int flags) {
|
||||
return -1;
|
||||
}
|
||||
int result = real(first, last, flags);
|
||||
if (result == 0 && !(flags & CLOSE_RANGE_CLOEXEC)) bl_nl_range_closed(first, last);
|
||||
if (result == 0 && !(flags & CLOSE_RANGE_CLOEXEC)) dd_nl_range_closed(first, last);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1542,12 +1542,12 @@ void closefrom(int lowfd) {
|
||||
static void (*real)(int);
|
||||
if (!real) real = (void (*)(int))dlsym(RTLD_NEXT, "closefrom");
|
||||
if (lowfd >= 0) {
|
||||
bl_fsync_fds_closed((unsigned int)lowfd, ~0u);
|
||||
dd_fsync_fds_closed((unsigned int)lowfd, ~0u);
|
||||
ns_forget_range((unsigned int)lowfd, ~0u);
|
||||
}
|
||||
if (real) {
|
||||
real(lowfd);
|
||||
if (lowfd >= 0) bl_nl_range_closed((unsigned int)lowfd, ~0u);
|
||||
if (lowfd >= 0) dd_nl_range_closed((unsigned int)lowfd, ~0u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static int is_oom_score_adj(const char *path) {
|
||||
return strcmp(p, "oom_score_adj") == 0 || strcmp(p, "oom_adj") == 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) const char *bl_oom_adj_redirect(const char *path, int writing) {
|
||||
__attribute__((visibility("hidden"))) const char *dd_oom_adj_redirect(const char *path, int writing) {
|
||||
static int logged;
|
||||
if (!writing || !is_oom_score_adj(path)) return path;
|
||||
if (!__atomic_exchange_n(&logged, 1, __ATOMIC_RELAXED)) {
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int bl_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
int bl_writable_retry(int dirfd, const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
const char *bl_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
|
||||
int bl_venc_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_vdec_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int bl_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int dd_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
|
||||
int dd_writable_retry(int dirfd, const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int dd_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
const char *dd_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
|
||||
int dd_venc_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int dd_vdec_open(const char *path, int flags) __attribute__((visibility("hidden")));
|
||||
int dd_dircache_create(int dirfd, const char *path, int flags, mode_t mode,
|
||||
int (*real)(int, const char *, int, mode_t)) __attribute__((visibility("hidden")));
|
||||
|
||||
static int (*real_open)(const char *, int, ...);
|
||||
@@ -49,19 +49,19 @@ static int open_from(const char *path, int flags, mode_t mode, const void *calle
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
path = bl_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
|
||||
if ((fd = bl_status_without_tracer(path, flags, caller)) >= 0) return fd;
|
||||
if ((fd = bl_ntsync_open(path, flags)) != -2) return fd;
|
||||
if ((fd = bl_venc_open(path, flags)) != -2) return fd;
|
||||
if ((fd = bl_vdec_open(path, flags)) != -2) return fd;
|
||||
path = dd_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
|
||||
if ((fd = dd_status_without_tracer(path, flags, caller)) >= 0) return fd;
|
||||
if ((fd = dd_ntsync_open(path, flags)) != -2) return fd;
|
||||
if ((fd = dd_venc_open(path, flags)) != -2) return fd;
|
||||
if ((fd = dd_vdec_open(path, flags)) != -2) return fd;
|
||||
if (real_open == NULL) real_open = dlsym(RTLD_NEXT, "open");
|
||||
if (real_open == NULL) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
fd = bl_dircache_create(AT_FDCWD, path, flags, mode, via_open);
|
||||
fd = dd_dircache_create(AT_FDCWD, path, flags, mode, via_open);
|
||||
if (retry_without_noatime(fd, flags)) fd = real_open(path, flags & ~O_NOATIME, mode);
|
||||
if (fd < 0 && bl_writable_retry(AT_FDCWD, path, flags)) fd = real_open(path, flags & ~O_NOATIME, mode);
|
||||
if (fd < 0 && dd_writable_retry(AT_FDCWD, path, flags)) fd = real_open(path, flags & ~O_NOATIME, mode);
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -72,19 +72,19 @@ static int openat_from(int dirfd, const char *path, int flags, mode_t mode, cons
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
path = bl_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
|
||||
if ((fd = bl_status_without_tracer(path, flags, caller)) >= 0) return fd;
|
||||
if ((fd = bl_ntsync_open(path, flags)) != -2) return fd;
|
||||
if ((fd = bl_venc_open(path, flags)) != -2) return fd;
|
||||
if ((fd = bl_vdec_open(path, flags)) != -2) return fd;
|
||||
path = dd_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
|
||||
if ((fd = dd_status_without_tracer(path, flags, caller)) >= 0) return fd;
|
||||
if ((fd = dd_ntsync_open(path, flags)) != -2) return fd;
|
||||
if ((fd = dd_venc_open(path, flags)) != -2) return fd;
|
||||
if ((fd = dd_vdec_open(path, flags)) != -2) return fd;
|
||||
if (real_openat == NULL) real_openat = dlsym(RTLD_NEXT, "openat");
|
||||
if (real_openat == NULL) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
fd = bl_dircache_create(dirfd, path, flags, mode, via_openat);
|
||||
fd = dd_dircache_create(dirfd, path, flags, mode, via_openat);
|
||||
if (retry_without_noatime(fd, flags)) fd = real_openat(dirfd, path, flags & ~O_NOATIME, mode);
|
||||
if (fd < 0 && bl_writable_retry(dirfd, path, flags)) fd = real_openat(dirfd, path, flags & ~O_NOATIME, mode);
|
||||
if (fd < 0 && dd_writable_retry(dirfd, path, flags)) fd = real_openat(dirfd, path, flags & ~O_NOATIME, mode);
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define EXFAT_MAGIC 0x2011bab0
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_is_wineserver(void) {
|
||||
int dd_is_wineserver(void) {
|
||||
static int cached = -1;
|
||||
char exe[PATH_MAX];
|
||||
const char *base;
|
||||
@@ -40,11 +40,11 @@ static int has_no_unix_owner(int fd) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
void bl_storage_owner(int fd, struct stat *st) {
|
||||
void dd_storage_owner(int fd, struct stat *st) {
|
||||
int saved = errno;
|
||||
uid_t uid;
|
||||
|
||||
if (st != NULL && bl_is_wineserver()) {
|
||||
if (st != NULL && dd_is_wineserver()) {
|
||||
uid = getuid();
|
||||
if (st->st_uid != uid && has_no_unix_owner(fd)) st->st_uid = uid;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ int fchmod(int fd, mode_t mode) {
|
||||
return -1;
|
||||
}
|
||||
result = next_fchmod(fd, mode);
|
||||
if (result != 0 && errno == EPERM && bl_is_wineserver()) {
|
||||
if (result != 0 && errno == EPERM && dd_is_wineserver()) {
|
||||
if (has_no_unix_owner(fd)) {
|
||||
errno = saved;
|
||||
return 0;
|
||||
|
||||
@@ -40,7 +40,7 @@ static int enabled(void) {
|
||||
const char *off;
|
||||
|
||||
if (cached >= 0) return cached;
|
||||
off = getenv("BL_NO_PATH_CACHE");
|
||||
off = getenv("DD_NO_PATH_CACHE");
|
||||
cached = strcmp(program_invocation_short_name, "steam") == 0 &&
|
||||
(strstr(program_invocation_name, "steamrtarm64") != NULL ||
|
||||
strstr(program_invocation_name, "steamrt64") != NULL) &&
|
||||
@@ -83,7 +83,7 @@ static void store(const char *path, int kind, int mode, int flags, unsigned h, c
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
char *bl_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *)) {
|
||||
char *dd_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *)) {
|
||||
char out[PATH_MAX];
|
||||
unsigned h;
|
||||
struct entry *e;
|
||||
@@ -111,7 +111,7 @@ char *bl_cached_realpath(const char *path, char *resolved, char *(*real)(const c
|
||||
return strdup(out);
|
||||
}
|
||||
|
||||
int bl_dircache_absent(const char *path) __attribute__((weak, visibility("hidden")));
|
||||
int dd_dircache_absent(const char *path) __attribute__((weak, visibility("hidden")));
|
||||
|
||||
static int cached_access(const char *path, int mode, int flags, int (*check)(const char *, int, int)) {
|
||||
unsigned h;
|
||||
@@ -124,7 +124,7 @@ static int cached_access(const char *path, int mode, int flags, int (*check)(con
|
||||
hit = find(path, KIND_ACCESS, mode, flags, h) != NULL;
|
||||
pthread_mutex_unlock(&lock);
|
||||
if (hit) return 0;
|
||||
if (bl_dircache_absent && bl_dircache_absent(path)) {
|
||||
if (dd_dircache_absent && dd_dircache_absent(path)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
@@ -144,11 +144,11 @@ static int (*next_faccessat(void))(int, const char *, int, int) {
|
||||
return real;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_binfmt_runnable(const char *path, int mode);
|
||||
__attribute__((visibility("hidden"))) int bl_writable_access(int dirfd, const char *path, int mode, int flags);
|
||||
__attribute__((visibility("hidden"))) int dd_binfmt_runnable(const char *path, int mode);
|
||||
__attribute__((visibility("hidden"))) int dd_writable_access(int dirfd, const char *path, int mode, int flags);
|
||||
|
||||
static int writable_as_owner(int (*real)(int, const char *, int, int), int dirfd, const char *path, int mode, int flags) {
|
||||
if (!bl_writable_access(dirfd, path, mode, flags)) return -1;
|
||||
if (!dd_writable_access(dirfd, path, mode, flags)) return -1;
|
||||
if ((mode & ~W_OK) == 0 || real(dirfd, path, mode & ~W_OK, flags) == 0) return 0;
|
||||
return -1;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ static int check_cwd(const char *path, int mode, int flags) {
|
||||
result = real(AT_FDCWD, path, mode, flags);
|
||||
if (result == 0) return 0;
|
||||
err = errno;
|
||||
if (err == EACCES && bl_binfmt_runnable(path, mode)) return 0;
|
||||
if (err == EACCES && dd_binfmt_runnable(path, mode)) return 0;
|
||||
errno = err;
|
||||
if (writable_as_owner(real, AT_FDCWD, path, mode, flags) == 0) return 0;
|
||||
errno = err;
|
||||
|
||||
@@ -60,7 +60,7 @@ static int grant_owner_write(int dirfd, const char *path) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_writable_retry(int dirfd, const char *path, int flags) {
|
||||
int dd_writable_retry(int dirfd, const char *path, int flags) {
|
||||
int saved = errno;
|
||||
int granted = 0;
|
||||
char parent[PATH_MAX];
|
||||
@@ -84,7 +84,7 @@ int bl_writable_retry(int dirfd, const char *path, int flags) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
int bl_writable_access(int dirfd, const char *path, int mode, int flags) {
|
||||
int dd_writable_access(int dirfd, const char *path, int mode, int flags) {
|
||||
int saved = errno;
|
||||
struct stat st;
|
||||
int owned;
|
||||
|
||||
@@ -21,22 +21,22 @@
|
||||
#define SYS_openat2 437
|
||||
#endif
|
||||
|
||||
#define BL_RESOLVE_BENEATH 0x08
|
||||
#define BL_RESOLVE_IN_ROOT 0x10
|
||||
#define BL_MAX_SYMLINKS 40
|
||||
#define BL_PROC_ROOT_INO 1
|
||||
#define DD_RESOLVE_BENEATH 0x08
|
||||
#define DD_RESOLVE_IN_ROOT 0x10
|
||||
#define DD_MAX_SYMLINKS 40
|
||||
#define DD_PROC_ROOT_INO 1
|
||||
|
||||
#ifdef SYS_newfstatat
|
||||
#define BL_SYS_FSTATAT SYS_newfstatat
|
||||
#define BL_FSTATAT_NAME "fstatat"
|
||||
typedef struct stat bl_stat;
|
||||
#define DD_SYS_FSTATAT SYS_newfstatat
|
||||
#define DD_FSTATAT_NAME "fstatat"
|
||||
typedef struct stat dd_stat;
|
||||
#else
|
||||
#define BL_SYS_FSTATAT SYS_fstatat64
|
||||
#define BL_FSTATAT_NAME "fstatat64"
|
||||
typedef struct stat64 bl_stat;
|
||||
#define DD_SYS_FSTATAT SYS_fstatat64
|
||||
#define DD_FSTATAT_NAME "fstatat64"
|
||||
typedef struct stat64 dd_stat;
|
||||
#endif
|
||||
|
||||
struct bl_open_how {
|
||||
struct dd_open_how {
|
||||
uint64_t flags;
|
||||
uint64_t mode;
|
||||
uint64_t resolve;
|
||||
@@ -45,7 +45,7 @@ struct bl_open_how {
|
||||
static long (*real_syscall)(long, ...);
|
||||
static void *(*real_dlopen)(const char *, int);
|
||||
static int openat2_missing;
|
||||
static int (*next_fstatat)(int, const char *, bl_stat *, int);
|
||||
static int (*next_fstatat)(int, const char *, dd_stat *, int);
|
||||
static int (*next_openat)(int, const char *, int, ...);
|
||||
static ssize_t (*next_readlinkat)(int, const char *, char *, size_t);
|
||||
static int (*next_statx)(int, const char *, int, unsigned int, struct statx *);
|
||||
@@ -53,7 +53,7 @@ static int (*next_statx)(int, const char *, int, unsigned int, struct statx *);
|
||||
static int find_fastpath(struct dl_phdr_info *info, size_t size, void *name) {
|
||||
(void)size;
|
||||
const char *slash = strrchr(info->dlpi_name, '/');
|
||||
if (!slash || strcmp(slash + 1, "libblfastpath.so") != 0 || strlen(info->dlpi_name) >= PATH_MAX) {
|
||||
if (!slash || strcmp(slash + 1, "libddfastpath.so") != 0 || strlen(info->dlpi_name) >= PATH_MAX) {
|
||||
return 0;
|
||||
}
|
||||
strcpy(name, info->dlpi_name);
|
||||
@@ -65,16 +65,16 @@ __attribute__((constructor)) static void find_fastpath_calls(void) {
|
||||
dl_iterate_phdr(find_fastpath, name);
|
||||
void *fastpath = *name ? dlopen(name, RTLD_NOLOAD | RTLD_LAZY) : NULL;
|
||||
if (fastpath) {
|
||||
next_fstatat = (int (*)(int, const char *, bl_stat *, int))dlsym(fastpath, BL_FSTATAT_NAME);
|
||||
next_fstatat = (int (*)(int, const char *, dd_stat *, int))dlsym(fastpath, DD_FSTATAT_NAME);
|
||||
next_openat = (int (*)(int, const char *, int, ...))dlsym(fastpath, "openat");
|
||||
next_readlinkat = (ssize_t (*)(int, const char *, char *, size_t))dlsym(fastpath, "readlinkat");
|
||||
next_statx = (int (*)(int, const char *, int, unsigned int, struct statx *))dlsym(fastpath, "statx");
|
||||
}
|
||||
}
|
||||
|
||||
static long path_stat(int dirfd, const char *path, bl_stat *st, int flags) {
|
||||
static long path_stat(int dirfd, const char *path, dd_stat *st, int flags) {
|
||||
if (!next_fstatat) {
|
||||
return real_syscall(BL_SYS_FSTATAT, (long)dirfd, (long)path, (long)st, (long)flags);
|
||||
return real_syscall(DD_SYS_FSTATAT, (long)dirfd, (long)path, (long)st, (long)flags);
|
||||
}
|
||||
return next_fstatat(dirfd, path, st, flags);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ void *dlopen(const char *filename, int flags) {
|
||||
return real_dlopen(filename, flags);
|
||||
}
|
||||
|
||||
int bl_fsync_syscall(long number, const long *args, long *ret) __attribute__((visibility("hidden")));
|
||||
int dd_fsync_syscall(long number, const long *args, long *ret) __attribute__((visibility("hidden")));
|
||||
|
||||
static struct robust_list_head *thread_robust_head(void) {
|
||||
pthread_mutexattr_t attr;
|
||||
@@ -159,10 +159,10 @@ static int is_magic_link(int dirfd, char *link, size_t parent_len) {
|
||||
}
|
||||
char saved = link[parent_len];
|
||||
link[parent_len] = 0;
|
||||
bl_stat parent;
|
||||
dd_stat parent;
|
||||
long result = path_stat(dirfd, (parent_len ? link : "."), &parent, 0);
|
||||
link[parent_len] = saved;
|
||||
return result != 0 || parent.st_ino != BL_PROC_ROOT_INO;
|
||||
return result != 0 || parent.st_ino != DD_PROC_ROOT_INO;
|
||||
}
|
||||
|
||||
static long openat_in_root(int dirfd, const char *path, int flags, long mode) {
|
||||
@@ -217,16 +217,16 @@ static long openat_in_root(int dirfd, const char *path, int flags, long mode) {
|
||||
}
|
||||
memcpy(resolved + resolved_len + separator, name, len);
|
||||
resolved[candidate_len] = 0;
|
||||
bl_stat st;
|
||||
dd_stat st;
|
||||
int follow = !last || trailing_slash || !nofollow;
|
||||
long stat_result = follow ? path_stat(dirfd, resolved, &st, AT_SYMLINK_NOFOLLOW) : -1;
|
||||
if (stat_result == 0 && S_ISLNK(st.st_mode)) {
|
||||
if (++symlinks > BL_MAX_SYMLINKS) {
|
||||
if (++symlinks > DD_MAX_SYMLINKS) {
|
||||
errno = ELOOP;
|
||||
return -1;
|
||||
}
|
||||
if (!have_root) {
|
||||
bl_stat root;
|
||||
dd_stat root;
|
||||
struct statfs root_fs;
|
||||
if (path_stat(dirfd, ".", &root, 0) != 0) {
|
||||
return -1;
|
||||
@@ -265,7 +265,7 @@ static long openat_in_root(int dirfd, const char *path, int flags, long mode) {
|
||||
while (*inside == '/') {
|
||||
inside++;
|
||||
}
|
||||
bl_stat probe;
|
||||
dd_stat probe;
|
||||
int host = *inside && path_stat(dirfd, inside, &probe, AT_SYMLINK_NOFOLLOW) != 0 &&
|
||||
errno == ENOENT && path_stat(AT_FDCWD, pending, &probe, 0) == 0;
|
||||
pending[target_len] = saved;
|
||||
@@ -302,22 +302,22 @@ static long openat_in_root(int dirfd, const char *path, int flags, long mode) {
|
||||
|
||||
static long openat2_via_openat(const long *args) {
|
||||
const char *path = (const char *)args[1];
|
||||
const struct bl_open_how *how = (const struct bl_open_how *)args[2];
|
||||
const struct dd_open_how *how = (const struct dd_open_how *)args[2];
|
||||
if (!path || !how || (size_t)args[3] < sizeof(*how)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ((how->resolve & BL_RESOLVE_IN_ROOT) && (int)args[0] != AT_FDCWD) {
|
||||
if ((how->resolve & DD_RESOLVE_IN_ROOT) && (int)args[0] != AT_FDCWD) {
|
||||
return openat_in_root((int)args[0], path, (int)how->flags, (long)how->mode);
|
||||
}
|
||||
if (how->resolve & BL_RESOLVE_IN_ROOT) {
|
||||
if (how->resolve & DD_RESOLVE_IN_ROOT) {
|
||||
while (*path == '/') {
|
||||
path++;
|
||||
}
|
||||
if (!*path) {
|
||||
path = ".";
|
||||
}
|
||||
} else if ((how->resolve & BL_RESOLVE_BENEATH) && *path == '/') {
|
||||
} else if ((how->resolve & DD_RESOLVE_BENEATH) && *path == '/') {
|
||||
errno = EXDEV;
|
||||
return -1;
|
||||
}
|
||||
@@ -346,14 +346,14 @@ static long openat2_call(const long *args) {
|
||||
return openat2_via_openat(args);
|
||||
}
|
||||
|
||||
int bl_openat2(int dirfd, const char *path, void *how, size_t size) __asm__("openat2");
|
||||
int bl_openat2(int dirfd, const char *path, void *how, size_t size) {
|
||||
int dd_openat2(int dirfd, const char *path, void *how, size_t size) __asm__("openat2");
|
||||
int dd_openat2(int dirfd, const char *path, void *how, size_t size) {
|
||||
long args[6] = {dirfd, (long)path, (long)how, (long)size, 0, 0};
|
||||
return (int)openat2_call(args);
|
||||
}
|
||||
|
||||
int bl_writewatch_syscall(long number, const long *args, long (*real)(long, ...), long *rc) __attribute__((visibility("hidden")));
|
||||
int bl_clock_syscall(long number, const long *args, long (*real)(long, ...), long *ret) __attribute__((visibility("hidden")));
|
||||
int dd_writewatch_syscall(long number, const long *args, long (*real)(long, ...), long *rc) __attribute__((visibility("hidden")));
|
||||
int dd_clock_syscall(long number, const long *args, long (*real)(long, ...), long *ret) __attribute__((visibility("hidden")));
|
||||
|
||||
long syscall(long number, ...) {
|
||||
va_list ap;
|
||||
@@ -374,16 +374,16 @@ long syscall(long number, ...) {
|
||||
return 0;
|
||||
}
|
||||
long handled;
|
||||
if (bl_fsync_syscall(number, args, &handled)) {
|
||||
if (dd_fsync_syscall(number, args, &handled)) {
|
||||
return handled;
|
||||
}
|
||||
if (!real_syscall) {
|
||||
real_syscall = (long (*)(long, ...)) dlsym(RTLD_NEXT, "syscall");
|
||||
}
|
||||
if (bl_clock_syscall(number, args, real_syscall, &handled)) {
|
||||
if (dd_clock_syscall(number, args, real_syscall, &handled)) {
|
||||
return handled;
|
||||
}
|
||||
if (bl_writewatch_syscall(number, args, real_syscall, &handled)) {
|
||||
if (dd_writewatch_syscall(number, args, real_syscall, &handled)) {
|
||||
return handled;
|
||||
}
|
||||
if (number == SYS_openat2) {
|
||||
@@ -392,8 +392,8 @@ long syscall(long number, ...) {
|
||||
if (number == SYS_openat) {
|
||||
return path_open((int)args[0], (const char *)args[1], (int)args[2], args[3]);
|
||||
}
|
||||
if (number == BL_SYS_FSTATAT) {
|
||||
return path_stat((int)args[0], (const char *)args[1], (bl_stat *)args[2], (int)args[3]);
|
||||
if (number == DD_SYS_FSTATAT) {
|
||||
return path_stat((int)args[0], (const char *)args[1], (dd_stat *)args[2], (int)args[3]);
|
||||
}
|
||||
if (number == SYS_readlinkat) {
|
||||
return path_readlink((int)args[0], (const char *)args[1], (char *)args[2], (size_t)args[3]);
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "../../../app/src/main/cpp/venc/venc_proto.h"
|
||||
|
||||
int bl_venc_streaming(void) __attribute__((visibility("hidden")));
|
||||
int bl_venc_connect(void) __attribute__((visibility("hidden")));
|
||||
int dd_venc_streaming(void) __attribute__((visibility("hidden")));
|
||||
int dd_venc_connect(void) __attribute__((visibility("hidden")));
|
||||
|
||||
static pthread_mutex_t rt_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int rt_fd = -1, rt_down, rt_x, rt_y, rt_screen;
|
||||
@@ -18,10 +18,10 @@ static int rt_fd = -1, rt_down, rt_x, rt_y, rt_screen;
|
||||
static int rt_enabled(void) {
|
||||
static int enabled = -1;
|
||||
if (enabled < 0) {
|
||||
const char *v = getenv("BL_REMOTE_TOUCH");
|
||||
const char *v = getenv("DD_REMOTE_TOUCH");
|
||||
enabled = v == NULL || strcmp(v, "0") != 0;
|
||||
}
|
||||
return enabled && bl_venc_streaming();
|
||||
return enabled && dd_venc_streaming();
|
||||
}
|
||||
|
||||
static uint32_t rt_fraction(int value, int extent) {
|
||||
@@ -40,7 +40,7 @@ static void rt_send(void *dpy, uint32_t action) {
|
||||
.x = rt_fraction(rt_x, width(dpy, rt_screen)), .y = rt_fraction(rt_y, height(dpy, rt_screen)),
|
||||
};
|
||||
for (int attempt = 0; attempt < 2; attempt++) {
|
||||
if (rt_fd < 0) rt_fd = bl_venc_connect();
|
||||
if (rt_fd < 0) rt_fd = dd_venc_connect();
|
||||
if (rt_fd < 0) return;
|
||||
if (send(rt_fd, &m, sizeof m, MSG_NOSIGNAL) == (ssize_t)sizeof m) return;
|
||||
close(rt_fd);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
static const char *content_of(const char *path, char *buf, size_t len) {
|
||||
const char *roots = getenv("BL_LIBRARY_SPACE");
|
||||
const char *roots = getenv("DD_LIBRARY_SPACE");
|
||||
if (!path || !roots || !*roots)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
static int (*next_fstat)(int, struct stat *);
|
||||
void bl_storage_owner(int fd, struct stat *st) __attribute__((visibility("hidden")));
|
||||
void dd_storage_owner(int fd, struct stat *st) __attribute__((visibility("hidden")));
|
||||
static int (*next_fallocate)(int, int, off_t, off_t);
|
||||
static int (*next_posix_fallocate)(int, off_t, off_t);
|
||||
static ssize_t (*next_pwrite)(int, const void *, size_t, off_t);
|
||||
@@ -59,8 +59,8 @@ static void initialize(void) {
|
||||
while (__atomic_load_n(&init_state, __ATOMIC_ACQUIRE) != 2) { }
|
||||
return;
|
||||
}
|
||||
const char *on = getenv("BL_STORAGE_DIAGNOSTICS");
|
||||
const char *device = getenv("BL_STORAGE_DEVICE");
|
||||
const char *on = getenv("DD_STORAGE_DIAGNOSTICS");
|
||||
const char *device = getenv("DD_STORAGE_DEVICE");
|
||||
if (on != NULL && strcmp(on, "1") == 0 && device != NULL && *device != '\0') {
|
||||
char *end = NULL;
|
||||
errno = 0;
|
||||
@@ -105,7 +105,7 @@ static void comm_name(char *out, size_t size) {
|
||||
}
|
||||
|
||||
static void append_line(const char *line, size_t length) {
|
||||
const char *path = getenv("BL_STORAGE_LOG");
|
||||
const char *path = getenv("DD_STORAGE_LOG");
|
||||
struct stat st;
|
||||
int saved = errno;
|
||||
if (path == NULL || *path == '\0' || length == 0 || length > 2048) goto done;
|
||||
@@ -288,7 +288,7 @@ int fstat(int fd, struct stat *out) {
|
||||
errno = entry_errno;
|
||||
if (!enabled) {
|
||||
int result = next_fstat(fd, out);
|
||||
if (result == 0) bl_storage_owner(fd, out);
|
||||
if (result == 0) dd_storage_owner(fd, out);
|
||||
return result;
|
||||
}
|
||||
uint64_t start = now_ns();
|
||||
@@ -296,7 +296,7 @@ int fstat(int fd, struct stat *out) {
|
||||
int result = next_fstat(fd, out);
|
||||
int call_errno = errno;
|
||||
uint64_t elapsed = now_ns() - start;
|
||||
if (result == 0) bl_storage_owner(fd, out);
|
||||
if (result == 0) dd_storage_owner(fd, out);
|
||||
if (result == 0 && on_selected_device(fd, out)) {
|
||||
add(&stats.fstat_calls, 1);
|
||||
add(&stats.fstat_elapsed_ns, elapsed);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* tools/linuxfs/preload/subreaper.c
|
||||
*
|
||||
* Mark every process that loads libblsession.so as a child subreaper.
|
||||
* Mark every process that loads libddsession.so as a child subreaper.
|
||||
*
|
||||
* wlroots starts Xwayland with a double fork: gamescope -> middle process
|
||||
* (exits immediately) -> Xwayland. With no subreaper in the tree, Xwayland
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <sys/prctl.h>
|
||||
|
||||
__attribute__((constructor))
|
||||
static void bl_session_set_subreaper(void)
|
||||
static void dd_session_set_subreaper(void)
|
||||
{
|
||||
(void)prctl(PR_SET_CHILD_SUBREAPER, 1);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ static char g_dir[PATH_MAX - NAME_MAX - 2];
|
||||
|
||||
static const char *object_dir(void) {
|
||||
if (!g_dir[0]) {
|
||||
const char *d = getenv("BL_SYSV_DIR");
|
||||
const char *d = getenv("DD_SYSV_DIR");
|
||||
snprintf(g_dir, sizeof(g_dir), "%s", d && *d ? d : DIR_DEFAULT);
|
||||
mkdir(g_dir, 0700);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#define STATUS_MAX 16384
|
||||
#define TRACER_FIELD "\nTracerPid:\t"
|
||||
|
||||
int bl_from_ntdll(const void *caller) __attribute__((visibility("hidden")));
|
||||
int dd_from_ntdll(const void *caller) __attribute__((visibility("hidden")));
|
||||
|
||||
static const char *skip_digits(const char *s) {
|
||||
const char *end = s;
|
||||
@@ -41,7 +41,7 @@ static int is_web_helper(const void *caller) {
|
||||
if (strcmp(program_invocation_short_name, "steamwebhelper") != 0 &&
|
||||
strcmp(program_invocation_short_name, "vrwebhelper") != 0)
|
||||
return 0;
|
||||
const char *hide = getenv("BL_WEBHELPER_HIDE_TRACER");
|
||||
const char *hide = getenv("DD_WEBHELPER_HIDE_TRACER");
|
||||
Dl_info info;
|
||||
if (hide && hide[0] == '1' && caller && dladdr(caller, &info) && info.dli_fname
|
||||
&& strstr(info.dli_fname, "libtier0_s.so"))
|
||||
@@ -72,14 +72,14 @@ static int read_only_copy(const char *data, size_t len, int flags) {
|
||||
return ro;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_status_without_tracer(const char *path, int flags, const void *caller) {
|
||||
__attribute__((visibility("hidden"))) int dd_status_without_tracer(const char *path, int flags, const void *caller) {
|
||||
char text[STATUS_MAX];
|
||||
size_t len = 0;
|
||||
int saved = errno;
|
||||
int out = -1;
|
||||
|
||||
long pid;
|
||||
if ((flags & O_ACCMODE) != O_RDONLY || (pid = status_pid(path)) < 0 || is_web_helper(caller) || bl_from_ntdll(caller))
|
||||
if ((flags & O_ACCMODE) != O_RDONLY || (pid = status_pid(path)) < 0 || is_web_helper(caller) || dd_from_ntdll(caller))
|
||||
return -1;
|
||||
// through the next open(): the native userland's hook gives the app's ids as root's there
|
||||
static int (*next_open)(const char *, int, ...) = NULL;
|
||||
|
||||
@@ -102,17 +102,17 @@ static int make_stand_in(int type) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_nl_socket(int type, int *fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_owns(int fd);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getsockname(int fd, struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_socket(int type, int *fd);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_owns(int fd);
|
||||
__attribute__((visibility("hidden"))) int dd_nl_getsockname(int fd, struct sockaddr *addr,
|
||||
socklen_t *len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getpeername(int fd, struct sockaddr *addr,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_getpeername(int fd, struct sockaddr *addr,
|
||||
socklen_t *len, int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_setsockopt(int fd, int level, int option,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_setsockopt(int fd, int level, int option,
|
||||
const void *value, socklen_t len,
|
||||
int (*real)(int, int, int, const void *, socklen_t),
|
||||
int *rc);
|
||||
__attribute__((visibility("hidden"))) int bl_nl_getsockopt(int fd, int level, int option,
|
||||
__attribute__((visibility("hidden"))) int dd_nl_getsockopt(int fd, int level, int option,
|
||||
void *value, socklen_t *len,
|
||||
int (*real)(int, int, int, void *, socklen_t *),
|
||||
int *rc);
|
||||
@@ -128,7 +128,7 @@ int socket(int domain, int type, int protocol) {
|
||||
}
|
||||
if (domain == AF_NETLINK && protocol == NETLINK_ROUTE) {
|
||||
int route_fd;
|
||||
bl_nl_socket(type, &route_fd);
|
||||
dd_nl_socket(type, &route_fd);
|
||||
return route_fd;
|
||||
}
|
||||
fd = real_socket(domain, type, protocol);
|
||||
@@ -142,7 +142,7 @@ int socket(int domain, int type, int protocol) {
|
||||
return make_stand_in(type);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_udevmon_stand_in(int fd) {
|
||||
__attribute__((visibility("hidden"))) int dd_udevmon_stand_in(int fd) {
|
||||
return is_stand_in(fd);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ int getsockname(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
struct sockaddr_nl nl;
|
||||
int route_rc;
|
||||
|
||||
if (bl_nl_getsockname(fd, addr, len, &route_rc)) return route_rc;
|
||||
if (dd_nl_getsockname(fd, addr, len, &route_rc)) return route_rc;
|
||||
if (is_stand_in(fd)) {
|
||||
if (addr == NULL || len == NULL) {
|
||||
errno = EFAULT;
|
||||
@@ -175,7 +175,7 @@ int getsockname(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
int getpeername(int fd, struct sockaddr *addr, socklen_t *len) {
|
||||
static int (*real)(int, struct sockaddr *, socklen_t *);
|
||||
int route_rc;
|
||||
if (bl_nl_getpeername(fd, addr, len, &route_rc)) return route_rc;
|
||||
if (dd_nl_getpeername(fd, addr, len, &route_rc)) return route_rc;
|
||||
if (real == NULL) real = dlsym(RTLD_NEXT, "getpeername");
|
||||
return real(fd, addr, len);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ int setsockopt(int fd, int level, int optname, const void *optval, socklen_t opt
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
if (bl_nl_setsockopt(fd, level, optname, optval, optlen, real_setsockopt, &route_rc)) return route_rc;
|
||||
if (dd_nl_setsockopt(fd, level, optname, optval, optlen, real_setsockopt, &route_rc)) return route_rc;
|
||||
if (is_stand_in(fd)) {
|
||||
if (level == SOL_NETLINK)
|
||||
return 0;
|
||||
@@ -207,7 +207,7 @@ int getsockopt(int fd, int level, int option, void *value, socklen_t *len) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
if (bl_nl_getsockopt(fd, level, option, value, len, real, &route_rc)) return route_rc;
|
||||
if (dd_nl_getsockopt(fd, level, option, value, len, real, &route_rc)) return route_rc;
|
||||
return real(fd, level, option, value, len);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ static unsigned murmur_hash2(const char *key, size_t len) {
|
||||
return h;
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) int bl_udevmon_inject(const char *action, const char *devpath,
|
||||
__attribute__((visibility("default"))) int dd_udevmon_inject(const char *action, const char *devpath,
|
||||
const char *subsystem, const char *devname,
|
||||
unsigned major, unsigned minor) {
|
||||
static unsigned long long seqnum = 900000;
|
||||
@@ -280,7 +280,7 @@ __attribute__((visibility("default"))) int bl_udevmon_inject(const char *action,
|
||||
return sent;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_udevmon_recvmsg(int fd, struct msghdr *msg, int flags,
|
||||
__attribute__((visibility("hidden"))) int dd_udevmon_recvmsg(int fd, struct msghdr *msg, int flags,
|
||||
ssize_t (*real_recvmsg)(int, struct msghdr *, int),
|
||||
ssize_t *result) {
|
||||
if (!is_stand_in(fd)) return 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ static int find_ntdll(struct dl_phdr_info *info, size_t size, void *data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_from_ntdll(const void *caller) {
|
||||
__attribute__((visibility("hidden"))) int dd_from_ntdll(const void *caller) {
|
||||
uintptr_t pc = (uintptr_t)caller, lo = __atomic_load_n(&ntdll_lo, __ATOMIC_ACQUIRE);
|
||||
if (!lo) {
|
||||
dl_iterate_phdr(find_ntdll, NULL);
|
||||
@@ -42,53 +42,53 @@ __attribute__((visibility("hidden"))) int bl_from_ntdll(const void *caller) {
|
||||
#include <asm/hwcap.h>
|
||||
#include <asm/sigcontext.h>
|
||||
|
||||
#define BL_STR2(x) #x
|
||||
#define BL_STR(x) BL_STR2(x)
|
||||
#define DD_STR2(x) #x
|
||||
#define DD_STR(x) DD_STR2(x)
|
||||
|
||||
#define BL_HWCAP_GCS (1UL << 32)
|
||||
#define BL_FRAME_SIZE 4688
|
||||
#define BL_REGS 312
|
||||
#define BL_SP 560
|
||||
#define BL_PC 568
|
||||
#define BL_PSTATE 576
|
||||
#define BL_FPSIMD 592
|
||||
#define DD_HWCAP_GCS (1UL << 32)
|
||||
#define DD_FRAME_SIZE 4688
|
||||
#define DD_REGS 312
|
||||
#define DD_SP 560
|
||||
#define DD_PC 568
|
||||
#define DD_PSTATE 576
|
||||
#define DD_FPSIMD 592
|
||||
|
||||
struct bl_sigframe {
|
||||
struct dd_sigframe {
|
||||
siginfo_t info;
|
||||
ucontext_t uc;
|
||||
};
|
||||
|
||||
struct bl_kernel_sigaction {
|
||||
struct dd_kernel_sigaction {
|
||||
void (*handler)(int, siginfo_t *, void *);
|
||||
unsigned long flags;
|
||||
void *restorer;
|
||||
uint64_t mask;
|
||||
};
|
||||
|
||||
struct bl_usr2_call {
|
||||
struct dd_usr2_call {
|
||||
void (*handler)(int, siginfo_t *, void *);
|
||||
uint64_t old_mask;
|
||||
};
|
||||
|
||||
_Static_assert(sizeof(struct bl_sigframe) == BL_FRAME_SIZE, "rt_sigframe size");
|
||||
_Static_assert(offsetof(struct bl_sigframe, uc.uc_mcontext.regs) == BL_REGS, "regs offset");
|
||||
_Static_assert(offsetof(struct bl_sigframe, uc.uc_mcontext.sp) == BL_SP, "sp offset");
|
||||
_Static_assert(offsetof(struct bl_sigframe, uc.uc_mcontext.pc) == BL_PC, "pc offset");
|
||||
_Static_assert(offsetof(struct bl_sigframe, uc.uc_mcontext.pstate) == BL_PSTATE, "pstate offset");
|
||||
_Static_assert(offsetof(struct bl_sigframe, uc.uc_mcontext.__reserved) == BL_FPSIMD, "reserved offset");
|
||||
_Static_assert(sizeof(struct dd_sigframe) == DD_FRAME_SIZE, "rt_sigframe size");
|
||||
_Static_assert(offsetof(struct dd_sigframe, uc.uc_mcontext.regs) == DD_REGS, "regs offset");
|
||||
_Static_assert(offsetof(struct dd_sigframe, uc.uc_mcontext.sp) == DD_SP, "sp offset");
|
||||
_Static_assert(offsetof(struct dd_sigframe, uc.uc_mcontext.pc) == DD_PC, "pc offset");
|
||||
_Static_assert(offsetof(struct dd_sigframe, uc.uc_mcontext.pstate) == DD_PSTATE, "pstate offset");
|
||||
_Static_assert(offsetof(struct dd_sigframe, uc.uc_mcontext.__reserved) == DD_FPSIMD, "reserved offset");
|
||||
_Static_assert(sizeof(struct fpsimd_context) + sizeof(struct _aarch64_ctx) <=
|
||||
sizeof(((mcontext_t *)0)->__reserved), "reserved space");
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_usr2_frame(struct bl_usr2_call *call);
|
||||
__attribute__((visibility("hidden"), used)) void bl_usr2_run(struct bl_usr2_call *call, struct bl_sigframe *frame);
|
||||
__attribute__((visibility("hidden"))) void dd_usr2_frame(struct dd_usr2_call *call);
|
||||
__attribute__((visibility("hidden"), used)) void dd_usr2_run(struct dd_usr2_call *call, struct dd_sigframe *frame);
|
||||
|
||||
__asm__(".text\n"
|
||||
".p2align 2\n"
|
||||
".type bl_usr2_frame, %function\n"
|
||||
"bl_usr2_frame:\n"
|
||||
" mov x16, #" BL_STR(BL_FRAME_SIZE) "\n"
|
||||
".type dd_usr2_frame, %function\n"
|
||||
"dd_usr2_frame:\n"
|
||||
" mov x16, #" DD_STR(DD_FRAME_SIZE) "\n"
|
||||
" sub sp, sp, x16\n"
|
||||
" add x17, sp, #" BL_STR(BL_REGS) "\n"
|
||||
" add x17, sp, #" DD_STR(DD_REGS) "\n"
|
||||
" stp x0, x1, [x17, #0]\n"
|
||||
" stp x2, x3, [x17, #16]\n"
|
||||
" stp x4, x5, [x17, #32]\n"
|
||||
@@ -107,12 +107,12 @@ __asm__(".text\n"
|
||||
" str x30, [x17, #240]\n"
|
||||
" str xzr, [x17, #0]\n"
|
||||
" add x16, sp, x16\n"
|
||||
" str x16, [sp, #" BL_STR(BL_SP) "]\n"
|
||||
" str x16, [sp, #" DD_STR(DD_SP) "]\n"
|
||||
" adr x16, 1f\n"
|
||||
" str x16, [sp, #" BL_STR(BL_PC) "]\n"
|
||||
" str x16, [sp, #" DD_STR(DD_PC) "]\n"
|
||||
" mrs x16, nzcv\n"
|
||||
" str x16, [sp, #" BL_STR(BL_PSTATE) "]\n"
|
||||
" add x17, sp, #" BL_STR(BL_FPSIMD) "\n"
|
||||
" str x16, [sp, #" DD_STR(DD_PSTATE) "]\n"
|
||||
" add x17, sp, #" DD_STR(DD_FPSIMD) "\n"
|
||||
" mrs x16, fpsr\n"
|
||||
" str w16, [x17, #8]\n"
|
||||
" mrs x16, fpcr\n"
|
||||
@@ -134,13 +134,13 @@ __asm__(".text\n"
|
||||
" stp q28, q29, [x17, #464]\n"
|
||||
" stp q30, q31, [x17, #496]\n"
|
||||
" mov x1, sp\n"
|
||||
" bl bl_usr2_run\n"
|
||||
" mov x8, #" BL_STR(__NR_rt_sigreturn) "\n"
|
||||
" bl dd_usr2_run\n"
|
||||
" mov x8, #" DD_STR(__NR_rt_sigreturn) "\n"
|
||||
" svc #0\n"
|
||||
" brk #0\n"
|
||||
"1:\n"
|
||||
" ret\n"
|
||||
".size bl_usr2_frame, .-bl_usr2_frame\n");
|
||||
".size dd_usr2_frame, .-dd_usr2_frame\n");
|
||||
|
||||
static int (*usr2_real_raise)(int);
|
||||
|
||||
@@ -160,7 +160,7 @@ static uint64_t usr2_ssbs(void) {
|
||||
return value & (1UL << 12);
|
||||
}
|
||||
|
||||
void bl_usr2_run(struct bl_usr2_call *call, struct bl_sigframe *frame) {
|
||||
void dd_usr2_run(struct dd_usr2_call *call, struct dd_sigframe *frame) {
|
||||
struct fpsimd_context *fp = (struct fpsimd_context *)frame->uc.uc_mcontext.__reserved;
|
||||
struct _aarch64_ctx *end = (struct _aarch64_ctx *)(fp + 1);
|
||||
|
||||
@@ -192,11 +192,11 @@ int raise(int sig) {
|
||||
real = (int (*)(int))dlsym(RTLD_NEXT, "raise");
|
||||
__atomic_store_n(&usr2_real_raise, real, __ATOMIC_RELEASE);
|
||||
}
|
||||
if (sig != SIGUSR2 || (getauxval(AT_HWCAP) & BL_HWCAP_GCS) || !bl_from_ntdll(__builtin_return_address(0))) {
|
||||
if (sig != SIGUSR2 || (getauxval(AT_HWCAP) & DD_HWCAP_GCS) || !dd_from_ntdll(__builtin_return_address(0))) {
|
||||
return real(sig);
|
||||
}
|
||||
|
||||
struct bl_kernel_sigaction action;
|
||||
struct dd_kernel_sigaction action;
|
||||
if (usr2_sys(__NR_rt_sigaction, SIGUSR2, 0, (long)&action, sizeof(action.mask)) != 0) return real(sig);
|
||||
if (!(action.flags & SA_SIGINFO) || (action.flags & SA_RESETHAND) || (uintptr_t)action.handler <= 1) {
|
||||
return real(sig);
|
||||
@@ -204,7 +204,7 @@ int raise(int sig) {
|
||||
|
||||
uint64_t bit = 1ULL << (SIGUSR2 - 1);
|
||||
uint64_t block = action.mask | ((action.flags & SA_NODEFER) ? 0 : bit);
|
||||
struct bl_usr2_call call = {action.handler, 0};
|
||||
struct dd_usr2_call call = {action.handler, 0};
|
||||
if (usr2_sys(__NR_rt_sigprocmask, SIG_BLOCK, (long)&block, (long)&call.old_mask, sizeof(block)) != 0) {
|
||||
return real(sig);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ int raise(int sig) {
|
||||
usr2_sys(__NR_rt_sigprocmask, SIG_SETMASK, (long)&call.old_mask, 0, sizeof(call.old_mask));
|
||||
return real(sig);
|
||||
}
|
||||
bl_usr2_frame(&call);
|
||||
dd_usr2_frame(&call);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <poll.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__aarch64__) || defined(BL_VDEC_ANY_ARCH)
|
||||
#if defined(__aarch64__) || defined(DD_VDEC_ANY_ARCH)
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <linux/videodev2.h>
|
||||
@@ -220,12 +220,12 @@ static int vd_have_ffmpeg(void) {
|
||||
return vd_ffmpeg > 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_venc_connect(void);
|
||||
__attribute__((visibility("hidden"))) int dd_venc_connect(void);
|
||||
|
||||
static int vd_enabled(void) {
|
||||
pthread_mutex_lock(&vd_lock);
|
||||
if (vd_state == 0) {
|
||||
const char *flag = getenv("BL_REMOTE_PLAY_DECODE"), *socket = getenv("BL_VENC_SOCKET");
|
||||
const char *flag = getenv("DD_REMOTE_PLAY_DECODE"), *socket = getenv("DD_VENC_SOCKET");
|
||||
vd_state = -1;
|
||||
if (strcmp(program_invocation_short_name, "streaming_client") == 0 && (flag == NULL || strcmp(flag, "0") != 0)) {
|
||||
vd_heap = open("/dev/dma_heap/system", O_RDONLY | O_CLOEXEC);
|
||||
@@ -245,7 +245,7 @@ static struct vdec *vd_find(int fd) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_vdec_open(const char *path, int flags) {
|
||||
__attribute__((visibility("hidden"))) int dd_vdec_open(const char *path, int flags) {
|
||||
(void)flags;
|
||||
if (path == NULL || strcmp(path, VDEC_DEVICE) != 0 || !vd_enabled()) return -2;
|
||||
int fd = memfd_create("droiddeck-vdec", 0);
|
||||
@@ -314,7 +314,7 @@ static void vd_send_capture(struct vdec *v, uint32_t index) {
|
||||
|
||||
static int vd_open_hardware(struct vdec *v) {
|
||||
if (v->hw_failed) return -1;
|
||||
int sock = bl_venc_connect();
|
||||
int sock = dd_venc_connect();
|
||||
if (sock < 0) return -1;
|
||||
struct vdec_config c = {
|
||||
.type = VDEC_CONFIG, .codec = v->fourcc == V4L2_PIX_FMT_HEVC ? VENC_HEVC : VENC_H264,
|
||||
@@ -740,7 +740,7 @@ static int vd_ioctl(struct vdec *v, unsigned long req, void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_vdec_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
__attribute__((visibility("hidden"))) int dd_vdec_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
struct vdec *v = vd_find(fd);
|
||||
if (v == NULL) return 0;
|
||||
pthread_mutex_lock(&vd_lock);
|
||||
@@ -755,7 +755,7 @@ __attribute__((visibility("hidden"))) int bl_vdec_ioctl(int fd, unsigned long re
|
||||
return 1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_vdec_closed(int fd) {
|
||||
__attribute__((visibility("hidden"))) void dd_vdec_closed(int fd) {
|
||||
struct vdec *v = vd_find(fd);
|
||||
if (v == NULL) return;
|
||||
pthread_mutex_lock(&vd_lock);
|
||||
@@ -768,7 +768,7 @@ __attribute__((visibility("hidden"))) void bl_vdec_closed(int fd) {
|
||||
pthread_mutex_unlock(&vd_lock);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_vdec_poll(struct pollfd *fds, nfds_t n, int timeout_ms,
|
||||
__attribute__((visibility("hidden"))) int dd_vdec_poll(struct pollfd *fds, nfds_t n, int timeout_ms,
|
||||
int (*real)(struct pollfd *, nfds_t, int), int *ret) {
|
||||
if (n != 1 || vd_find(fds[0].fd) == NULL) return 0;
|
||||
struct vdec *v = vd_find(fds[0].fd);
|
||||
@@ -949,13 +949,13 @@ void SDL_UnloadObject(void *handle) {
|
||||
|
||||
#else
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_vdec_open(const char *path, int flags) {
|
||||
__attribute__((visibility("hidden"))) int dd_vdec_open(const char *path, int flags) {
|
||||
(void)path;
|
||||
(void)flags;
|
||||
return -2;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_vdec_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
__attribute__((visibility("hidden"))) int dd_vdec_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
(void)fd;
|
||||
(void)req;
|
||||
(void)arg;
|
||||
@@ -963,9 +963,9 @@ __attribute__((visibility("hidden"))) int bl_vdec_ioctl(int fd, unsigned long re
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_vdec_closed(int fd) { (void)fd; }
|
||||
__attribute__((visibility("hidden"))) void dd_vdec_closed(int fd) { (void)fd; }
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_vdec_poll(struct pollfd *fds, nfds_t n, int timeout_ms,
|
||||
__attribute__((visibility("hidden"))) int dd_vdec_poll(struct pollfd *fds, nfds_t n, int timeout_ms,
|
||||
int (*real)(struct pollfd *, nfds_t, int), int *ret) {
|
||||
(void)fds;
|
||||
(void)n;
|
||||
|
||||
@@ -115,14 +115,14 @@ static void vn_free_queue(struct vq *q) {
|
||||
memset(q, 0, sizeof *q);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_venc_streaming(void) {
|
||||
__attribute__((visibility("hidden"))) int dd_venc_streaming(void) {
|
||||
return __atomic_load_n(&vn_open_count, __ATOMIC_ACQUIRE) > 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_venc_connect(void);
|
||||
__attribute__((visibility("hidden"))) int dd_venc_connect(void);
|
||||
|
||||
int bl_venc_connect(void) {
|
||||
const char *path = getenv("BL_VENC_SOCKET");
|
||||
int dd_venc_connect(void) {
|
||||
const char *path = getenv("DD_VENC_SOCKET");
|
||||
if (path == NULL || *path == '\0') return -1;
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
if (strlen(path) >= sizeof addr.sun_path) return -1;
|
||||
@@ -138,10 +138,10 @@ int bl_venc_connect(void) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_venc_open(const char *path, int flags) {
|
||||
__attribute__((visibility("hidden"))) int dd_venc_open(const char *path, int flags) {
|
||||
(void)flags;
|
||||
if (path == NULL || strcmp(path, VENC_DEVICE) != 0) return -2;
|
||||
int fd = bl_venc_connect();
|
||||
int fd = dd_venc_connect();
|
||||
if (fd < 0) return -2;
|
||||
pthread_mutex_lock(&vn_lock);
|
||||
struct venc *v = NULL;
|
||||
@@ -546,7 +546,7 @@ static int vn_ioctl(struct venc *v, unsigned long req, void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_venc_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
__attribute__((visibility("hidden"))) int dd_venc_ioctl(int fd, unsigned long req, void *arg, int *rc) {
|
||||
struct venc *v = vn_find(fd);
|
||||
if (v == NULL) return 0;
|
||||
pthread_mutex_lock(&vn_lock);
|
||||
@@ -561,7 +561,7 @@ __attribute__((visibility("hidden"))) int bl_venc_ioctl(int fd, unsigned long re
|
||||
return 1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_venc_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off,
|
||||
__attribute__((visibility("hidden"))) int dd_venc_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off,
|
||||
void *(*real)(void *, size_t, int, int, int, off_t), void **out) {
|
||||
struct venc *v = vn_find(fd);
|
||||
if (v == NULL) return 0;
|
||||
@@ -579,7 +579,7 @@ __attribute__((visibility("hidden"))) int bl_venc_mmap(void *addr, size_t len, i
|
||||
return 1;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void bl_venc_closed(int fd) {
|
||||
__attribute__((visibility("hidden"))) void dd_venc_closed(int fd) {
|
||||
struct venc *v = vn_find(fd);
|
||||
if (v == NULL) return;
|
||||
pthread_mutex_lock(&vn_lock);
|
||||
@@ -623,14 +623,14 @@ static int vn_poll(struct pollfd *fds, nfds_t n, int timeout_ms, int (*real)(str
|
||||
return r + ready;
|
||||
}
|
||||
|
||||
__attribute__((weak, visibility("hidden"))) int bl_vdec_poll(struct pollfd *fds, nfds_t n, int timeout_ms,
|
||||
__attribute__((weak, visibility("hidden"))) int dd_vdec_poll(struct pollfd *fds, nfds_t n, int timeout_ms,
|
||||
int (*real)(struct pollfd *, nfds_t, int), int *ret);
|
||||
|
||||
int poll(struct pollfd *fds, nfds_t n, int timeout_ms) {
|
||||
static int (*real)(struct pollfd *, nfds_t, int);
|
||||
if (!real) real = (int (*)(struct pollfd *, nfds_t, int))dlsym(RTLD_NEXT, "poll");
|
||||
int ret;
|
||||
if (bl_vdec_poll && bl_vdec_poll(fds, n, timeout_ms, real, &ret)) return ret;
|
||||
if (dd_vdec_poll && dd_vdec_poll(fds, n, timeout_ms, real, &ret)) return ret;
|
||||
if (__atomic_load_n(&vn_open_count, __ATOMIC_ACQUIRE) == 0) return real(fds, n, timeout_ms);
|
||||
return vn_poll(fds, n, timeout_ms, real);
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
extern char **environ;
|
||||
|
||||
__attribute__((constructor)) static void bl_venus_keep_kopper(void) {
|
||||
__attribute__((constructor)) static void dd_venus_keep_kopper(void) {
|
||||
static const char name[] = "LIBGL_KOPPER_DISABLE=";
|
||||
const char *debug = getenv("VN_DEBUG");
|
||||
if (!debug || !strstr(debug, "vtest") || !environ) return;
|
||||
|
||||
@@ -57,10 +57,10 @@ static char *const *chromium_argv(const char *path, char *const argv[]) {
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
char *const *bl_webhelper_argv(const char *path, char *const argv[], char *const envp[]) {
|
||||
char *const *dd_webhelper_argv(const char *path, char *const argv[], char *const envp[]) {
|
||||
if (electron_node_mode(envp)) return argv;
|
||||
if (!is_webhelper_browser(path, argv)) return chromium_argv(path, argv);
|
||||
const char *spec = getenv("BL_WEBHELPER_ARGS");
|
||||
const char *spec = getenv("DD_WEBHELPER_ARGS");
|
||||
if (!spec || !*spec) spec = WEBHELPER_DEFAULT;
|
||||
if (!strcmp(spec, "stock")) return argv;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ static int ww_uffd = -1;
|
||||
static int scan_blocked;
|
||||
#endif
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_writewatch_syscall(long number, const long *args, long (*real)(long, ...), long *rc) {
|
||||
__attribute__((visibility("hidden"))) int dd_writewatch_syscall(long number, const long *args, long (*real)(long, ...), long *rc) {
|
||||
#if defined(__aarch64__) && defined(PAGEMAP_SCAN) && defined(UFFD_USER_MODE_ONLY)
|
||||
if (number != WINE_ARM64_USERFAULTFD || (args[0] & ~(long)(O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY))) return 0;
|
||||
*rc = real(SYS_userfaultfd, args[0]);
|
||||
@@ -89,7 +89,7 @@ done:
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((visibility("hidden"))) int bl_writewatch_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
__attribute__((visibility("hidden"))) int dd_writewatch_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
void *arg, int *rc) {
|
||||
#if defined(PAGEMAP_SCAN) && defined(UFFD_USER_MODE_ONLY)
|
||||
if (request != PAGEMAP_SCAN) return 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef Atom (*intern_atom_fn)(Display *, const char *, Bool);
|
||||
static int following(void) {
|
||||
static int cached = -1;
|
||||
if (cached < 0) {
|
||||
const char *v = getenv("BL_FOLLOW_OUTPUT");
|
||||
const char *v = getenv("DD_FOLLOW_OUTPUT");
|
||||
cached = v && v[0] == '1';
|
||||
}
|
||||
return cached;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#define MADV_PAGEOUT 21
|
||||
#endif
|
||||
#ifndef ZR_CTL
|
||||
#define ZR_CTL "/tmp/.bl-zram"
|
||||
#define ZR_CTL "/tmp/.dd-zram"
|
||||
#endif
|
||||
#define ZR_SWAPPED (1ULL << 62)
|
||||
#define ZR_BATCH 512
|
||||
|
||||
Reference in new issue
Block a user