lstat64.c 1.2 KB

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