open.c 947 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * open() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.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 attribute_hidden __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. strong_alias(__open,open)
  32. weak_alias(__open,__libc_open)
  33. int creat(const char *file, mode_t mode)
  34. {
  35. return __open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
  36. }