lstat.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. && defined __UCLIBC_HAS_LFS__
  48. strong_alias_untyped(lstat,lstat64)
  49. libc_hidden_def(lstat64)
  50. # endif
  51. #endif /* __NR_fstatat64 */