summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2019-08-16 14:06:04 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-21 15:29:02 +0100
commitfb20d734612d403b3e41a1a781714fd5f63f7e35 (patch)
treeb3e4c200161b65d85798005202aaa1ff62314292 /meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch
parent10d40f5971fd64810d0256bfbe175b717398ef03 (diff)
downloadpoky-fb20d734612d403b3e41a1a781714fd5f63f7e35.tar.gz
cross-localedef-native: Add hardlink resolver from util-linux
The hard link resolver that is built into localedef cannot be run in parallel. It will search sibling directories (which are be processed in parallel) and perform a creation of a .tmp file and remove the original and move the .tmp file in. The problem is that if a probe occurs a hard link can be requested to the file that is being removed. This will lead to a stray copy or potentially, on a loaded system cause race condition which pseudo cannot deal with, where it is left with a hard link request to a file that no longer exists. In this situation psuedo will inherit the permissions of what ever the target inode had to offer. In short, there are two problems: 1) You will be left with stray copies when using the hard link resolution that is built in while running in parallel with localedef. 2) When running under pseudo the possibility exists for uid/gid leakage when the source file is removed before the hard link can be completed. The solution is to call localedef with --no-hard-links and separately process the hardlinks at a later point. To do this requires the inclusion of the hardlink utility found in modern versions of util-linux. Most host systems do not have this, so it will be included with the cross-localedef binary. There are two patches here. The first imports the raw version of hardlink.c and a couple of header files directly from util-linux. The second patch applies the fix-ups to make it compile, along with a change to recipe to package the new binary. [YOCTO #11299] [YOCTO #12434] (From OE-Core rev: 57e2e498ffb675d274aa95b10c14bd81742d2761) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch')
-rw-r--r--meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch226
1 files changed, 226 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch b/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch
new file mode 100644
index 0000000000..1148ebfcc7
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch
@@ -0,0 +1,226 @@
1---
2 locale/programs/c.h | 2
3 locale/programs/cross-localedef-hardlink.c | 79 +++++++++++++----------------
4 2 files changed, 39 insertions(+), 42 deletions(-)
5
6--- a/locale/programs/cross-localedef-hardlink.c
7+++ b/locale/programs/cross-localedef-hardlink.c
8@@ -20,6 +20,8 @@
9 * with this program; if not, write to the Free Software Foundation, Inc.,
10 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
11 */
12+
13+#undef HAVE_PCRE
14 #include <sys/types.h>
15 #include <stdlib.h>
16 #include <getopt.h>
17@@ -38,8 +40,8 @@
18
19 #include "c.h"
20 #include "xalloc.h"
21-#include "nls.h"
22-#include "closestream.h"
23+//#include "nls.h"
24+//#include "closestream.h"
25
26 #define NHASH (1<<17) /* Must be a power of 2! */
27 #define NBUF 64
28@@ -124,33 +126,33 @@ static void print_summary(void)
29 if (ctl->verbose > 1 && ctl->nlinks)
30 fputc('\n', stdout);
31
32- printf(_("Directories: %9lld\n"), ctl->ndirs);
33- printf(_("Objects: %9lld\n"), ctl->nobjects);
34- printf(_("Regular files: %9lld\n"), ctl->nregfiles);
35- printf(_("Comparisons: %9lld\n"), ctl->ncomp);
36+ printf(("Directories: %9lld\n"), ctl->ndirs);
37+ printf(("Objects: %9lld\n"), ctl->nobjects);
38+ printf(("Regular files: %9lld\n"), ctl->nregfiles);
39+ printf(("Comparisons: %9lld\n"), ctl->ncomp);
40 printf( "%s%9lld\n", (ctl->no_link ?
41- _("Would link: ") :
42- _("Linked: ")), ctl->nlinks);
43+ ("Would link: ") :
44+ ("Linked: ")), ctl->nlinks);
45 printf( "%s %9lld\n", (ctl->no_link ?
46- _("Would save: ") :
47- _("Saved: ")), ctl->nsaved);
48+ ("Would save: ") :
49+ ("Saved: ")), ctl->nsaved);
50 }
51
52 static void __attribute__((__noreturn__)) usage(void)
53 {
54 fputs(USAGE_HEADER, stdout);
55- printf(_(" %s [options] directory...\n"), program_invocation_short_name);
56+ printf((" %s [options] directory...\n"), program_invocation_short_name);
57
58 fputs(USAGE_SEPARATOR, stdout);
59- puts(_("Consolidate duplicate files using hardlinks."));
60+ puts(("Consolidate duplicate files using hardlinks."));
61
62 fputs(USAGE_OPTIONS, stdout);
63- puts(_(" -c, --content compare only contents, ignore permission, etc."));
64- puts(_(" -n, --dry-run don't actually link anything"));
65- puts(_(" -v, --verbose print summary after hardlinking"));
66- puts(_(" -vv print every hardlinked file and summary"));
67- puts(_(" -f, --force force hardlinking across filesystems"));
68- puts(_(" -x, --exclude <regex> exclude files matching pattern"));
69+ puts((" -c, --content compare only contents, ignore permission, etc."));
70+ puts((" -n, --dry-run don't actually link anything"));
71+ puts((" -v, --verbose print summary after hardlinking"));
72+ puts((" -vv print every hardlinked file and summary"));
73+ puts((" -f, --force force hardlinking across filesystems"));
74+ puts((" -x, --exclude <regex> exclude files matching pattern"));
75
76 fputs(USAGE_SEPARATOR, stdout);
77 printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */
78@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size
79 size_t sum = a + b;
80
81 if (sum < a)
82- errx(EXIT_FAILURE, _("integer overflow"));
83+ errx(EXIT_FAILURE, ("integer overflow"));
84 return sum;
85 }
86
87@@ -193,7 +195,7 @@ static void process_path(struct hardlink
88 if (st.st_dev != ctl->dev && !ctl->force) {
89 if (ctl->dev)
90 errx(EXIT_FAILURE,
91- _("%s is on different filesystem than the rest "
92+ ("%s is on different filesystem than the rest "
93 "(use -f option to override)."), name);
94 ctl->dev = st.st_dev;
95 }
96@@ -287,9 +289,9 @@ static void process_path(struct hardlink
97 (ssize_t) sizeof(ctl->iobuf1) : fsize;
98
99 if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize)
100- warn(_("cannot read %s"), name);
101+ warn(("cannot read %s"), name);
102 else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize)
103- warn(_("cannot read %s"), fp2->name);
104+ warn(("cannot read %s"), fp2->name);
105
106 if (xsz != rsize) {
107 close(fd);
108@@ -303,13 +305,13 @@ static void process_path(struct hardlink
109 if (fsize > 0)
110 continue;
111 if (lstat(name, &st3)) {
112- warn(_("cannot stat %s"), name);
113+ warn(("cannot stat %s"), name);
114 close(fd);
115 return;
116 }
117 st3.st_atime = st.st_atime;
118 if (stcmp(&st, &st3, 0)) {
119- warnx(_("file %s changed underneath us"), name);
120+ warnx(("file %s changed underneath us"), name);
121 close(fd);
122 return;
123 }
124@@ -329,18 +331,18 @@ static void process_path(struct hardlink
125 suffixlen + 1);
126 /* First create a temporary link to n1 under a new name */
127 if (link(n1, nam2.buf)) {
128- warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"),
129+ warn(("failed to hardlink %s to %s (create temporary link as %s failed)"),
130 n1, n2, nam2.buf);
131 free(nam2.buf);
132 continue;
133 }
134 /* Then rename into place over the existing n2 */
135 if (rename(nam2.buf, n2)) {
136- warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"),
137+ warn(("failed to hardlink %s to %s (rename temporary link to %s failed)"),
138 n1, n2, n2);
139 /* Something went wrong, try to remove the now redundant temporary link */
140 if (unlink(nam2.buf))
141- warn(_("failed to remove temporary link %s"), nam2.buf);
142+ warn(("failed to remove temporary link %s"), nam2.buf);
143 free(nam2.buf);
144 continue;
145 }
146@@ -351,16 +353,16 @@ static void process_path(struct hardlink
147 /* We actually did not save anything this time, since the link second argument
148 had some other links as well. */
149 if (ctl->verbose > 1)
150- printf(_(" %s %s to %s\n"),
151- (ctl->no_link ? _("Would link") : _("Linked")),
152+ printf((" %s %s to %s\n"),
153+ (ctl->no_link ? ("Would link") : ("Linked")),
154 n1, n2);
155 } else {
156 ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096;
157 if (ctl->verbose > 1)
158- printf(_(" %s %s to %s, %s %jd\n"),
159- (ctl->no_link ? _("Would link") : _("Linked")),
160+ printf((" %s %s to %s, %s %jd\n"),
161+ (ctl->no_link ? ("Would link") : ("Linked")),
162 n1, n2,
163- (ctl->no_link ? _("would save") : _("saved")),
164+ (ctl->no_link ? ("would save") : ("saved")),
165 (intmax_t)st.st_size);
166 }
167 close(fd);
168@@ -410,11 +412,6 @@ int main(int argc, char **argv)
169 { NULL, 0, NULL, 0 },
170 };
171
172- setlocale(LC_ALL, "");
173- bindtextdomain(PACKAGE, LOCALEDIR);
174- textdomain(PACKAGE);
175- close_stdout_atexit();
176-
177 while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) {
178 switch (ch) {
179 case 'n':
180@@ -434,7 +431,7 @@ int main(int argc, char **argv)
181 exclude_pattern = (PCRE2_SPTR) optarg;
182 #else
183 errx(EXIT_FAILURE,
184- _("option --exclude not supported (built without pcre2)"));
185+ ("option --exclude not supported (built without pcre2)"));
186 #endif
187 break;
188 case 'V':
189@@ -447,7 +444,7 @@ int main(int argc, char **argv)
190 }
191
192 if (optind == argc) {
193- warnx(_("no directory specified"));
194+ warnx(("no directory specified"));
195 errtryhelp(EXIT_FAILURE);
196 }
197
198@@ -461,7 +458,7 @@ int main(int argc, char **argv)
199 PCRE2_UCHAR buffer[256];
200 pcre2_get_error_message(errornumber, buffer,
201 sizeof(buffer));
202- errx(EXIT_FAILURE, _("pattern error at offset %d: %s"),
203+ errx(EXIT_FAILURE, ("pattern error at offset %d: %s"),
204 (int)erroroffset, buffer);
205 }
206 match_data = pcre2_match_data_create_from_pattern(re, NULL);
207@@ -506,7 +503,7 @@ int main(int argc, char **argv)
208 >=0) {
209 if (ctl->verbose) {
210 nam1.buf[nam1baselen] = 0;
211- printf(_("Skipping %s%s\n"), nam1.buf, di->d_name);
212+ printf(("Skipping %s%s\n"), nam1.buf, di->d_name);
213 }
214 continue;
215 }
216--- a/locale/programs/c.h
217+++ b/locale/programs/c.h
218@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char add
219 /* Don't use inline function to avoid '#include "nls.h"' in c.h
220 */
221 #define errtryhelp(eval) __extension__ ({ \
222- fprintf(stderr, _("Try '%s --help' for more information.\n"), \
223+ fprintf(stderr, ("Try '%s --help' for more information.\n"), \
224 program_invocation_short_name); \
225 exit(eval); \
226 })