xstat.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* xstat using old-style Unix stat 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 __xstat64 __xstat64_disable
  18. #include <errno.h>
  19. #include <stddef.h>
  20. #include <sys/stat.h>
  21. #include <kernel_stat.h>
  22. #include <sysdep.h>
  23. #include <sys/syscall.h>
  24. #include <xstatconv.h>
  25. /* Get information about the file NAME in BUF. */
  26. int
  27. __xstat (int vers, const char *name, struct stat *buf)
  28. {
  29. if (vers == _STAT_VER_KERNEL)
  30. return INLINE_SYSCALL (stat, 2, name, buf);
  31. #ifdef STAT_IS_KERNEL_STAT
  32. return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
  33. #else
  34. struct kernel_stat kbuf;
  35. int result;
  36. result = INLINE_SYSCALL (stat, 2, name, &kbuf);
  37. if (result == 0)
  38. result = __xstat_conv (vers, &kbuf, buf);
  39. return result;
  40. #endif
  41. }
  42. hidden_def (__xstat)
  43. weak_alias (__xstat, _xstat);
  44. #if XSTAT_IS_XSTAT64
  45. #undef __xstat64
  46. strong_alias (__xstat, __xstat64);
  47. hidden_ver (__xstat, __xstat64)
  48. #endif