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

Side by Side Diff: fusl/src/temp/mkostemps.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/temp/mkostemp.c ('k') | fusl/src/temp/mkstemp.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 #define _BSD_SOURCE
2 #include <string.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <errno.h>
6 #include "libc.h"
7
8 char *__randname(char *);
9
10 int __mkostemps(char *template, int len, int flags)
11 {
12 size_t l = strlen(template);
13 if (l<6 || len>l-6 || memcmp(template+l-len-6, "XXXXXX", 6)) {
14 errno = EINVAL;
15 return -1;
16 }
17
18 flags -= flags & O_ACCMODE;
19 int fd, retries = 100;
20 do {
21 __randname(template+l-len-6);
22 if ((fd = open(template, flags | O_RDWR | O_CREAT | O_EXCL, 0600 ))>=0)
23 return fd;
24 } while (--retries && errno == EEXIST);
25
26 memcpy(template+l-len-6, "XXXXXX", 6);
27 return -1;
28 }
29
30 weak_alias(__mkostemps, mkostemps);
31 weak_alias(__mkostemps, mkostemps64);
OLDNEW
« no previous file with comments | « fusl/src/temp/mkostemp.c ('k') | fusl/src/temp/mkstemp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698