lstat64.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * lstat64() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <_lfs_64.h>
  9. #include <sys/syscall.h>
  10. #include <unistd.h>
  11. #include <sys/stat.h>
  12. #if defined __NR_fstatat64 && !defined __NR_lstat
  13. # include <fcntl.h>
  14. int lstat64(const char *file_name, struct stat64 *buf)
  15. {
  16. return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
  17. }
  18. libc_hidden_def(lstat64)
  19. #elif __WORDSIZE == 64 && defined __NR_newfstatat
  20. # include <fcntl.h>
  21. int lstat64(const char *file_name, struct stat64 *buf)
  22. {
  23. return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
  24. }
  25. libc_hidden_def(lstat64)
  26. #elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__
  27. # include <fcntl.h>
  28. # include <statx_cp.h>
  29. int lstat64(const char *file_name, struct stat64 *buf)
  30. {
  31. struct statx tmp;
  32. int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name,
  33. AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
  34. STATX_BASIC_STATS, &tmp);
  35. if (rc == 0)
  36. __cp_stat64_statx ((struct stat64 *)buf, &tmp);
  37. return rc;
  38. }
  39. libc_hidden_def(lstat64)
  40. /* For systems which have both, prefer the old one */
  41. #elif defined __NR_lstat64
  42. # include "xstatconv.h"
  43. # define __NR___syscall_lstat64 __NR_lstat64
  44. static __always_inline _syscall2(int, __syscall_lstat64, const char *, file_name,
  45. struct kernel_stat64 *, buf)
  46. int lstat64(const char *file_name, struct stat64 *buf)
  47. {
  48. int result;
  49. struct kernel_stat64 kbuf;
  50. result = __syscall_lstat64(file_name, &kbuf);
  51. if (result == 0) {
  52. __xstat64_conv(&kbuf, buf);
  53. }
  54. return result;
  55. }
  56. libc_hidden_def(lstat64)
  57. #endif