open.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 <stdlib.h>
  11. #include <stdarg.h>
  12. #include <fcntl.h>
  13. #include <string.h>
  14. #include <sys/param.h>
  15. extern __typeof(open) __libc_open;
  16. extern __typeof(creat) __libc_creat;
  17. #define __NR___syscall_open __NR_open
  18. static inline _syscall3(int, __syscall_open, const char *, file,
  19. int, flags, __kernel_mode_t, mode);
  20. libc_hidden_proto(__libc_open)
  21. int __libc_open(const char *file, int oflag, ...)
  22. {
  23. mode_t mode = 0;
  24. if (oflag & O_CREAT) {
  25. va_list arg;
  26. va_start (arg, oflag);
  27. mode = va_arg (arg, mode_t);
  28. va_end (arg);
  29. }
  30. return __syscall_open(file, oflag, mode);
  31. }
  32. libc_hidden_def(__libc_open)
  33. libc_hidden_proto(open)
  34. weak_alias(__libc_open,open)
  35. libc_hidden_weak(open)
  36. int __libc_creat(const char *file, mode_t mode)
  37. {
  38. return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
  39. }
  40. weak_alias(__libc_creat,creat)