open.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * open() 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 <fcntl.h>
  11. #include <stdarg.h>
  12. #include <cancel.h>
  13. #define __NR___syscall_open __NR_open
  14. static __always_inline _syscall3(int, __syscall_open, const char *, file,
  15. int, flags, __kernel_mode_t, mode)
  16. strong_alias_untyped(__syscall_open,__NC(open))
  17. #define __NR___open2_nocancel __NR_open
  18. _syscall2(int, __NC(open2), const char *, file, int, flags)
  19. int open(const char *file, int oflag, ...)
  20. {
  21. mode_t mode = 0;
  22. if (oflag & O_CREAT) {
  23. va_list arg;
  24. va_start(arg, oflag);
  25. mode = va_arg(arg, mode_t);
  26. va_end(arg);
  27. }
  28. if (SINGLE_THREAD_P)
  29. return __NC(open)(file, oflag, mode);
  30. #ifdef __NEW_THREADS
  31. int oldtype = LIBC_CANCEL_ASYNC ();
  32. int result = __NC(open)(file, oflag, mode);
  33. LIBC_CANCEL_RESET (oldtype);
  34. return result;
  35. #endif
  36. }
  37. lt_strong_alias(open)
  38. lt_libc_hidden(open)