Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ enum file_type {
STREAM_BY_FOPEN,
STREAM_BY_FDOPEN,
FILE_BY_MKSTEMP,
FILE_BY_O_TMPFILE,
FILE_BY_DUP
};

Expand Down
26 changes: 26 additions & 0 deletions mysys/mf_tempfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
}

#else /* mkstemp() is available on all non-Windows supported platforms. */
#ifdef O_TMPFILE
{
static int O_TMPFILE_works = 1;

if (O_TMPFILE_works)
{
/* explictly don't use O_EXCL here has it has a different
meaning with O_TMPFILE
*/
if ((file = open(dir, O_RDWR | O_TMPFILE | O_CLOEXEC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) >= 0)
{
snprintf(to, FN_REFLEN, "%s/#sql/fd=%d", dir, file);
file = my_register_filename(file, to, FILE_BY_O_TMPFILE,
EE_CANTCREATEFILE, MyFlags);
}
else if (errno == EOPNOTSUPP || errno == EINVAL)
{
my_printf_error(EE_CANTCREATEFILE, "O_TMPFILE is not supported on %s "
"(disabling future attempts)", MYF(0), dir);
O_TMPFILE_works= 0;
}
}
}
if (file == -1)
#endif /* O_TMPFILE */
{
char prefix_buff[30];
uint pfx_len;
Expand Down