You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/sys-apps/fakechroot/files/fakechroot-2.9-glibc-2.10-c...

162 lines
6.3 KiB

Index: trunk/test/src/test-scandir.c
===================================================================
--- trunk/test/src/test-scandir.c (revision 0)
+++ trunk/test/src/test-scandir.c (revision 343)
@@ -0,0 +1,35 @@
+#define _SVID_SOURCE
+#include <dirent.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int main (int argc, char *argv[]) {
+ struct dirent **namelist;
+ int i, n;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s chdir scandir\n", argv[0]);
+ exit(2);
+ }
+
+ if (*argv[1] && chdir(argv[1]) == -1) {
+ perror("chdir");
+ exit(1);
+ }
+
+ n = scandir(argv[2], &namelist, 0, alphasort);
+ if (n < 0) {
+ perror("scandir");
+ exit(1);
+ }
+ else {
+ for (i=0; i<n; i++) {
+ printf("%s\n", namelist[i]->d_name);
+ free(namelist[i]);
+ }
+ free(namelist);
+ }
+
+ return 0;
+}
+
Index: trunk/test/src/Makefile.am
===================================================================
--- trunk/test/src/Makefile.am (revision 341)
+++ trunk/test/src/Makefile.am (revision 343)
@@ -1 +1 @@
-check_PROGRAMS = test-chroot
+check_PROGRAMS = test-chroot test-scandir
Index: trunk/m4/scandir_argtypes.m4
===================================================================
--- trunk/m4/scandir_argtypes.m4 (revision 341)
+++ trunk/m4/scandir_argtypes.m4 (revision 343)
@@ -12,7 +12,7 @@
for ac_arg1 in 'const char *dir'; do
for ac_arg2 in 'struct dirent ***namelist'; do
for ac_arg3 in 'int(*filter)(const struct dirent *)' 'int(*filter)(struct dirent *)'; do
- for ac_arg4 in 'int(*compar)(const void *,const void *)'; do
+ for ac_arg4 in 'int(*compar)(const void *,const void *)' 'int(*compar)(const struct dirent **, const struct dirent **)'; do
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT
Index: trunk/m4/scandir64_argtypes.m4
===================================================================
--- trunk/m4/scandir64_argtypes.m4 (revision 0)
+++ trunk/m4/scandir64_argtypes.m4 (revision 343)
@@ -0,0 +1,48 @@
+dnl AC_FUNC_SCANDIR64_ARGTYPES
+dnl -------------------------
+dnl Determine the correct type to be passed to each of the `scandir64'
+dnl function's arguments, and define those types in `SCANDIR64_TYPE_ARG1',
+dnl `SCANDIR64_TYPE_ARG2', `SCANDIR64_TYPE_ARG3' and `SCANDIR64_TYPE_ARG4'.
+AN_FUNCTION([scandir64], [AC_FUNC_SCANDIR64_ARGTYPES])
+AC_DEFUN([AC_FUNC_SCANDIR64_ARGTYPES],
+[AC_CHECK_HEADERS(dirent.h)
+AC_CACHE_CHECK([types of arguments for scandir64],
+[ac_cv_func_scandir64_args],
+[for ac_return in 'int'; do
+ for ac_arg1 in 'const char *dir'; do
+ for ac_arg2 in 'struct dirent64 ***namelist'; do
+ for ac_arg3 in 'int(*filter)(const struct dirent64 *)' 'int(*filter)(struct dirent64 *)'; do
+ for ac_arg4 in 'int(*compar)(const void *,const void *)' 'int(*compar)(const struct dirent64 **, const struct dirent64 **)'; do
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+[AC_INCLUDES_DEFAULT
+#ifdef HAVE_UNISTD_H
+#include <dirent.h>
+#endif
+],
+ [extern $ac_return scandir64 ($ac_arg1, $ac_arg2, $ac_arg3, $ac_arg4);])],
+ [ac_cv_func_scandir64_args="$ac_return;$ac_arg1;$ac_arg2;$ac_arg3;$ac_arg4"; break 5])
+ done
+ done
+ done
+ done
+done
+# Provide a safe default value.
+: ${ac_cv_func_scandir64_args='(default) int;const char *dir;struct dirent64 ***namelist;int(*filter)(const struct dirent64 *);int(*compar)(const void *,const void *)'}
+])
+ac_save_IFS=$IFS; IFS=';'
+set dummy `echo "$ac_cv_func_scandir64_args" | sed 's/^(default) //' | sed 's/\*/\*/g'`
+IFS=$ac_save_IFS
+shift
+AC_DEFINE_UNQUOTED(SCANDIR64_TYPE_RETURN, $[1],
+ [Define to the type of return value for `scandir64'.])
+AC_DEFINE_UNQUOTED(SCANDIR64_TYPE_ARG1, $[2],
+ [Define to the type of arg 1 for `scandir64'.])
+AC_DEFINE_UNQUOTED(SCANDIR64_TYPE_ARG2, $[3],
+ [Define to the type of arg 2 for `scandir64'.])
+AC_DEFINE_UNQUOTED(SCANDIR64_TYPE_ARG3, $[4],
+ [Define to the type of arg 3 for `scandir64'.])
+AC_DEFINE_UNQUOTED(SCANDIR64_TYPE_ARG4, $[5],
+ [Define to the type of arg 4 for `scandir64'.])
+rm -f conftest*
+])
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac (revision 341)
+++ trunk/configure.ac (revision 343)
@@ -177,6 +177,7 @@
AC_FUNC_READLINK_ARGTYPES
AC_FUNC_SCANDIR_ARGTYPES
+AC_FUNC_SCANDIR64_ARGTYPES
AC_CONFIG_FILES([ \
Makefile \
Index: trunk/src/libfakechroot.c
===================================================================
--- trunk/src/libfakechroot.c (revision 341)
+++ trunk/src/libfakechroot.c (revision 343)
@@ -512,10 +512,10 @@
#endif
static int (*next_rmdir) (const char *pathname) = NULL;
#ifdef HAVE_SCANDIR
-static int (*next_scandir) (const char *dir, struct dirent ***namelist, SCANDIR_TYPE_ARG3, int(*compar)(const void *, const void *)) = NULL;
+static int (*next_scandir) (SCANDIR_TYPE_ARG1, SCANDIR_TYPE_ARG2, SCANDIR_TYPE_ARG3, SCANDIR_TYPE_ARG4) = NULL;
#endif
#ifdef HAVE_SCANDIR64
-static int (*next_scandir64) (const char *dir, struct dirent64 ***namelist, int(*filter)(const struct dirent64 *), int(*compar)(const void *, const void *)) = NULL;
+static int (*next_scandir64) (SCANDIR64_TYPE_ARG1, SCANDIR64_TYPE_ARG2, SCANDIR64_TYPE_ARG3, SCANDIR64_TYPE_ARG4) = NULL;
#endif
#ifdef HAVE_SETXATTR
static int (*next_setxattr) (const char *path, const char *name, const void *value, size_t size, int flags) = NULL;
@@ -2664,7 +2664,7 @@
#ifdef HAVE_SCANDIR
/* #include <dirent.h> */
-int scandir (const char *dir, struct dirent ***namelist, SCANDIR_TYPE_ARG3, int(*compar)(const void *, const void *))
+int scandir (SCANDIR_TYPE_ARG1, SCANDIR_TYPE_ARG2, SCANDIR_TYPE_ARG3, SCANDIR_TYPE_ARG4)
{
char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH];
expand_chroot_path(dir, fakechroot_path, fakechroot_ptr, fakechroot_buf);
@@ -2676,7 +2676,7 @@
#ifdef HAVE_SCANDIR64
/* #include <dirent.h> */
-int scandir64 (const char *dir, struct dirent64 ***namelist, int(*filter)(const struct dirent64 *), int(*compar)(const void *, const void *))
+int scandir64 (SCANDIR64_TYPE_ARG1, SCANDIR64_TYPE_ARG2, SCANDIR64_TYPE_ARG3, SCANDIR64_TYPE_ARG4)
{
char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH];
expand_chroot_path(dir, fakechroot_path, fakechroot_ptr, fakechroot_buf);