fxstat64.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* fxstat64 using Linux fstat64/statx system call.
  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. #include <errno.h>
  16. #include <stddef.h>
  17. #include <fcntl.h>
  18. #include <sys/stat.h>
  19. #include <kernel_stat.h>
  20. #include <sysdep.h>
  21. #include <sys/syscall.h>
  22. #include <statx_cp.h>
  23. /* Get information about the file FD in BUF. */
  24. int
  25. ___fxstat64 (int vers, int fd, struct stat64 *buf)
  26. {
  27. int result;
  28. #ifdef __NR_fstat64
  29. result = INLINE_SYSCALL (fstat64, 2, fd, buf);
  30. #else
  31. struct statx tmp;
  32. result = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS,
  33. &tmp);
  34. if (result == 0)
  35. __cp_stat64_statx (buf, &tmp);
  36. #endif
  37. return result;
  38. }
  39. #include <shlib-compat.h>
  40. #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
  41. versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
  42. strong_alias (___fxstat64, __old__fxstat64)
  43. compat_symbol (libc, __old__fxstat64, __fxstat64, GLIBC_2_1);
  44. hidden_ver (___fxstat64, __fxstat64)
  45. #else
  46. strong_alias (___fxstat64, __fxstat64)
  47. hidden_def (__fxstat64)
  48. #endif