OSDN Git Service

mkostemp: fix implementation
[uclinux-h8/uClibc.git] / libc / stdlib / mkostemp.c
index 0369235..912be30 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <fcntl.h>
 #include "../misc/internals/tempname.h"
 
 /* Generate a unique temporary file name from TEMPLATE.
@@ -26,5 +27,6 @@
 int
 mkostemp (char *template, int flags)
 {
-  return __gen_tempname (template, __GT_FILE, flags);
+  flags -= flags & O_ACCMODE; /* Remove O_RDONLY, O_WRONLY, and O_RDWR. */
+  return __gen_tempname (template, __GT_FILE, flags, S_IRUSR | S_IWUSR);
 }