diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 4e615629..107eeb94 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1623,6 +1623,11 @@ void CreateCPUPresentFile(int fd) dummy = write(fd, buff, strlen(buff)); (void)dummy; } +void CreateClocksourceFile(int fd) +{ + size_t dummy; + write(fd, "tsc", strlen("tsc")); +} #ifdef ANDROID static int shm_open(const char *name, int oflag, mode_t mode) { @@ -1635,6 +1640,7 @@ static int shm_unlink(const char *name) { #define TMP_CPUINFO "box64_tmpcpuinfo" #define TMP_CPUTOPO "box64_tmpcputopo%d" +#define TMP_CLOCKSOURCE "box64_tmpclocksource" #endif #define TMP_MEMMAP "box64_tmpmemmap" #define TMP_CMDLINE "box64_tmpcmdline" @@ -1680,6 +1686,15 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo lseek(tmp, 0, SEEK_SET); return tmp; } + if(!strcmp((const char*)pathname, "/sys/bus/clocksource/devices/clocksource0/current_clocksource")) { + // special case to say tsc as current clocksource + int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); + if(tmp<0) return open(pathname, flags, mode); // error fallback + shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use + CreateClocksourceFile(tmp); + lseek(tmp, 0, SEEK_SET); + return tmp; + } #endif int ret = open(pathname, flags, mode); return ret; @@ -1801,6 +1816,15 @@ EXPORT FILE* my_fopen64(x64emu_t* emu, const char* path, const char* mode) lseek(tmp, 0, SEEK_SET); return fdopen(tmp, mode); } + if(strcmp(path, "/sys/bus/clocksource/devices/clocksource0/current_clocksource")==0) { + // special case for cpuinfo + int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); + if(tmp<0) return fopen64(path, mode); // error fallback + shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use + CreateClocksourceFile(tmp); + lseek(tmp, 0, SEEK_SET); + return fdopen(tmp, mode); + } #endif if(isProcSelf(path, "exe")) { return fopen64(emu->context->fullpath, mode); |