summaryrefslogtreecommitdiffstats
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, 0 insertions, 94 deletions
diff --git a/meta/recipes-devtools/pseudo/pseudo/opendir.patch b/meta/recipes-devtools/pseudo/pseudo/opendir.patch
deleted file mode 100644
index bc6cec8e7e..0000000000
--- a/meta/recipes-devtools/pseudo/pseudo/opendir.patch
+++ /dev/null
@@ -1,94 +0,0 @@
1commit 162f2692c399b93311652201a940fdaf9c9e6924
2Author: Peter Seebach <peter.seebach@windriver.com>
3Date: Thu Feb 2 11:45:42 2012 -0600
4
5 Make opendir/closedir stash and forget directory names.
6
7 The dirfd(DIR *) interface allows you to get the fd for a DIR *,
8 meaning you can use it with openat(), meaning you can need its
9 path. This causes a segfault. Also gonna fix the base_path
10 code not to segfault in that case, but first fix the underlying
11 problem.
12
13Upstream-Status: Backport
14
15diff --git a/ChangeLog.txt b/ChangeLog.txt
16index 4de488c..9625b38 100644
17--- a/ChangeLog.txt
18+++ b/ChangeLog.txt
19@@ -1,3 +1,7 @@
20+2012-02-02:
21+ * (seebs) stash dir name for DIR * from opendir using dirfd.
22+ * (seebs) add closedir.
23+
24 2011-11-02:
25 * (seebs) Call this 1.2 because the UNLOAD change is moderately
26 significant, and so's the clone change.
27diff --git a/ports/unix/guts/closedir.c b/ports/unix/guts/closedir.c
28new file mode 100644
29index 0000000..1085361
30--- /dev/null
31+++ b/ports/unix/guts/closedir.c
32@@ -0,0 +1,20 @@
33+/*
34+ * Copyright (c) 2012 Wind River Systems; see
35+ * guts/COPYRIGHT for information.
36+ *
37+ * static int
38+ * wrap_closedir(DIR *dirp) {
39+ * int rc = -1;
40+ */
41+ if (!dirp) {
42+ errno = EFAULT;
43+ return -1;
44+ }
45+
46+ int fd = dirfd(dirp);
47+ pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0);
48+ rc = real_closedir(dirp);
49+
50+/* return rc;
51+ * }
52+ */
53diff --git a/ports/unix/guts/opendir.c b/ports/unix/guts/opendir.c
54index 8eaa71f..e69717e 100644
55--- a/ports/unix/guts/opendir.c
56+++ b/ports/unix/guts/opendir.c
57@@ -6,8 +6,25 @@
58 * wrap_opendir(const char *path) {
59 * DIR * rc = NULL;
60 */
61+ struct stat buf;
62+ int save_errno;
63
64 rc = real_opendir(path);
65+ if (rc) {
66+ int fd;
67+ save_errno = errno;
68+ fd = dirfd(rc);
69+ if (real_fstat(fd, &buf) == -1) {
70+ pseudo_debug(1, "diropen (fd %d) succeeded, but fstat failed (%s).\n",
71+ fd, strerror(errno));
72+ pseudo_client_op_plain(OP_OPEN, PSA_READ, fd, -1, path, 0);
73+ } else {
74+ pseudo_client_op_plain(OP_OPEN, PSA_READ, fd, -1, path, &buf);
75+ }
76+
77+
78+ errno = save_errno;
79+ }
80
81 /* return rc;
82 * }
83diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in
84index e06e404..32250c4 100644
85--- a/ports/unix/wrapfuncs.in
86+++ b/ports/unix/wrapfuncs.in
87@@ -21,6 +21,7 @@ long pathconf(const char *path, int name);
88 char *realpath(const char *name, char *resolved_name); /* version="GLIBC_2.3" */
89 int remove(const char *path); /* flags=AT_SYMLINK_NOFOLLOW */
90 DIR *opendir(const char *path);
91+int closedir(DIR *dirp);
92 char *tempnam(const char *template, const char *pfx);
93 char *tmpnam(char *s);
94 int truncate(const char *path, off_t length);