fstatat.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * fstatat() for uClibc
  3. *
  4. * Copyright (C) 2009 Analog Devices Inc.
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <sys/stat.h>
  10. #include "xstatconv.h"
  11. /* 64bit ports tend to favor newfstatat() */
  12. #if __WORDSIZE == 64 && defined __NR_newfstatat
  13. # define __NR_fstatat64 __NR_newfstatat
  14. #endif
  15. #ifdef __NR_fstatat64
  16. int fstatat(int fd, const char *file, struct stat *buf, int flag)
  17. {
  18. int ret;
  19. # ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
  20. struct kernel_stat64 kbuf;
  21. ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
  22. if (ret == 0)
  23. __xstat32_conv(&kbuf, buf);
  24. # else
  25. ret = INLINE_SYSCALL(fstatat64, 4, fd, file, buf, flag);
  26. if (ret == 0) {
  27. /* Did we overflow */
  28. if (buf->__pad1 || buf->__pad2 || buf->__pad3
  29. || buf->__pad4 || buf->__pad5 || buf->__pad6
  30. || buf->__pad7) {
  31. __set_errno(EOVERFLOW);
  32. return -1;
  33. }
  34. }
  35. # endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */
  36. return ret;
  37. }
  38. libc_hidden_def(fstatat)
  39. #else
  40. /* should add emulation with fstat() and /proc/self/fd/ ... */
  41. #endif