readdir64.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Read a directory. Linux LFS version.
  2. Copyright (C) 1997-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. /* When _DIRENT_MATCHES_DIRENT64 is defined we can alias 'readdir64' to
  16. 'readdir'. However the function signatures are not equal due
  17. different return types, so we need to suppress {__}readdir so weak
  18. and strong alias do not throw conflicting types errors. */
  19. #define readdir __no_readdir_decl
  20. #define __readdir __no___readdir_decl
  21. #include <dirent.h>
  22. #define __READDIR __readdir64
  23. #define __GETDENTS __getdents64
  24. #define DIRENT_TYPE struct dirent64
  25. #include <sysdeps/posix/readdir.c>
  26. #undef __readdir
  27. #undef readdir
  28. libc_hidden_def (__readdir64)
  29. #if _DIRENT_MATCHES_DIRENT64
  30. strong_alias (__readdir64, __readdir)
  31. weak_alias (__readdir64, readdir64)
  32. weak_alias (__readdir64, readdir)
  33. #else
  34. /* The compat code expects the 'struct direct' with d_ino being a __ino_t
  35. instead of __ino64_t. */
  36. # include <shlib-compat.h>
  37. versioned_symbol (libc, __readdir64, readdir64, GLIBC_2_2);
  38. # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
  39. # include <olddirent.h>
  40. # define __READDIR attribute_compat_text_section __old_readdir64
  41. # define __GETDENTS __old_getdents64
  42. # define DIRENT_TYPE struct __old_dirent64
  43. # include <sysdeps/posix/readdir.c>
  44. libc_hidden_def (__old_readdir64)
  45. compat_symbol (libc, __old_readdir64, readdir64, GLIBC_2_1);
  46. # endif /* SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) */
  47. #endif /* _DIRENT_MATCHES_DIRENT64 */