summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/mkstemp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/mkstemp.c')
-rw-r--r--src/lib/libc/stdlib/mkstemp.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/lib/libc/stdlib/mkstemp.c b/src/lib/libc/stdlib/mkstemp.c
deleted file mode 100644
index 75a9d27d1a..0000000000
--- a/src/lib/libc/stdlib/mkstemp.c
+++ /dev/null
@@ -1,64 +0,0 @@
1/* $OpenBSD: mkstemp.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */
2/*
3 * Copyright (c) 2024 Todd C. Miller
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <sys/stat.h>
19#include <errno.h>
20#include <fcntl.h>
21#include <stdlib.h>
22
23#define MKOSTEMP_FLAGS (O_APPEND | O_CLOEXEC | O_DSYNC | O_RSYNC | O_SYNC)
24
25static int
26mkstemp_cb(const char *path, int flags)
27{
28 flags |= O_CREAT | O_EXCL | O_RDWR;
29 return open(path, flags, S_IRUSR|S_IWUSR);
30}
31
32int
33mkostemps(char *path, int slen, int flags)
34{
35 if (flags & ~MKOSTEMP_FLAGS) {
36 errno = EINVAL;
37 return -1;
38 }
39 return __mktemp4(path, slen, flags, mkstemp_cb);
40}
41
42int
43mkostemp(char *path, int flags)
44{
45 if (flags & ~MKOSTEMP_FLAGS) {
46 errno = EINVAL;
47 return -1;
48 }
49 return __mktemp4(path, 0, flags, mkstemp_cb);
50}
51DEF_WEAK(mkostemp);
52
53int
54mkstemp(char *path)
55{
56 return __mktemp4(path, 0, 0, mkstemp_cb);
57}
58DEF_WEAK(mkstemp);
59
60int
61mkstemps(char *path, int slen)
62{
63 return __mktemp4(path, slen, 0, mkstemp_cb);
64}