fxstatat.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (C) 2005-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. /* Ho hum, if fxstatat == fxstatat64 we must get rid of the prototype or gcc
  15. will complain since they don't strictly match. */
  16. #define __fxstatat64 __fxstatat64_disable
  17. #include <errno.h>
  18. #include <fcntl.h>
  19. #include <stddef.h>
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <sys/stat.h>
  23. #include <kernel_stat.h>
  24. #include <sysdep.h>
  25. #include <sys/syscall.h>
  26. #include <xstatconv.h>
  27. /* Get information about the file NAME in BUF. */
  28. int
  29. __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
  30. {
  31. int result;
  32. INTERNAL_SYSCALL_DECL (err);
  33. #ifdef STAT_IS_KERNEL_STAT
  34. # define kst (*st)
  35. #else
  36. struct kernel_stat kst;
  37. #endif
  38. result = INTERNAL_SYSCALL (newfstatat, err, 4, fd, file, &kst, flag);
  39. if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
  40. {
  41. #ifdef STAT_IS_KERNEL_STAT
  42. return 0;
  43. #else
  44. return __xstat_conv (vers, &kst, st);
  45. #endif
  46. }
  47. else
  48. return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
  49. err));
  50. }
  51. libc_hidden_def (__fxstatat)
  52. #if XSTAT_IS_XSTAT64
  53. # undef __fxstatat64
  54. strong_alias (__fxstatat, __fxstatat64);
  55. libc_hidden_def (__fxstatat64)
  56. #endif