lstat.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * lstat() 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 <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 lstat(const char *file_name, struct stat *buf)
  15. {
  16. return fstatat(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
  17. }
  18. libc_hidden_def(lstat)
  19. /* For systems which have both, prefer the old one */
  20. #else
  21. # include "xstatconv.h"
  22. int lstat(const char *file_name, struct stat *buf)
  23. {
  24. int result;
  25. # ifdef __NR_lstat64
  26. /* normal stat call has limited values for various stat elements
  27. * e.g. uid device major/minor etc.
  28. * so we use 64 variant if available
  29. * in order to get newer versions of stat elements
  30. */
  31. struct kernel_stat64 kbuf;
  32. result = INLINE_SYSCALL(lstat64, 2, file_name, &kbuf);
  33. if (result == 0) {
  34. __xstat32_conv(&kbuf, buf);
  35. }
  36. # else
  37. struct kernel_stat kbuf;
  38. result = INLINE_SYSCALL(lstat, 2, file_name, &kbuf);
  39. if (result == 0) {
  40. __xstat_conv(&kbuf, buf);
  41. }
  42. # endif /* __NR_lstat64 */
  43. return result;
  44. }
  45. libc_hidden_def(lstat)
  46. # if ! defined __NR_fstatat64 && ! defined __NR_lstat64
  47. strong_alias_untyped(lstat,lstat64)
  48. libc_hidden_def(lstat64)
  49. # endif
  50. #endif /* __NR_fstatat64 */