Loading...
--- Libc/Libc-498.1.7/sys/open.c
+++ Libc/Libc-583/sys/open.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005, 2009 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@@ -22,24 +22,26 @@
*/
#include <sys/types.h>
-/*
- * We need O_NOCTTY from fcntl.h, but that would also drag in the variadic
- * prototype for open(), and so we'd have to use stdarg.h to get the mode.
- * So open.h just contains O_NOCTTY, which it gets from fcntl.h.
- *
- * This is for legacy only.
- */
-#include "open.h"
+#include <fcntl.h>
+#include <stdarg.h>
int __open_nocancel(const char *path, int flags, mode_t mode);
-int open(const char *path, int flags, mode_t mode) LIBC_ALIAS_C(open);
/*
* open stub: The legacy interface never automatically associated a controlling
* tty, so we always pass O_NOCTTY.
*/
int
-open(const char *path, int flags, mode_t mode)
+open(const char *path, int flags, ...)
{
+ mode_t mode = 0;
+
+ if(flags & O_CREAT) {
+ va_list ap;
+ va_start(ap, flags);
+ // compiler warns to pass int (not mode_t) to va_arg
+ mode = va_arg(ap, int);
+ va_end(ap);
+ }
return(__open_nocancel(path, flags | O_NOCTTY, mode));
}