*hash += *(value++);
}
-static bool fail_scandirat;
-int __real_scandirat(int dirfd, const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **));
-int __wrap_scandirat(int dirfd, const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **))
-{
- if (fail_scandirat)
- return -1;
-
- errno = 0;
- int r = __real_scandirat(dirfd, dirp, namelist, filter, compar);
-
- /* Workaround a build chain issue.
- * There seems to be a mismatch between how the emulator emulates this syscall
- * and how glibc expects it would. Fortunately, the symptoms are fairly unique
- * with the EOVERFLOW error not really being possible otherwise (the directory
- * we run this on has just two one-liner files). */
- if (errno == EOVERFLOW)
- exit(EXIT_SKIP); // that's game null and void
-
- return r;
-}
-int __wrap_scandirat64(int dirfd, const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **))
-{
- return __wrap_scandirat(dirfd, dirp, namelist, filter, compar);
+/* scandirat() is not the underlying syscall, it's just a libc wrapper for getdents.
+ * There's significant differences between getdents and getdents64 (unlike, for
+ * example open64, which just passes some flag we don't really care about) so we
+ * wouldn't be able to just redirect one to the other. Therefore the simplest
+ * way not to duplicate code is to just wrap both scandirat variantes the same way. */
+#define WRAP_SCANDIRAT(callname) \
+int __real_##callname(int dirfd, const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)); \
+int __wrap_##callname(int dirfd, const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)) { \
+ return fail_scandirat ? -1 : __real_##callname(dirfd, dirp, namelist, filter, compar); \
}
+static bool fail_scandirat;
+WRAP_SCANDIRAT(scandirat)
+WRAP_SCANDIRAT(scandirat64)
static bool fail_openat;
int __real_openat(int dirfd, const char *pathname, int flags, mode_t mode);