12 char *tempnam(const char *dir
, const char *pfx
)
19 if (!dir
) dir
= P_tmpdir
;
20 if (!pfx
) pfx
= "temp";
24 l
= dl
+ 1 + pl
+ 1 + 6;
33 memcpy(s
+dl
+1, pfx
, pl
);
37 for (try=0; try<MAXTRIES
; try++) {
40 r
= __syscall(SYS_lstat
, s
, &(struct stat
){0});
42 r
= __syscall(SYS_fstatat
, AT_FDCWD
, s
,
43 &(struct stat
){0}, AT_SYMLINK_NOFOLLOW
);
45 if (r
== -ENOENT
) return strdup(s
);