mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-12 03:22:48 +00:00
Fix random return value of faccessat() in x86
faccessat() should return 0 when success, but it returns random number with errno == 0 in x86 platform.
It’s a side effect of commit bf80b08b5f when magisk binaries ‘corretly’ linked with library of API16 .. lol
Co-authored-by: John Wu <topjohnwu@gmail.com>
This commit is contained in:
@@ -359,6 +359,20 @@ ssize_t xreadlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int xfaccessat(int dirfd, const char *pathname) {
|
||||
int ret = faccessat(dirfd, pathname, F_OK, 0);
|
||||
if (ret < 0) {
|
||||
PLOGE("faccessat %s", pathname);
|
||||
}
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (ret > 0 && errno == 0) {
|
||||
LOGD("faccessat success but ret is %d\n", ret);
|
||||
ret = 0;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xsymlink(const char *target, const char *linkpath) {
|
||||
int ret = symlink(target, linkpath);
|
||||
if (ret < 0) {
|
||||
|
||||
Reference in New Issue
Block a user