open.c 973 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #undef __open
  16. #undef 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 attribute_hidden __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. strong_alias(__open,open)
  34. weak_alias(__open,__libc_open)
  35. int creat(const char *file, mode_t mode)
  36. {
  37. return __open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
  38. }