lxstat.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* lxstat using old-style Unix lstat 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 __lxstat64 __lxstat64_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. __lxstat (int vers, const char *name, struct stat *buf)
  28. {
  29. if (vers == _STAT_VER_KERNEL)
  30. return INLINE_SYSCALL (lstat, 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 (lstat, 2, name, &kbuf);
  37. if (result == 0)
  38. result = __xstat_conv (vers, &kbuf, buf);
  39. return result;
  40. #endif
  41. }
  42. hidden_def (__lxstat)
  43. weak_alias (__lxstat, _lxstat);
  44. #if XSTAT_IS_XSTAT64
  45. #undef __lxstat64
  46. strong_alias (__lxstat, __lxstat64);
  47. hidden_ver (__lxstat, __lxstat64)
  48. #endif