Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: fusl/src/stdio/tmpnam.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/stdio/tmpfile.c ('k') | fusl/src/stdio/ungetc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <errno.h>
4 #include <sys/stat.h>
5 #include <string.h>
6 #include "syscall.h"
7
8 #define MAXTRIES 100
9
10 char *__randname(char *);
11
12 char *tmpnam(char *buf)
13 {
14 static char internal[L_tmpnam];
15 char s[] = "/tmp/tmpnam_XXXXXX";
16 int try;
17 int r;
18 for (try=0; try<MAXTRIES; try++) {
19 __randname(s+12);
20 #ifdef SYS_lstat
21 r = __syscall(SYS_lstat, s, &(struct stat){0});
22 #else
23 r = __syscall(SYS_fstatat, AT_FDCWD, s,
24 &(struct stat){0}, AT_SYMLINK_NOFOLLOW);
25 #endif
26 if (r == -ENOENT) return strcpy(buf ? buf : internal, s);
27 }
28 return 0;
29 }
OLDNEW
« no previous file with comments | « fusl/src/stdio/tmpfile.c ('k') | fusl/src/stdio/ungetc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698