11 char *__randname(char *);
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);
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);