13 char *tempnam(const char *dir
, const char *pfx
)
20 if (!dir
) dir
= P_tmpdir
;
21 if (!pfx
) pfx
= "temp";
25 l
= dl
+ 1 + pl
+ 1 + 6;
34 memcpy(s
+dl
+1, pfx
, pl
);
38 for (try=0; try<MAXTRIES
; try++) {
41 r
= __syscall(SYS_lstat
, s
, &(struct kstat
){0});
43 r
= __syscall(SYS_fstatat
, AT_FDCWD
, s
,
44 &(struct kstat
){0}, AT_SYMLINK_NOFOLLOW
);
46 if (r
== -ENOENT
) return strdup(s
);