lstat64.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /* For systems which have both, prefer the old one */
  27. #elif defined __NR_lstat64
  28. # include "xstatconv.h"
  29. # define __NR___syscall_lstat64 __NR_lstat64
  30. static __always_inline _syscall2(int, __syscall_lstat64, const char *, file_name,
  31. struct kernel_stat64 *, buf)
  32. int lstat64(const char *file_name, struct stat64 *buf)
  33. {
  34. int result;
  35. struct kernel_stat64 kbuf;
  36. result = __syscall_lstat64(file_name, &kbuf);
  37. if (result == 0) {
  38. __xstat64_conv(&kbuf, buf);
  39. }
  40. return result;
  41. }
  42. libc_hidden_def(lstat64)
  43. #endif