fxstat.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* fxstat using old-style Unix fstat system call.
  2. Copyright (C) 1991-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. /* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
  16. will complain since they don't strictly match. */
  17. #define __fxstat64 __fxstat64_disable
  18. #include <errno.h>
  19. #include <stddef.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22. #include <kernel_stat.h>
  23. #include <sysdep.h>
  24. #include <sys/syscall.h>
  25. #include <xstatconv.h>
  26. /* Get information about the file FD in BUF. */
  27. int
  28. __fxstat (int vers, int fd, struct stat *buf)
  29. {
  30. if (vers == _STAT_VER_KERNEL)
  31. return INLINE_SYSCALL (fstat, 2, fd, buf);
  32. #ifdef STAT_IS_KERNEL_STAT
  33. return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
  34. #else
  35. struct kernel_stat kbuf;
  36. int result;
  37. result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
  38. if (result == 0)
  39. result = __xstat_conv (vers, &kbuf, buf);
  40. return result;
  41. #endif
  42. }
  43. hidden_def (__fxstat)
  44. weak_alias (__fxstat, _fxstat);
  45. #if XSTAT_IS_XSTAT64
  46. #undef __fxstat64
  47. strong_alias (__fxstat, __fxstat64);
  48. hidden_ver (__fxstat, __fxstat64)
  49. #endif