open.c 913 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * open() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codpoet.org>
  6. *
  7. * GNU Library General Public License (LGPL) version 2 or later.
  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. #define __NR___syscall_open __NR_open
  16. static inline _syscall3(int, __syscall_open, const char *, file,
  17. int, flags, __kernel_mode_t, mode);
  18. int __libc_open(const char *file, int flags, ...)
  19. {
  20. /* gcc may warn about mode being uninitialized.
  21. * Just ignore that, since gcc is wrong. */
  22. mode_t mode;
  23. if (flags & O_CREAT) {
  24. va_list ap;
  25. va_start(ap, flags);
  26. mode = va_arg(ap, mode_t);
  27. va_end(ap);
  28. }
  29. return __syscall_open(file, flags, mode);
  30. }
  31. weak_alias(__libc_open, open);
  32. int creat(const char *file, mode_t mode)
  33. {
  34. return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
  35. }