Rüdiger Kessel [off-list ref] writes:
Trying git_mkstemp_mode() first means trying more 16000 times to create a
random file before realizing that something might be wrong.
Well, git_mkstemps_mode() does have such a 16k loop, and it tries to
create a unique, unused file this way:
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
if (fd > 0)
return fd;
/*
* Fatal error (EPERM, ENOSPC etc).
* It doesn't make sense to loop.
*/
if (errno != EEXIST)
break;
If you do not have a directory D and try to create D/tmp_random here,
shouldn't you get an error that is _NOT_ EEXIST and trigger this break?