aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/guts/mkstemp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/unix/guts/mkstemp.c')
-rw-r--r--ports/unix/guts/mkstemp.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/ports/unix/guts/mkstemp.c b/ports/unix/guts/mkstemp.c
index 1e2b026..8fab58b 100644
--- a/ports/unix/guts/mkstemp.c
+++ b/ports/unix/guts/mkstemp.c
@@ -6,42 +6,9 @@
* wrap_mkstemp(char *template) {
* int rc = -1;
*/
- PSEUDO_STATBUF buf;
- int save_errno;
- size_t len;
- char *tmp_template;
+ /* mkstemp() is just like mkostemps() with no flags and no suffix */
+ rc = wrap_mkostemps(template, 0, 0);
- if (!template) {
- errno = EFAULT;
- return 0;
- }
-
- len = strlen(template);
- tmp_template = PSEUDO_ROOT_PATH(AT_FDCWD, template, AT_SYMLINK_NOFOLLOW);
-
- if (!tmp_template) {
- errno = ENOENT;
- return -1;
- }
-
- rc = real_mkstemp(tmp_template);
-
- if (rc != -1) {
- save_errno = errno;
-
- if (base_fstat(rc, &buf) != -1) {
- real_fchmod(rc, PSEUDO_FS_MODE(0600, 0));
- pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, &buf);
- pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, rc, -1, tmp_template, &buf);
- } else {
- pseudo_debug(PDBGF_CONSISTENCY, "mkstemp (fd %d) succeeded, but fstat failed (%s).\n",
- rc, strerror(errno));
- pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, rc, -1, tmp_template, 0);
- }
- errno = save_errno;
- }
- /* mkstemp only changes the XXXXXX at the end. */
- memcpy(template + len - 6, tmp_template + strlen(tmp_template) - 6, 6);
/* return rc;
* }
*/