1
0

open.c 464 B

1234567891011121314151617181920212223
  1. #include <fcntl.h>
  2. #include <stdarg.h>
  3. #include "syscall.h"
  4. int open(const char *filename, int flags, ...)
  5. {
  6. mode_t mode = 0;
  7. if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) {
  8. va_list ap;
  9. va_start(ap, flags);
  10. mode = va_arg(ap, mode_t);
  11. va_end(ap);
  12. }
  13. int fd = __sys_open_cp(filename, flags, mode);
  14. if (fd>=0 && (flags & O_CLOEXEC))
  15. __syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
  16. return __syscall_ret(fd);
  17. }
  18. weak_alias(open, open64);