lstat.c 1023 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include "xstatconv.h"
  13. int lstat(const char *file_name, struct stat *buf)
  14. {
  15. int result;
  16. #ifdef __NR_lstat64
  17. /* normal stat call has limited values for various stat elements
  18. * e.g. uid device major/minor etc.
  19. * so we use 64 variant if available
  20. * in order to get newer versions of stat elements
  21. */
  22. struct kernel_stat64 kbuf;
  23. result = INLINE_SYSCALL(lstat64, 2, file_name, &kbuf);
  24. if (result == 0) {
  25. __xstat32_conv(&kbuf, buf);
  26. }
  27. #else
  28. struct kernel_stat kbuf;
  29. result = INLINE_SYSCALL(lstat, 2, file_name, &kbuf);
  30. if (result == 0) {
  31. __xstat_conv(&kbuf, buf);
  32. }
  33. #endif
  34. return result;
  35. }
  36. libc_hidden_def(lstat)
  37. #if ! defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
  38. strong_alias_untyped(lstat,lstat64)
  39. libc_hidden_def(lstat64)
  40. #endif