X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Foverride.c;h=5a722d932e0f65740b60f1a6e8da1abf8726915b;hp=a9d545b420e38133bea2a9bd2c6877fe0f5d58a6;hb=c3831532675b527bd34ee92377b1b6d323345cb1;hpb=b4f4cb40a6f3f4ecc05c7b6c8f2e852282234519 diff --git a/loader/override.c b/loader/override.c index a9d545b..5a722d9 100644 --- a/loader/override.c +++ b/loader/override.c @@ -268,7 +268,26 @@ static int w_chdir(const char *path) ret = 0; else ret = g_chdir_raw(path); - strace("chdir(%s) = %d\n", path, ret); + + strace("chdir(%s) = %ld\n", path, ret); + return g_syscall_error(ret); +} + +static ssize_t w_readlink(const char *path, char *buf, size_t bufsiz) +{ + long ret; + + if (path != NULL && strncmp(path, "/proc/", 6) == 0 + && strcmp(strrchr(path, '/'), "/exe") == 0) + { + ret = snprintf(buf, bufsiz, "%s", bin_path); + if (ret > bufsiz) + ret = bufsiz; + } + else + ret = g_readlink_raw(path, buf, bufsiz); + + strace("readlink(%s, %s, %zd) = %ld\n", path, buf, bufsiz, ret); return g_syscall_error(ret); } @@ -290,6 +309,7 @@ static int w_chdir(const char *path) #undef execvp #undef execve #undef chdir +#undef readlink #ifdef DL @@ -320,6 +340,7 @@ MAKE_WRAP_SYM_N(execv); MAKE_WRAP_SYM_N(execvp); MAKE_WRAP_SYM(execve); MAKE_WRAP_SYM_N(chdir); +MAKE_WRAP_SYM_N(readlink); typeof(mmap) mmap2 __attribute__((alias("w_mmap"))); #define REAL_FUNC_NP(name) \ @@ -446,6 +467,12 @@ int real_chdir(const char *path) return g_syscall_error(ret); } +ssize_t real_readlink(const char *path, char *buf, size_t bufsiz) +{ + long ret = g_readlink_raw(path, buf, bufsiz); + return g_syscall_error(ret); +} + void real_sleep(unsigned int seconds) { struct timespec ts = { seconds, 0 };