aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.txt3
-rw-r--r--guts/README1
-rw-r--r--guts/mkstemp64.c47
-rw-r--r--pseudo.112
-rw-r--r--wrapfuncs64.in1
5 files changed, 64 insertions, 0 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index c0d9baf..a074e55 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+2010-06-21:
+ * (seebs) add mkstemp64
+
2010-06-02:
* (seebs) add PSEUDO_NOSYMLINKEXP feature and documentation.
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;
+ * }
+ */
diff --git a/pseudo.1 b/pseudo.1
index 3cc7a95..16a36d6 100644
--- a/pseudo.1
+++ b/pseudo.1
@@ -323,6 +323,18 @@ no function outside of debugging
.I pseudo
itself.
.TP 8
+.B PSEUDO_NOSYMLINKEXP
+By default, when chrooted,
+.I pseudo
+prepends the chroot directory to
+the paths used for absolute symlinks; this behavior ensures that
+opening symlinks produces expected results in most cases. In some
+cases you may want to suppress this. If this variable is unset, or
+set to any value other than 0,
+.I pseudo
+expands symlink paths like this. If this variable is set to 0,
+the behavior is disabled.
+.TP 8
.BR PSEUDO_OPTS
This variable holds options to be passed to any new
.I pseudo
diff --git a/wrapfuncs64.in b/wrapfuncs64.in
index 20d4ea3..71ab0a6 100644
--- a/wrapfuncs64.in
+++ b/wrapfuncs64.in
@@ -13,3 +13,4 @@ int ftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int),
int glob64(const char *pattern, int flags, int (*errfunc)(const char *, int), glob64_t *pglob);
int scandir64(const char *path, struct dirent64 ***namelist, int (*filter)(const struct dirent64 *), int (*compar)());
int truncate64(const char *path, off64_t length);
+int mkstemp64(char *template); /* flags=AT_SYMLINK_NOFOLLOW */