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 "syscalls.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. libc_hidden_proto(__libc_open)
  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. int __libc_open(const char *file, int flags, ...)
  21. {
  22. /* gcc may warn about mode being uninitialized.
  23. * Just ignore that, since gcc is wrong. */
  24. mode_t mode;
  25. if (flags & O_CREAT) {
  26. va_list ap;
  27. va_start(ap, flags);
  28. mode = va_arg(ap, mode_t);
  29. va_end(ap);
  30. }
  31. return __syscall_open(file, flags, mode);
  32. }
  33. libc_hidden_def(__libc_open)
  34. libc_hidden_proto(open)
  35. weak_alias(__libc_open,open)
  36. libc_hidden_weak(open)
  37. int creat(const char *file, mode_t mode)
  38. {
  39. return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
  40. }