openat.c 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * openat() 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 <fcntl.h>
  10. #include <stdarg.h>
  11. #include <cancel.h>
  12. #ifdef __NR_openat
  13. # define __NR___syscall_openat __NR_openat
  14. static __inline__ _syscall4(int, __syscall_openat, int, fd, const char *, file, int, oflag, mode_t, mode)
  15. int __openat(int fd, const char *file, int o_flag, ...)
  16. {
  17. #ifdef __NEW_THREADS
  18. int oldtype, result;
  19. #endif
  20. va_list ap;
  21. mode_t mode;
  22. va_start(ap, o_flag);
  23. mode = va_arg(ap, int);
  24. va_end(ap);
  25. if (SINGLE_THREAD_P)
  26. return __syscall_openat(fd, file, o_flag, mode);
  27. #ifdef __NEW_THREADS
  28. oldtype = LIBC_CANCEL_ASYNC ();
  29. result = __syscall_openat(fd, file, o_flag, mode);
  30. LIBC_CANCEL_RESET (oldtype);
  31. return result;
  32. #endif
  33. }
  34. strong_alias_untyped(__openat,openat)
  35. libc_hidden_def(openat)
  36. #else
  37. /* should add emulation with open() and /proc/self/fd/ ... */
  38. #endif