aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
authorPeter Seebach <seebs@eee12.(none)>2010-06-21 18:43:31 -0500
committerPeter Seebach <seebs@eee12.(none)>2010-06-21 18:43:31 -0500
commite2b14be08b727d74b073bd28776dd584f4b4c8f2 (patch)
tree6906c85127192643bd3c8ef0802a180dea9ff482 /guts
parent602626f84e9c06463fc8f5f92caad041b3a30d9b (diff)
downloadpseudo-e2b14be08b727d74b073bd28776dd584f4b4c8f2.tar.gz
pseudo-e2b14be08b727d74b073bd28776dd584f4b4c8f2.tar.bz2
pseudo-e2b14be08b727d74b073bd28776dd584f4b4c8f2.zip
Add mkstemp64(). Also, check in the man page for the NOSYMLINKEXP
feature.
Diffstat (limited to 'guts')
-rw-r--r--guts/README1
-rw-r--r--guts/mkstemp64.c47
2 files changed, 48 insertions, 0 deletions
diff --git a/guts/README b/guts/README
index 871e6bb..86ec59e 100644
--- a/guts/README
+++ b/guts/README
@@ -90,6 +90,7 @@ wrappers:
freopen
freopen64
mkstemp
+ mkstemp64
fcntl
fork
link
diff --git a/guts/mkstemp64.c b/guts/mkstemp64.c
new file mode 100644
index 0000000..def4126
--- /dev/null
+++ b/guts/mkstemp64.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010 Wind River Systems; see
+ * guts/COPYRIGHT for information.
+ *
+ * static int
+ * wrap_mkstemp64(char *template) {
+ * int rc = -1;
+ */
+ struct stat64 buf;
+ int save_errno;
+ size_t len;
+ char *tmp_template;
+
+ 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_mkstemp64(tmp_template);
+
+ if (rc != -1) {
+ save_errno = errno;
+
+ if (real___fxstat64(_STAT_VER, rc, &buf) != -1) {
+ 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(1, "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);
+ free(tmp_template);
+/* return rc;
+ * }
+ */