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

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

Issue 1717423002: [fusl] Don't syscall(SYS_unlink) in stdio (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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/remove.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <fcntl.h> 2 #include <fcntl.h>
3 #include <unistd.h>
3 #include "stdio_impl.h" 4 #include "stdio_impl.h"
4 5
5 #define MAXTRIES 100 6 #define MAXTRIES 100
6 7
7 char* __randname(char*); 8 char* __randname(char*);
8 9
9 FILE* tmpfile(void) { 10 FILE* tmpfile(void) {
10 char s[] = "/tmp/tmpfile_XXXXXX"; 11 char s[] = "/tmp/tmpfile_XXXXXX";
11 int fd; 12 int fd;
12 FILE* f; 13 FILE* f;
13 int try 14 int try
14 ; 15 ;
15 for (try = 0; try < MAXTRIES; try ++) { 16 for (try = 0; try < MAXTRIES; try ++) {
16 __randname(s + 13); 17 __randname(s + 13);
17 fd = sys_open(s, O_RDWR | O_CREAT | O_EXCL, 0600); 18 fd = sys_open(s, O_RDWR | O_CREAT | O_EXCL, 0600);
18 if (fd >= 0) { 19 if (fd >= 0) {
19 #ifdef SYS_unlink 20 unlink(s);
20 __syscall(SYS_unlink, s);
21 #else
22 __syscall(SYS_unlinkat, AT_FDCWD, s, 0);
23 #endif
24 f = __fdopen(fd, "w+"); 21 f = __fdopen(fd, "w+");
25 if (!f) 22 if (!f)
26 __syscall(SYS_close, fd); 23 __syscall(SYS_close, fd);
27 return f; 24 return f;
28 } 25 }
29 } 26 }
30 return 0; 27 return 0;
31 } 28 }
OLDNEW
« no previous file with comments | « fusl/src/stdio/remove.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698