open.c 816 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #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 open(const char *file, int oflag, ...)
  19. {
  20. mode_t mode = 0;
  21. if (oflag & O_CREAT) {
  22. va_list arg;
  23. va_start(arg, oflag);
  24. mode = va_arg(arg, mode_t);
  25. va_end(arg);
  26. }
  27. return __syscall_open(file, oflag, mode);
  28. }
  29. libc_hidden_def(open)
  30. int creat(const char *file, mode_t mode)
  31. {
  32. return open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
  33. }