#ifdef O_TMPFILE
fd = open (dir, flags | O_RDWR | O_EXCL | O_TMPFILE, 0700);
/* If the running system does not support the O_TMPFILE flag then retry without it. */
if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP)) {
if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP &&
errno != EACCES)) {
return fd;
} else {
errno = 0;