open64.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <features.h>
  7. #include <fcntl.h>
  8. #include <stdarg.h>
  9. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  10. #include <errno.h>
  11. #include <sysdep-cancel.h>
  12. #endif
  13. #ifdef __UCLIBC_HAS_LFS__
  14. #ifndef O_LARGEFILE
  15. # define O_LARGEFILE 0100000
  16. #endif
  17. /* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
  18. a third argument is the file protection. */
  19. int open64 (const char *file, int oflag, ...)
  20. {
  21. mode_t mode = 0;
  22. if (oflag & O_CREAT)
  23. {
  24. va_list arg;
  25. va_start (arg, oflag);
  26. mode = va_arg (arg, mode_t);
  27. va_end (arg);
  28. }
  29. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  30. if (SINGLE_THREAD_P)
  31. return INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode);
  32. int oldtype = LIBC_CANCEL_ASYNC ();
  33. int result = INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode);
  34. LIBC_CANCEL_RESET (oldtype);
  35. return result;
  36. #else
  37. return open(file, oflag | O_LARGEFILE, mode);
  38. #endif
  39. }
  40. #ifndef __LINUXTHREADS_OLD__
  41. libc_hidden_def(open64)
  42. #else
  43. libc_hidden_weak(open64)
  44. strong_alias(open64,__libc_open64)
  45. #endif
  46. #endif /* __UCLIBC_HAS_LFS__ */