Dash:
[t2.git] / package / base / glibc / ldconfig-glob.patch
blobd9b2016267cdc53d44454491dcec9d78eca33983
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/*/glibc/ldconfig-glob.patch
5 # Copyright (C) 2004 - 2021 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 This is an alternative ldconfig wildcard expansion (glob) patch for
18 recent glibc's.
20 - Valentin Ziegler <valentin@exactcode.de>
22 --- glibc-2.33/elf/ldconfig.c.vanilla 2021-02-02 13:02:34.684800081 +0100
23 +++ glibc-2.33/elf/ldconfig.c 2021-02-02 13:25:04.253869704 +0100
24 @@ -508,23 +508,56 @@
25 if (opt_chroot)
26 path = chroot_canon (opt_chroot, path);
28 - struct stat64 stat_buf;
29 - if (path == NULL || stat64 (path, &stat_buf))
30 - {
31 - if (opt_verbose)
32 - error (0, errno, _("Can't stat %s"), entry->path);
33 - free (entry->path);
34 - free (entry);
35 - }
36 - else
37 - {
38 - entry->ino = stat_buf.st_ino;
39 - entry->dev = stat_buf.st_dev;
40 + /* assume path is a pattern */
41 + glob_t result;
42 + if (glob(path, GLOB_ONLYDIR, NULL, &result) == 0) {
43 + for (int j = 0; j < result.gl_pathc; j++)
44 + {
45 + /* create a copy entry with expanded path */
46 + struct dir_entry *real_entry = xmalloc (sizeof (struct dir_entry));
47 + memcpy (real_entry, entry, sizeof (struct dir_entry));
48 + real_entry->path = xstrdup (result.gl_pathv[j]);
50 - if (add_single_dir (entry, 1))
51 - /* Add glibc-hwcaps subdirectories if present. */
52 - add_glibc_hwcaps_subdirectories (entry, path);
53 - }
54 + struct stat64 stat_buf;
55 + if (real_entry->path == NULL || stat64 (real_entry->path, &stat_buf))
56 + {
57 + if (opt_verbose)
58 + error (0, errno, _("Can't stat %s"), real_entry->path);
59 + free (real_entry->path);
60 + free (real_entry);
61 + }
62 + else
63 + {
64 + real_entry->ino = stat_buf.st_ino;
65 + real_entry->dev = stat_buf.st_dev;
67 + if (add_single_dir (real_entry, 1))
68 + /* Add glibc-hwcaps subdirectories if present. */
69 + add_glibc_hwcaps_subdirectories (real_entry, real_entry->path);
70 + }
71 + }
72 + } else {
73 + /* fallback to code from glibc with orig. error handling */
74 + struct stat64 stat_buf;
75 + if (path == NULL || stat64 (path, &stat_buf))
76 + {
77 + if (opt_verbose)
78 + error (0, errno, _("Can't stat %s"), entry->path);
79 + free (entry->path);
80 + free (entry);
81 + }
82 + else
83 + {
84 + entry->ino = stat_buf.st_ino;
85 + entry->dev = stat_buf.st_dev;
87 + if (add_single_dir (entry, 1))
88 + /* Add glibc-hwcaps subdirectories if present. */
89 + add_glibc_hwcaps_subdirectories (entry, path);
90 + }
91 + }
93 + globfree (&result);
95 if (opt_chroot)
96 free (path);