xref: /OK3568_Linux_fs/buildroot/package/make/0001-glob-Do-not-assume-glibc-glob-internals.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 193f1e81edd6b1b56b0eb0ff8aa4b41c7b4257b4 Mon Sep 17 00:00:00 2001
2From: Paul Eggert <eggert@cs.ucla.edu>
3Date: Sun, 24 Sep 2017 09:12:58 -0400
4Subject: [PATCH] glob: Do not assume glibc glob internals.
5
6It has been proposed that glibc glob start using gl_lstat,
7which the API allows it to do.  GNU 'make' should not get in
8the way of this.  See:
9https://sourceware.org/ml/libc-alpha/2017-09/msg00409.html
10
11* dir.c (local_lstat): New function, like local_stat.
12(dir_setup_glob): Use it to initialize gl_lstat too, as the API
13requires.
14
15Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
16(from upstream commit 193f1e81edd6b1b56b0eb0ff8aa4b41c7b4257b4)
17---
18 dir.c | 29 +++++++++++++++++++++++++++--
19 1 file changed, 27 insertions(+), 2 deletions(-)
20
21diff --git a/dir.c b/dir.c
22index adbb8a9..c343e4c 100644
23--- a/dir.c
24+++ b/dir.c
25@@ -1299,15 +1299,40 @@ local_stat (const char *path, struct stat *buf)
26 }
27 #endif
28
29+/* Similarly for lstat.  */
30+#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
31+# ifndef VMS
32+#  ifndef HAVE_SYS_STAT_H
33+int lstat (const char *path, struct stat *sbuf);
34+#  endif
35+# else
36+    /* We are done with the fake lstat.  Go back to the real lstat */
37+#   ifdef lstat
38+#     undef lstat
39+#   endif
40+# endif
41+# define local_lstat lstat
42+#elif defined(WINDOWS32)
43+/* Windows doesn't support lstat().  */
44+# define local_lstat local_stat
45+#else
46+static int
47+local_lstat (const char *path, struct stat *buf)
48+{
49+  int e;
50+  EINTRLOOP (e, lstat (path, buf));
51+  return e;
52+}
53+#endif
54+
55 void
56 dir_setup_glob (glob_t *gl)
57 {
58   gl->gl_opendir = open_dirstream;
59   gl->gl_readdir = read_dirstream;
60   gl->gl_closedir = free;
61+  gl->gl_lstat = local_lstat;
62   gl->gl_stat = local_stat;
63-  /* We don't bother setting gl_lstat, since glob never calls it.
64-     The slot is only there for compatibility with 4.4 BSD.  */
65 }
66
67 void
68--
692.21.0
70
71