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