aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/pseudo/pseudo/opendir.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/pseudo/pseudo/opendir.patch')
-rw-r--r--meta/recipes-devtools/pseudo/pseudo/opendir.patch94
1 files changed, 94 insertions, 0 deletions
diff --git a/meta/recipes-devtools/pseudo/pseudo/opendir.patch b/meta/recipes-devtools/pseudo/pseudo/opendir.patch
new file mode 100644
index 0000000000..bc6cec8e7e
--- /dev/null
+++ b/meta/recipes-devtools/pseudo/pseudo/opendir.patch
@@ -0,0 +1,94 @@
+commit 162f2692c399b93311652201a940fdaf9c9e6924
+Author: Peter Seebach <peter.seebach@windriver.com>
+Date: Thu Feb 2 11:45:42 2012 -0600
+
+ Make opendir/closedir stash and forget directory names.
+
+ The dirfd(DIR *) interface allows you to get the fd for a DIR *,
+ meaning you can use it with openat(), meaning you can need its
+ path. This causes a segfault. Also gonna fix the base_path
+ code not to segfault in that case, but first fix the underlying
+ problem.
+
+Upstream-Status: Backport
+
+diff --git a/ChangeLog.txt b/ChangeLog.txt
+index 4de488c..9625b38 100644
+--- a/ChangeLog.txt
++++ b/ChangeLog.txt
+@@ -1,3 +1,7 @@
++2012-02-02:
++ * (seebs) stash dir name for DIR * from opendir using dirfd.
++ * (seebs) add closedir.
++
+ 2011-11-02:
+ * (seebs) Call this 1.2 because the UNLOAD change is moderately
+ significant, and so's the clone change.
+diff --git a/ports/unix/guts/closedir.c b/ports/unix/guts/closedir.c
+new file mode 100644
+index 0000000..1085361
+--- /dev/null
++++ b/ports/unix/guts/closedir.c
+@@ -0,0 +1,20 @@
++/*
++ * Copyright (c) 2012 Wind River Systems; see
++ * guts/COPYRIGHT for information.
++ *
++ * static int
++ * wrap_closedir(DIR *dirp) {
++ * int rc = -1;
++ */
++ if (!dirp) {
++ errno = EFAULT;
++ return -1;
++ }
++
++ int fd = dirfd(dirp);
++ pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0);
++ rc = real_closedir(dirp);
++
++/* return rc;
++ * }
++ */
+diff --git a/ports/unix/guts/opendir.c b/ports/unix/guts/opendir.c
+index 8eaa71f..e69717e 100644
+--- a/ports/unix/guts/opendir.c
++++ b/ports/unix/guts/opendir.c
+@@ -6,8 +6,25 @@
+ * wrap_opendir(const char *path) {
+ * DIR * rc = NULL;
+ */
++ struct stat buf;
++ int save_errno;
+
+ rc = real_opendir(path);
++ if (rc) {
++ int fd;
++ save_errno = errno;
++ fd = dirfd(rc);
++ if (real_fstat(fd, &buf) == -1) {
++ pseudo_debug(1, "diropen (fd %d) succeeded, but fstat failed (%s).\n",
++ fd, strerror(errno));
++ pseudo_client_op_plain(OP_OPEN, PSA_READ, fd, -1, path, 0);
++ } else {
++ pseudo_client_op_plain(OP_OPEN, PSA_READ, fd, -1, path, &buf);
++ }
++
++
++ errno = save_errno;
++ }
+
+ /* return rc;
+ * }
+diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in
+index e06e404..32250c4 100644
+--- a/ports/unix/wrapfuncs.in
++++ b/ports/unix/wrapfuncs.in
+@@ -21,6 +21,7 @@ long pathconf(const char *path, int name);
+ char *realpath(const char *name, char *resolved_name); /* version="GLIBC_2.3" */
+ int remove(const char *path); /* flags=AT_SYMLINK_NOFOLLOW */
+ DIR *opendir(const char *path);
++int closedir(DIR *dirp);
+ char *tempnam(const char *template, const char *pfx);
+ char *tmpnam(char *s);
+ int truncate(const char *path, off_t length);