1 |
commit: 2818707d8a7f87ddc2ccfbd3c6d99e9578f31854 |
2 |
Author: Michael Haubenwallner <haubi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Nov 29 09:37:54 2017 +0000 |
4 |
Commit: Michael Haubenwallner <haubi <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Nov 29 09:37:54 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=2818707d |
7 |
|
8 |
sys-apps/coreutils: update cygwin patch for 8.28 |
9 |
|
10 |
Thanks to: Egor Y. Egorov, for the updated patch. |
11 |
Closes: https://bugs.gentoo.org/638816 |
12 |
Package-Manager: Portage-2.3.10-prefix, Repoman-2.3.3 |
13 |
|
14 |
sys-apps/coreutils/coreutils-8.28-r1.ebuild | 2 +- |
15 |
.../files/coreutils-8.28-cygwin-8.26-3.patch | 1043 ++++++++++++++++++++ |
16 |
2 files changed, 1044 insertions(+), 1 deletion(-) |
17 |
|
18 |
diff --git a/sys-apps/coreutils/coreutils-8.28-r1.ebuild b/sys-apps/coreutils/coreutils-8.28-r1.ebuild |
19 |
index fc63a2986a..5f96825a94 100644 |
20 |
--- a/sys-apps/coreutils/coreutils-8.28-r1.ebuild |
21 |
+++ b/sys-apps/coreutils/coreutils-8.28-r1.ebuild |
22 |
@@ -86,7 +86,7 @@ src_prepare() { |
23 |
Makefile.in \ |
24 |
|| die |
25 |
elif use elibc_Cygwin ; then |
26 |
- epatch "${FILESDIR}"/${P}-cygwin-3.patch |
27 |
+ epatch "${FILESDIR}"/${P}-cygwin-8.26-3.patch |
28 |
sed -i -e 's|\(libstdbuf\.so\)$(EXEEXT)|\1|g' Makefile.in || die |
29 |
fi |
30 |
sed -i \ |
31 |
|
32 |
diff --git a/sys-apps/coreutils/files/coreutils-8.28-cygwin-8.26-3.patch b/sys-apps/coreutils/files/coreutils-8.28-cygwin-8.26-3.patch |
33 |
new file mode 100644 |
34 |
index 0000000000..20bfe76b3d |
35 |
--- /dev/null |
36 |
+++ b/sys-apps/coreutils/files/coreutils-8.28-cygwin-8.26-3.patch |
37 |
@@ -0,0 +1,1043 @@ |
38 |
+This was a copy of coreutils-8.25-3.src.patch from the official Cygwin |
39 |
+coreutils-8.25-3 source package, modified to avoid re-running autotools: |
40 |
+ |
41 |
+* Hunks for ./configure.ac go to ./configure instead. |
42 |
+* Hunks for ./lib/local.mk go to ./Makefile.in instead. |
43 |
+ |
44 |
+It has been updated to apply to coreutils-8.28 by Egor Y. Egorov, provided |
45 |
+in Gentoo Bug report https://bugs.gentoo.org/638816. |
46 |
+ |
47 |
+Once there is an official Cygwin source package for 8.28 or newer, we |
48 |
+probably want to import their patch again. |
49 |
+ |
50 |
+--- coreutils-8.28_prep/configure 2017-09-02 07:54:54.000000000 +0600 |
51 |
++++ coreutils-8.28_prep/configure 2017-11-20 10:58:06.601585900 +0600 |
52 |
+@@ -65498,7 +65498,8 @@ |
53 |
+ # Put this message here, after gl_WARN_ADD's chatter. |
54 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether this system supports stdbuf" >&5 |
55 |
+ $as_echo_n "checking whether this system supports stdbuf... " >&6; } |
56 |
+-CFLAGS="-fPIC $CFLAGS" |
57 |
++# -fPIC on cygwin is a warning |
58 |
++# CFLAGS="-fPIC $CFLAGS" |
59 |
+ LDFLAGS="-shared $LDFLAGS" |
60 |
+ stdbuf_supported=no |
61 |
+ # Note we only LINK here rather than RUN to support cross compilation |
62 |
+@@ -65530,7 +65531,7 @@ |
63 |
+ conftest$ac_exeext conftest.$ac_ext |
64 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $stdbuf_supported" >&5 |
65 |
+ $as_echo "$stdbuf_supported" >&6; } |
66 |
+-if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then |
67 |
++if test "$stdbuf_supported" = "yes"; then |
68 |
+ { |
69 |
+ if test -z "$optional_bin_progs"; then |
70 |
+ optional_bin_progs=stdbuf |
71 |
+--- coreutils-8.28_prep/lib/cygwin.c 1970-01-01 06:00:00.000000000 +0600 |
72 |
++++ coreutils-8.28_prep/lib/cygwin.c 2017-11-20 15:52:51.569827000 +0600 |
73 |
+@@ -0,0 +1,73 @@ |
74 |
++/* cygwin.c - helper functions unique to Cygwin |
75 |
++ |
76 |
++ Copyright (C) 2005, 2006, 2008, 2011 Free Software Foundation, Inc. |
77 |
++ |
78 |
++ This program is free software; you can redistribute it and/or modify |
79 |
++ it under the terms of the GNU General Public License as published by |
80 |
++ the Free Software Foundation; either version 3, or (at your option) |
81 |
++ any later version. |
82 |
++ |
83 |
++ This program is distributed in the hope that it will be useful, |
84 |
++ but WITHOUT ANY WARRANTY; without even the implied warranty of |
85 |
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
86 |
++ GNU General Public License for more details. |
87 |
++ |
88 |
++ You should have received a copy of the GNU General Public License |
89 |
++ along with this program; if not, write to the Free Software Foundation, |
90 |
++ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
91 |
++ |
92 |
++ Written by Eric Blake. */ |
93 |
++ |
94 |
++#include <config.h> |
95 |
++ |
96 |
++#include "cygwin.h" |
97 |
++ |
98 |
++#include <errno.h> |
99 |
++#include <limits.h> |
100 |
++#include <string.h> |
101 |
++#include <unistd.h> |
102 |
++ |
103 |
++/* Return -1 if PATH is not found, 0 if PATH will not have .exe |
104 |
++ appended (it is possible that a PATH that does not exist still |
105 |
++ returns 0 instead of -1, or fails for a PATH that exists but cannot |
106 |
++ be stat'ed), and positive if PATH has ".exe" automatically appended |
107 |
++ by cygwin (1 if PATH is a symlink, 2 otherwise). Won't change errno. */ |
108 |
++ |
109 |
++int |
110 |
++cygwin_spelling (char const *path) |
111 |
++{ |
112 |
++ int saved_errno = errno; |
113 |
++ int result = 0; /* Start with assumption that PATH is okay. */ |
114 |
++ size_t len; |
115 |
++ struct stat st1; |
116 |
++ struct stat st2; |
117 |
++ char *path_exe; |
118 |
++ |
119 |
++ /* If PATH will cause EINVAL or ENAMETOOLONG, treat it as missing. */ |
120 |
++ if (! path || ! *path) |
121 |
++ return -1; |
122 |
++ if (PATH_MAX < (len = strlen (path))) |
123 |
++ return -1; |
124 |
++ /* Don't change spelling if there is a trailing `/' or '.exe'. */ |
125 |
++ if (path[len - 1] == '/' |
126 |
++ || (len > 4 && !strcasecmp (&path[len - 4], ".exe"))) |
127 |
++ return 0; |
128 |
++ if (lstat (path, &st1) < 0) |
129 |
++ { |
130 |
++ errno = saved_errno; |
131 |
++ return -1; |
132 |
++ } |
133 |
++ if (S_ISDIR(st1.st_mode)) |
134 |
++ { |
135 |
++ errno = saved_errno; |
136 |
++ return 0; |
137 |
++ } |
138 |
++ path_exe = malloca (len + 5); /* adding ".exe" and NUL. */ |
139 |
++ strcat (stpcpy (path_exe, path), ".exe"); |
140 |
++ if (lstat (path_exe, &st2) == 0 && st1.st_ino == st2.st_ino) |
141 |
++ result = 1 + !S_ISLNK(st1.st_mode); |
142 |
++ freea (path_exe); |
143 |
++ |
144 |
++ errno = saved_errno; |
145 |
++ return result; |
146 |
++} |
147 |
+--- coreutils-8.28_prep/lib/cygwin.h 1970-01-01 06:00:00.000000000 +0600 |
148 |
++++ coreutils-8.28_prep/lib/cygwin.h 2017-11-20 15:52:51.571832900 +0600 |
149 |
+@@ -0,0 +1,38 @@ |
150 |
++/* cygwin.h - helper functions unique to Cygwin |
151 |
++ |
152 |
++ Copyright (C) 2005, 2006, 2008, 2010, 2011 Free Software Foundation, Inc. |
153 |
++ |
154 |
++ This program is free software; you can redistribute it and/or modify |
155 |
++ it under the terms of the GNU General Public License as published by |
156 |
++ the Free Software Foundation; either version 3, or (at your option) |
157 |
++ any later version. |
158 |
++ |
159 |
++ This program is distributed in the hope that it will be useful, |
160 |
++ but WITHOUT ANY WARRANTY; without even the implied warranty of |
161 |
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
162 |
++ GNU General Public License for more details. |
163 |
++ |
164 |
++ You should have received a copy of the GNU General Public License |
165 |
++ along with this program; if not, write to the Free Software Foundation, |
166 |
++ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
167 |
++ |
168 |
++ Written by Eric Blake. */ |
169 |
++ |
170 |
++#ifndef CYGWIN_H |
171 |
++# define CYGWIN_H 1 |
172 |
++ |
173 |
++#include "malloca.h" |
174 |
++ |
175 |
++int cygwin_spelling (char const *); |
176 |
++ |
177 |
++/* Append ".exe" to char *__NAME_ORIG, where __NAME is either NULL or |
178 |
++ between __NAME_ORIG and the nul terminator. Both params will be |
179 |
++ evaluated more than once and assigned the new value. The user must |
180 |
++ later call freea(__NAME). */ |
181 |
++#define CYGWIN_APPEND_EXE(__name, __name_orig) \ |
182 |
++ __name_orig = __name = \ |
183 |
++ strcat (strcpy (malloca (strchr (__name ? __name : __name_orig, '\0') \ |
184 |
++ - (__name_orig) + 5), \ |
185 |
++ __name_orig), ".exe") |
186 |
++ |
187 |
++#endif /* CYGWIN_H */ |
188 |
+--- coreutils-8.28_prep/lib/hash-pjw.c 2017-09-01 13:12:43.000000000 +0600 |
189 |
++++ coreutils-8.28_prep/lib/hash-pjw.c 2017-11-20 10:58:06.617214500 +0600 |
190 |
+@@ -19,6 +19,7 @@ |
191 |
+ |
192 |
+ #include "hash-pjw.h" |
193 |
+ |
194 |
++#include <ctype.h> |
195 |
+ #include <limits.h> |
196 |
+ |
197 |
+ #define SIZE_BITS (sizeof (size_t) * CHAR_BIT) |
198 |
+@@ -38,3 +39,16 @@ |
199 |
+ |
200 |
+ return h % tablesize; |
201 |
+ } |
202 |
++ |
203 |
++/* Likewise, but case-insensitive. */ |
204 |
++size_t |
205 |
++hash_pjw_case (const void *x, size_t tablesize) |
206 |
++{ |
207 |
++ const unsigned char *s; |
208 |
++ size_t h = 0; |
209 |
++ |
210 |
++ for (s = x; *s; s++) |
211 |
++ h = tolower (*s) + ((h << 9) | (h >> (SIZE_BITS - 9))); |
212 |
++ |
213 |
++ return h % tablesize; |
214 |
++} |
215 |
+--- coreutils-8.28_prep/lib/hash-pjw.h 2017-09-01 13:12:43.000000000 +0600 |
216 |
++++ coreutils-8.28_prep/lib/hash-pjw.h 2017-11-20 10:58:06.617214500 +0600 |
217 |
+@@ -21,3 +21,4 @@ |
218 |
+ The result is platform dependent: it depends on the size of the 'size_t' |
219 |
+ type and on the signedness of the 'char' type. */ |
220 |
+ extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; |
221 |
++extern size_t hash_pjw_case (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; |
222 |
+--- coreutils-8.28_prep/lib/hash-triple.c 2017-09-01 13:12:43.000000000 +0600 |
223 |
++++ coreutils-8.28_prep/lib/hash-triple.c 2017-11-20 10:58:06.617214500 +0600 |
224 |
+@@ -34,7 +34,13 @@ |
225 |
+ triple_hash (void const *x, size_t table_size) |
226 |
+ { |
227 |
+ struct F_triple const *p = x; |
228 |
++#if !__CYGWIN__ |
229 |
+ size_t tmp = hash_pjw (p->name, table_size); |
230 |
++#else // cygwin |
231 |
++ /* Hash case-insensitively, to force collisions on names that differ by |
232 |
++ case; copy.c can then account for case-insensitive renames. */ |
233 |
++ size_t tmp = hash_pjw_case (p->name, table_size); |
234 |
++#endif |
235 |
+ |
236 |
+ /* Ignoring the device number here should be fine. */ |
237 |
+ return (tmp ^ p->st_ino) % table_size; |
238 |
+--- coreutils-8.28_prep/lib/root-dev-ino.c 2017-09-01 13:11:03.000000000 +0600 |
239 |
++++ coreutils-8.28_prep/lib/root-dev-ino.c 2017-11-20 10:58:06.617214500 +0600 |
240 |
+@@ -25,13 +25,17 @@ |
241 |
+ /* Call lstat to get the device and inode numbers for '/'. |
242 |
+ Upon failure, return NULL. Otherwise, set the members of |
243 |
+ *ROOT_D_I accordingly and return ROOT_D_I. */ |
244 |
+-struct dev_ino * |
245 |
+-get_root_dev_ino (struct dev_ino *root_d_i) |
246 |
++struct root_dev_ino * |
247 |
++get_root_dev_ino (struct root_dev_ino *root_d_i) |
248 |
+ { |
249 |
+ struct stat statbuf; |
250 |
+ if (lstat ("/", &statbuf)) |
251 |
+ return NULL; |
252 |
+- root_d_i->st_ino = statbuf.st_ino; |
253 |
+- root_d_i->st_dev = statbuf.st_dev; |
254 |
++ root_d_i->single_slash.st_ino = statbuf.st_ino; |
255 |
++ root_d_i->single_slash.st_dev = statbuf.st_dev; |
256 |
++ if (lstat ("//", &statbuf)) |
257 |
++ return NULL; |
258 |
++ root_d_i->double_slash.st_ino = statbuf.st_ino; |
259 |
++ root_d_i->double_slash.st_dev = statbuf.st_dev; |
260 |
+ return root_d_i; |
261 |
+ } |
262 |
+--- coreutils-8.28_prep/lib/root-dev-ino.h 2017-09-01 13:11:03.000000000 +0600 |
263 |
++++ coreutils-8.28_prep/lib/root-dev-ino.h 2017-11-20 10:58:06.617214500 +0600 |
264 |
+@@ -21,19 +21,26 @@ |
265 |
+ # include "dev-ino.h" |
266 |
+ # include "same-inode.h" |
267 |
+ |
268 |
+-struct dev_ino * |
269 |
+-get_root_dev_ino (struct dev_ino *root_d_i); |
270 |
++struct root_dev_ino |
271 |
++{ |
272 |
++ struct dev_ino single_slash; |
273 |
++ struct dev_ino double_slash; |
274 |
++}; |
275 |
++ |
276 |
++struct root_dev_ino * |
277 |
++get_root_dev_ino (struct root_dev_ino *root_d_i); |
278 |
+ |
279 |
+ /* These macros are common to the programs that support the |
280 |
+ --preserve-root and --no-preserve-root options. */ |
281 |
+ |
282 |
+ # define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \ |
283 |
+- (Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino)) |
284 |
++ (Root_dev_ino && (SAME_INODE (*Dir_statbuf, (Root_dev_ino)->single_slash) \ |
285 |
++ || SAME_INODE (*Dir_statbuf, (Root_dev_ino)->double_slash))) |
286 |
+ |
287 |
+ # define ROOT_DEV_INO_WARN(Dirname) \ |
288 |
+ do \ |
289 |
+ { \ |
290 |
+- if (STREQ (Dirname, "/")) \ |
291 |
++ if (STREQ (Dirname, "/") || STREQ (Dirname, "//")) \ |
292 |
+ error (0, 0, _("it is dangerous to operate recursively on %s"), \ |
293 |
+ quoteaf (Dirname)); \ |
294 |
+ else \ |
295 |
+--- coreutils-8.28_prep/lib/same.c 2017-09-01 13:12:43.000000000 +0600 |
296 |
++++ coreutils-8.28_prep/lib/same.c 2017-11-20 10:58:06.617214500 +0600 |
297 |
+@@ -40,6 +40,13 @@ |
298 |
+ #include "error.h" |
299 |
+ #include "same-inode.h" |
300 |
+ |
301 |
++#if __CYGWIN__ |
302 |
++# include <sys/cygwin.h> |
303 |
++# include "cygwin.h" |
304 |
++# include "malloca.h" |
305 |
++# include "memcasecmp.h" |
306 |
++#endif |
307 |
++ |
308 |
+ #ifndef MIN |
309 |
+ # define MIN(a, b) ((a) < (b) ? (a) : (b)) |
310 |
+ #endif |
311 |
+@@ -59,6 +66,45 @@ |
312 |
+ (source_baselen == dest_baselen |
313 |
+ && memcmp (source_basename, dest_basename, dest_baselen) == 0); |
314 |
+ bool compare_dirs = identical_basenames; |
315 |
++#if __CYGWIN__ |
316 |
++ /* If two names differ case-insensitively by only an '.exe' suffix, |
317 |
++ do some sleuthing to see if .exe magic matters on the shorter |
318 |
++ name. Swapping the longer name to dest avoids duplication. */ |
319 |
++ if (source_baselen == dest_baselen + 4) |
320 |
++ { |
321 |
++ char const *tmp_basename = source_basename; |
322 |
++ size_t tmp_baselen = source_baselen; |
323 |
++ source_basename = dest_basename; |
324 |
++ source_baselen = dest_baselen; |
325 |
++ dest_basename = tmp_basename; |
326 |
++ dest_baselen = tmp_baselen; |
327 |
++ } |
328 |
++ if (source_baselen + 4 == dest_baselen |
329 |
++ && !memcasecmp (dest_basename - 4, ".exe", 4) |
330 |
++ && !memcasecmp (source_basename, dest_basename, source_baselen) |
331 |
++ && 0 < cygwin_spelling(source)) |
332 |
++ dest_baselen -= 4; |
333 |
++ /* Some, but not all, files are case-insensitive (depending on mount |
334 |
++ options, CYGWIN=case settings, and virtual file systems). Do |
335 |
++ some sleuthing to decide whether case-insensitivity matters. */ |
336 |
++ if (! compare_dirs && source_baselen == dest_baselen) |
337 |
++ { |
338 |
++ ssize_t wsrclen = cygwin_conv_path (CCP_POSIX_TO_WIN_W, |
339 |
++ source, NULL, 0); |
340 |
++ ssize_t wdstlen = cygwin_conv_path (CCP_POSIX_TO_WIN_W, |
341 |
++ dest, NULL, 0); |
342 |
++ char *wsrc = malloca (wsrclen); |
343 |
++ char *wdst = malloca (wdstlen); |
344 |
++ if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, source, wsrc, wsrclen)) |
345 |
++ error (EXIT_FAILURE, errno, "unable to convert path name %s", source); |
346 |
++ if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, dest, wdst, wdstlen)) |
347 |
++ error (EXIT_FAILURE, errno, "unable to convert path name %s", dest); |
348 |
++ if (wsrclen == wdstlen && memcasecmp (wsrc, wdst, wsrclen) == 0) |
349 |
++ compare_dirs = true; |
350 |
++ freea (wsrc); |
351 |
++ freea (wdst); |
352 |
++ } |
353 |
++#endif /* __CYGWIN__ */ |
354 |
+ bool same = false; |
355 |
+ |
356 |
+ #if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX |
357 |
+--- coreutils-8.28_prep/Makefile.in 2017-11-20 10:37:56.336452400 +0600 |
358 |
++++ coreutils-8.28_prep/Makefile.in 2017-11-20 10:58:06.632817000 +0600 |
359 |
+@@ -710,7 +710,8 @@ |
360 |
+ lib/xstrndup.h lib/xstrndup.c lib/xstrtod.c lib/xstrtoimax.c \ |
361 |
+ lib/xstrtol.c lib/xstrtoul.c lib/xstrtol-error.c \ |
362 |
+ lib/xstrtold.c lib/xstrtoumax.c lib/xvasprintf.h \ |
363 |
+- lib/xvasprintf.c lib/xasprintf.c lib/yesno.c |
364 |
++ lib/xvasprintf.c lib/xasprintf.c lib/yesno.c \ |
365 |
++ lib/cygwin.c lib/cygwin.h |
366 |
+ am__dirstamp = $(am__leading_dot)dirstamp |
367 |
+ @LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE@am__objects_1 = lib/unistr/u8-mbtoucr.$(OBJEXT) |
368 |
+ @LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE@am__objects_2 = lib/unistr/u8-uctomb.$(OBJEXT) \ |
369 |
+@@ -819,7 +820,8 @@ |
370 |
+ lib/xstrtol.$(OBJEXT) lib/xstrtoul.$(OBJEXT) \ |
371 |
+ lib/xstrtol-error.$(OBJEXT) lib/xstrtold.$(OBJEXT) \ |
372 |
+ lib/xstrtoumax.$(OBJEXT) lib/xvasprintf.$(OBJEXT) \ |
373 |
+- lib/xasprintf.$(OBJEXT) lib/yesno.$(OBJEXT) |
374 |
++ lib/xasprintf.$(OBJEXT) lib/yesno.$(OBJEXT) \ |
375 |
++ lib/cygwin.$(OBJEXT) |
376 |
+ lib_libcoreutils_a_OBJECTS = $(am_lib_libcoreutils_a_OBJECTS) |
377 |
+ src_libsinglebin___a_AR = $(AR) $(ARFLAGS) |
378 |
+ src_libsinglebin___a_LIBADD = |
379 |
+@@ -4289,6 +4291,8 @@ |
380 |
+ # mv $@-t $@ |
381 |
+ #EXTRA_DIST += script.in |
382 |
+ #MOSTLYCLEANFILES += script script-t |
383 |
++ |
384 |
++# Hook in cygwin helper |
385 |
+ lib_libcoreutils_a_SOURCES = lib/copy-acl.c lib/set-acl.c \ |
386 |
+ lib/acl-errno-valid.c lib/acl-internal.c lib/get-permissions.c \ |
387 |
+ lib/set-permissions.c lib/allocator.c lib/areadlink.c \ |
388 |
+@@ -4367,7 +4371,8 @@ |
389 |
+ lib/xstrndup.h lib/xstrndup.c lib/xstrtod.c lib/xstrtoimax.c \ |
390 |
+ lib/xstrtol.c lib/xstrtoul.c lib/xstrtol-error.c \ |
391 |
+ lib/xstrtold.c lib/xstrtoumax.c lib/xvasprintf.h \ |
392 |
+- lib/xvasprintf.c lib/xasprintf.c lib/yesno.c |
393 |
++ lib/xvasprintf.c lib/xasprintf.c lib/yesno.c \ |
394 |
++ lib/cygwin.c lib/cygwin.h |
395 |
+ lib_libcoreutils_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@ |
396 |
+ lib_libcoreutils_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@ |
397 |
+ EXTRA_lib_libcoreutils_a_SOURCES = lib/acl_entries.c lib/alloca.c \ |
398 |
+@@ -6468,6 +6473,8 @@ |
399 |
+ lib/xasprintf.$(OBJEXT): lib/$(am__dirstamp) \ |
400 |
+ lib/$(DEPDIR)/$(am__dirstamp) |
401 |
+ lib/yesno.$(OBJEXT): lib/$(am__dirstamp) lib/$(DEPDIR)/$(am__dirstamp) |
402 |
++lib/cygwin.$(OBJEXT): lib/$(am__dirstamp) \ |
403 |
++ lib/$(DEPDIR)/$(am__dirstamp) |
404 |
+ lib/acl_entries.$(OBJEXT): lib/$(am__dirstamp) \ |
405 |
+ lib/$(DEPDIR)/$(am__dirstamp) |
406 |
+ lib/alloca.$(OBJEXT): lib/$(am__dirstamp) \ |
407 |
+@@ -8473,6 +8480,7 @@ |
408 |
+ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/copy-acl.Po@am__quote@ |
409 |
+ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/creat-safer.Po@am__quote@ |
410 |
+ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/cycle-check.Po@am__quote@ |
411 |
++@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/cygwin.Po@am__quote@ |
412 |
+ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/di-set.Po@am__quote@ |
413 |
+ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/diacrit.Po@am__quote@ |
414 |
+ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/dirchownmod.Po@am__quote@ |
415 |
+--- coreutils-8.28_prep/src/chcon.c 2017-09-01 13:11:03.000000000 +0600 |
416 |
++++ coreutils-8.28_prep/src/chcon.c 2017-11-20 10:58:06.648439500 +0600 |
417 |
+@@ -48,7 +48,7 @@ |
418 |
+ |
419 |
+ /* Pointer to the device and inode numbers of '/', when --recursive. |
420 |
+ Otherwise NULL. */ |
421 |
+-static struct dev_ino *root_dev_ino; |
422 |
++static struct root_dev_ino *root_dev_ino; |
423 |
+ |
424 |
+ /* The name of the context file is being given. */ |
425 |
+ static char const *specified_context; |
426 |
+@@ -570,7 +570,7 @@ |
427 |
+ |
428 |
+ if (recurse && preserve_root) |
429 |
+ { |
430 |
+- static struct dev_ino dev_ino_buf; |
431 |
++ static struct root_dev_ino dev_ino_buf; |
432 |
+ root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
433 |
+ if (root_dev_ino == NULL) |
434 |
+ die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), |
435 |
+--- coreutils-8.28_prep/src/chgrp.c 2017-09-01 13:11:03.000000000 +0600 |
436 |
++++ coreutils-8.28_prep/src/chgrp.c 2017-11-20 10:58:06.648439500 +0600 |
437 |
+@@ -301,7 +301,7 @@ |
438 |
+ |
439 |
+ if (chopt.recurse && preserve_root) |
440 |
+ { |
441 |
+- static struct dev_ino dev_ino_buf; |
442 |
++ static struct root_dev_ino dev_ino_buf; |
443 |
+ chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
444 |
+ if (chopt.root_dev_ino == NULL) |
445 |
+ die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), |
446 |
+--- coreutils-8.28_prep/src/chmod.c 2017-09-01 13:11:03.000000000 +0600 |
447 |
++++ coreutils-8.28_prep/src/chmod.c 2017-11-20 10:58:06.648439500 +0600 |
448 |
+@@ -81,7 +81,7 @@ |
449 |
+ |
450 |
+ /* Pointer to the device and inode numbers of '/', when --recursive. |
451 |
+ Otherwise NULL. */ |
452 |
+-static struct dev_ino *root_dev_ino; |
453 |
++static struct root_dev_ino *root_dev_ino; |
454 |
+ |
455 |
+ /* For long options that have no equivalent short option, use a |
456 |
+ non-character as a pseudo short option, starting with CHAR_MAX + 1. */ |
457 |
+@@ -552,7 +552,7 @@ |
458 |
+ |
459 |
+ if (recurse && preserve_root) |
460 |
+ { |
461 |
+- static struct dev_ino dev_ino_buf; |
462 |
++ static struct root_dev_ino dev_ino_buf; |
463 |
+ root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
464 |
+ if (root_dev_ino == NULL) |
465 |
+ die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), |
466 |
+--- coreutils-8.28_prep/src/chown.c 2017-09-01 13:11:03.000000000 +0600 |
467 |
++++ coreutils-8.28_prep/src/chown.c 2017-11-20 10:58:06.648439500 +0600 |
468 |
+@@ -313,7 +313,7 @@ |
469 |
+ |
470 |
+ if (chopt.recurse && preserve_root) |
471 |
+ { |
472 |
+- static struct dev_ino dev_ino_buf; |
473 |
++ static struct root_dev_ino dev_ino_buf; |
474 |
+ chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
475 |
+ if (chopt.root_dev_ino == NULL) |
476 |
+ die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), |
477 |
+--- coreutils-8.28_prep/src/chown-core.h 2017-09-01 13:11:03.000000000 +0600 |
478 |
++++ coreutils-8.28_prep/src/chown-core.h 2017-11-20 10:58:06.648439500 +0600 |
479 |
+@@ -50,7 +50,7 @@ |
480 |
+ |
481 |
+ /* Pointer to the device and inode numbers of '/', when --recursive. |
482 |
+ Need not be freed. Otherwise NULL. */ |
483 |
+- struct dev_ino *root_dev_ino; |
484 |
++ struct root_dev_ino *root_dev_ino; |
485 |
+ |
486 |
+ /* This corresponds to the --dereference (opposite of -h) option. */ |
487 |
+ bool affect_symlink_referent; |
488 |
+--- coreutils-8.28_prep/src/chroot.c 2017-09-01 13:11:03.000000000 +0600 |
489 |
++++ coreutils-8.28_prep/src/chroot.c 2017-11-20 10:58:06.648439500 +0600 |
490 |
+@@ -171,7 +171,8 @@ |
491 |
+ is_root (const char* dir) |
492 |
+ { |
493 |
+ char *resolved = canonicalize_file_name (dir); |
494 |
+- bool is_res_root = resolved && STREQ ("/", resolved); |
495 |
++ bool is_res_root = resolved && (STREQ ("/", resolved) |
496 |
++ || STREQ ("//", resolved)); |
497 |
+ free (resolved); |
498 |
+ return is_res_root; |
499 |
+ } |
500 |
+--- coreutils-8.28_prep/src/cksum.c 2017-09-01 13:11:03.000000000 +0600 |
501 |
++++ coreutils-8.28_prep/src/cksum.c 2017-11-20 17:26:50.616443600 +0600 |
502 |
+@@ -296,6 +296,9 @@ |
503 |
+ |
504 |
+ have_read_stdin = false; |
505 |
+ |
506 |
++ if (O_BINARY) |
507 |
++ xset_binary_mode (STDIN_FILENO, O_BINARY); |
508 |
++ |
509 |
+ if (optind == argc) |
510 |
+ ok = cksum ("-", false); |
511 |
+ else |
512 |
+--- coreutils-8.28_prep/src/copy.c 2017-09-01 13:11:03.000000000 +0600 |
513 |
++++ coreutils-8.28_prep/src/copy.c 2017-11-20 10:58:06.668078700 +0600 |
514 |
+@@ -85,6 +85,10 @@ |
515 |
+ # define FICLONE _IOW (0x94, 9, int) |
516 |
+ #endif |
517 |
+ |
518 |
++#if __CYGWIN__ |
519 |
++# include "cygwin.h" |
520 |
++#endif |
521 |
++ |
522 |
+ #ifndef HAVE_FCHOWN |
523 |
+ # define HAVE_FCHOWN false |
524 |
+ # define fchown(fd, uid, gid) (-1) |
525 |
+@@ -1423,7 +1427,11 @@ |
526 |
+ static bool |
527 |
+ same_file_ok (char const *src_name, struct stat const *src_sb, |
528 |
+ char const *dst_name, struct stat const *dst_sb, |
529 |
+- const struct cp_options *x, bool *return_now) |
530 |
++ const struct cp_options *x, bool *return_now |
531 |
++#if __CYGWIN__ |
532 |
++ , bool *case_change |
533 |
++#endif |
534 |
++ ) |
535 |
+ { |
536 |
+ const struct stat *src_sb_link; |
537 |
+ const struct stat *dst_sb_link; |
538 |
+@@ -1567,6 +1575,18 @@ |
539 |
+ if (S_ISLNK (dst_sb_link->st_mode)) |
540 |
+ return true; |
541 |
+ |
542 |
++#if __CYGWIN__ |
543 |
++ /* If the files have the same name, but differ in case, then let |
544 |
++ rename() change the case. */ |
545 |
++ if (same_link && x->move_mode && same_name (src_name, dst_name) |
546 |
++ && memcmp (last_component (src_name), last_component (dst_name), |
547 |
++ base_len (src_name))) |
548 |
++ { |
549 |
++ *case_change = true; |
550 |
++ return true; |
551 |
++ } |
552 |
++#endif /* __CYGWIN__ */ |
553 |
++ |
554 |
+ /* It's not ok if they're distinct hard links to the same file as |
555 |
+ this causes a race condition and we may lose data in this case. */ |
556 |
+ if (same_link |
557 |
+@@ -1922,10 +1942,20 @@ |
558 |
+ && ! (x->move_mode || x->symbolic_link || x->hard_link |
559 |
+ || x->backup_type != no_backups |
560 |
+ || x->unlink_dest_before_opening)); |
561 |
+- if ((use_stat |
562 |
+- ? stat (dst_name, &dst_sb) |
563 |
+- : lstat (dst_name, &dst_sb)) |
564 |
+- != 0) |
565 |
++ int res = (use_stat |
566 |
++ ? stat (dst_name, &dst_sb) |
567 |
++ : lstat (dst_name, &dst_sb)); |
568 |
++#if __CYGWIN__ |
569 |
++ /* stat("a") succeeds even if it was really "a.exe". */ |
570 |
++ if (! res && cygwin_spelling (dst_name) != 0) |
571 |
++ { |
572 |
++ /* Only DST_NAME.exe exists, but we want the non-existant |
573 |
++ DST_NAME. */ |
574 |
++ res = -1; |
575 |
++ errno = ENOENT; |
576 |
++ } |
577 |
++#endif /* __CYGWIN__ */ |
578 |
++ if (res != 0) |
579 |
+ { |
580 |
+ if (errno != ENOENT) |
581 |
+ { |
582 |
+@@ -1941,10 +1971,17 @@ |
583 |
+ { /* Here, we know that dst_name exists, at least to the point |
584 |
+ that it is stat'able or lstat'able. */ |
585 |
+ bool return_now; |
586 |
++#if __CYGWIN__ |
587 |
++ bool case_change = false; |
588 |
++#endif /* __CYGWIN__ */ |
589 |
+ |
590 |
+ have_dst_lstat = !use_stat; |
591 |
+ if (! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, |
592 |
+- x, &return_now)) |
593 |
++ x, &return_now |
594 |
++#if __CYGWIN__ |
595 |
++ , &case_change |
596 |
++#endif /* __CYGWIN__ */ |
597 |
++ )) |
598 |
+ { |
599 |
+ error (0, 0, _("%s and %s are the same file"), |
600 |
+ quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); |
601 |
+@@ -2003,6 +2040,9 @@ |
602 |
+ cp and mv treat -i and -f differently. */ |
603 |
+ if (x->move_mode) |
604 |
+ { |
605 |
++#if __CYGWIN__ |
606 |
++ if (!case_change) |
607 |
++#endif /* __CYGWIN__ */ |
608 |
+ if (abandon_move (x, dst_name, &dst_sb)) |
609 |
+ { |
610 |
+ /* Pretend the rename succeeded, so the caller (mv) |
611 |
+@@ -2144,7 +2184,11 @@ |
612 |
+ /* Never unlink dst_name when in move mode. */ |
613 |
+ && ! x->move_mode |
614 |
+ && (x->unlink_dest_before_opening |
615 |
+- || (x->preserve_links && 1 < dst_sb.st_nlink) |
616 |
++ || (x->preserve_links && 1 < dst_sb.st_nlink |
617 |
++#if __CYGWIN__ |
618 |
++ && !case_change |
619 |
++#endif /* __CYGWIN__ */ |
620 |
++ ) |
621 |
+ || (x->dereference == DEREF_NEVER |
622 |
+ && ! S_ISREG (src_sb.st_mode)) |
623 |
+ )) |
624 |
+@@ -2936,6 +2980,21 @@ |
625 |
+ { |
626 |
+ assert (valid_options (options)); |
627 |
+ |
628 |
++#if __CYGWIN__ |
629 |
++ /* .exe magic - if src exists with an implicit .exe suffix and is |
630 |
++ not a symlink, but dst does not exist and was also specified |
631 |
++ without a suffix, then append .exe to dst. */ |
632 |
++ int cygwin = cygwin_spelling (src_name); |
633 |
++ char *p; |
634 |
++ if (cygwin == 2 |
635 |
++ && ((p = strchr (dst_name, '\0') - 4) <= dst_name |
636 |
++ || strcasecmp (p, ".exe") != 0)) |
637 |
++ { |
638 |
++ cygwin = 3; |
639 |
++ CYGWIN_APPEND_EXE (p, dst_name); |
640 |
++ } |
641 |
++#endif /* __CYGWIN__ */ |
642 |
++ |
643 |
+ /* Record the file names: they're used in case of error, when copying |
644 |
+ a directory into itself. I don't like to make these tools do *any* |
645 |
+ extra work in the common case when that work is solely to handle |
646 |
+@@ -2947,10 +3006,15 @@ |
647 |
+ top_level_dst_name = dst_name; |
648 |
+ |
649 |
+ bool first_dir_created_per_command_line_arg = false; |
650 |
+- return copy_internal (src_name, dst_name, nonexistent_dst, NULL, NULL, |
651 |
++ bool result = copy_internal (src_name, dst_name, nonexistent_dst, NULL, NULL, |
652 |
+ options, true, |
653 |
+ &first_dir_created_per_command_line_arg, |
654 |
+ copy_into_self, rename_succeeded); |
655 |
++#if __CYGWIN__ |
656 |
++ if (cygwin == 3) |
657 |
++ freea ((char *) dst_name); |
658 |
++#endif /* __CYGWIN__ */ |
659 |
++ return result; |
660 |
+ } |
661 |
+ |
662 |
+ /* Set *X to the default options for a value of type struct cp_options. */ |
663 |
+--- coreutils-8.28_prep/src/dd.c 2017-09-01 13:11:03.000000000 +0600 |
664 |
++++ coreutils-8.28_prep/src/dd.c 2017-11-20 10:58:06.670586400 +0600 |
665 |
+@@ -37,6 +37,10 @@ |
666 |
+ #include "xstrtol.h" |
667 |
+ #include "xtime.h" |
668 |
+ |
669 |
++#if __CYGWIN__ |
670 |
++# include <io.h> |
671 |
++#endif |
672 |
++ |
673 |
+ /* The official name of this program (e.g., no 'g' prefix). */ |
674 |
+ #define PROGRAM_NAME "dd" |
675 |
+ |
676 |
+@@ -1991,6 +1995,13 @@ |
677 |
+ static void |
678 |
+ set_fd_flags (int fd, int add_flags, char const *name) |
679 |
+ { |
680 |
++#if __CYGWIN__ |
681 |
++ /* Cygwin does not allow fcntl to set the mode. */ |
682 |
++ int mode_flags = add_flags & (O_BINARY | O_TEXT); |
683 |
++ add_flags &= ~(O_BINARY | O_TEXT); |
684 |
++ if (mode_flags && setmode (fd, mode_flags) == -1) |
685 |
++ error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name)); |
686 |
++#endif /* __CYGWIN__ */ |
687 |
+ /* Ignore file creation flags that are no-ops on file descriptors. */ |
688 |
+ add_flags &= ~ (O_NOCTTY | O_NOFOLLOW); |
689 |
+ |
690 |
+@@ -2380,6 +2391,8 @@ |
691 |
+ } |
692 |
+ else |
693 |
+ { |
694 |
++ if ((input_flags & (O_BINARY | O_TEXT)) == 0) |
695 |
++ input_flags |= O_BINARY; |
696 |
+ if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0) |
697 |
+ die (EXIT_FAILURE, errno, _("failed to open %s"), |
698 |
+ quoteaf (input_file)); |
699 |
+@@ -2403,6 +2416,8 @@ |
700 |
+ | (conversions_mask & C_NOCREAT ? 0 : O_CREAT) |
701 |
+ | (conversions_mask & C_EXCL ? O_EXCL : 0) |
702 |
+ | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC)); |
703 |
++ if ((opts & (O_BINARY | O_TEXT)) == 0) |
704 |
++ opts |= O_BINARY; |
705 |
+ |
706 |
+ /* Open the output file with *read* access only if we might |
707 |
+ need to read to satisfy a 'seek=' request. If we can't read |
708 |
+--- coreutils-8.28_prep/src/dircolors.c 2017-09-01 13:11:03.000000000 +0600 |
709 |
++++ coreutils-8.28_prep/src/dircolors.c 2017-11-20 10:58:06.670586400 +0600 |
710 |
+@@ -496,8 +496,12 @@ |
711 |
+ } |
712 |
+ else |
713 |
+ { |
714 |
++ /* tcsh treats LS_COLORS as a magic shell variable for its |
715 |
++ builtin ls-F, but does not recognize all the categories |
716 |
++ that coreutils ls does. Therefore, silence stderr to |
717 |
++ avoid messages like "Unknown colorls variable `su'.". */ |
718 |
+ prefix = "setenv LS_COLORS '"; |
719 |
+- suffix = "'\n"; |
720 |
++ suffix = "' >&/dev/null\n"; |
721 |
+ } |
722 |
+ fputs (prefix, stdout); |
723 |
+ fwrite (s, 1, len, stdout); |
724 |
+--- coreutils-8.28_prep/src/install.c 2017-09-01 13:11:03.000000000 +0600 |
725 |
++++ coreutils-8.28_prep/src/install.c 2017-11-20 10:58:06.670586400 +0600 |
726 |
+@@ -45,6 +45,10 @@ |
727 |
+ #include "utimens.h" |
728 |
+ #include "xstrtol.h" |
729 |
+ |
730 |
++#if __CYGWIN__ |
731 |
++# include "cygwin.h" |
732 |
++#endif |
733 |
++ |
734 |
+ /* The official name of this program (e.g., no 'g' prefix). */ |
735 |
+ #define PROGRAM_NAME "install" |
736 |
+ |
737 |
+@@ -556,6 +560,16 @@ |
738 |
+ error (0, errno, _("fork system call failed")); |
739 |
+ break; |
740 |
+ case 0: /* Child. */ |
741 |
++#if __CYGWIN__ |
742 |
++ { |
743 |
++ /* Check for .exe here, since strip doesn't. */ |
744 |
++ char *p; |
745 |
++ if (((p = strchr (name, '\0') - 4) <= name |
746 |
++ || strcasecmp (p, ".exe") != 0) |
747 |
++ && 0 < cygwin_spelling (name)) |
748 |
++ CYGWIN_APPEND_EXE (p, name); |
749 |
++ } |
750 |
++#endif /* __CYGWIN__ */ |
751 |
+ execlp (strip_program, strip_program, name, NULL); |
752 |
+ die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program)); |
753 |
+ default: /* Parent. */ |
754 |
+--- coreutils-8.28_prep/src/ls.c 2017-09-01 13:11:03.000000000 +0600 |
755 |
++++ coreutils-8.28_prep/src/ls.c 2017-11-20 10:58:06.670586400 +0600 |
756 |
+@@ -121,6 +121,10 @@ |
757 |
+ # include <sys/capability.h> |
758 |
+ #endif |
759 |
+ |
760 |
++#if __CYGWIN__ |
761 |
++# include "cygwin.h" |
762 |
++#endif |
763 |
++ |
764 |
+ #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \ |
765 |
+ : (ls_mode == LS_MULTI_COL \ |
766 |
+ ? "dir" : "vdir")) |
767 |
+@@ -782,6 +786,11 @@ |
768 |
+ N_("%b %e %H:%M") |
769 |
+ }; |
770 |
+ |
771 |
++#if __CYGWIN__ |
772 |
++/* Whether .exe should be appended to command-line args as needed. */ |
773 |
++static bool append_exe; |
774 |
++#endif /* __CYGWIN__ */ |
775 |
++ |
776 |
+ /* The set of signals that are caught. */ |
777 |
+ |
778 |
+ static sigset_t caught_signals; |
779 |
+@@ -817,6 +826,9 @@ |
780 |
+ enum |
781 |
+ { |
782 |
+ AUTHOR_OPTION = CHAR_MAX + 1, |
783 |
++#if __CYGWIN__ |
784 |
++ APPEND_EXE_OPTION, |
785 |
++#endif /* __CYGWIN__ */ |
786 |
+ BLOCK_SIZE_OPTION, |
787 |
+ COLOR_OPTION, |
788 |
+ DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION, |
789 |
+@@ -880,6 +892,9 @@ |
790 |
+ {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION}, |
791 |
+ {"context", no_argument, 0, 'Z'}, |
792 |
+ {"author", no_argument, NULL, AUTHOR_OPTION}, |
793 |
++#if __CYGWIN__ |
794 |
++ {"append-exe", no_argument, NULL, APPEND_EXE_OPTION}, |
795 |
++#endif /* __CYGWIN__ */ |
796 |
+ {GETOPT_HELP_OPTION_DECL}, |
797 |
+ {GETOPT_VERSION_OPTION_DECL}, |
798 |
+ {NULL, 0, NULL, 0} |
799 |
+@@ -2096,6 +2111,12 @@ |
800 |
+ print_scontext = true; |
801 |
+ break; |
802 |
+ |
803 |
++#if __CYGWIN__ |
804 |
++ case APPEND_EXE_OPTION: |
805 |
++ append_exe = true; |
806 |
++ break; |
807 |
++#endif /* __CYGWIN__ */ |
808 |
++ |
809 |
+ case_GETOPT_HELP_CHAR; |
810 |
+ |
811 |
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); |
812 |
+@@ -3107,6 +3128,12 @@ |
813 |
+ uintmax_t blocks = 0; |
814 |
+ struct fileinfo *f; |
815 |
+ |
816 |
++#if __CYGWIN__ |
817 |
++ char *name_alt = NULL; |
818 |
++ if (command_line_arg && append_exe && 0 < cygwin_spelling (name)) |
819 |
++ CYGWIN_APPEND_EXE (name_alt, name); |
820 |
++#endif /* __CYGWIN__ */ |
821 |
++ |
822 |
+ /* An inode value prior to gobble_file necessarily came from readdir, |
823 |
+ which is not used for command line arguments. */ |
824 |
+ assert (! command_line_arg || inode == NOT_AN_INODE_NUMBER); |
825 |
+@@ -3237,11 +3264,19 @@ |
826 |
+ file_failure (command_line_arg, |
827 |
+ _("cannot access %s"), full_name); |
828 |
+ if (command_line_arg) |
829 |
+- return 0; |
830 |
++ { |
831 |
++#if __CYGWIN__ |
832 |
++ freea (name_alt); |
833 |
++#endif /* __CYGWIN__ */ |
834 |
++ return 0; |
835 |
++ } |
836 |
+ |
837 |
+ f->name = xstrdup (name); |
838 |
+ cwd_n_used++; |
839 |
+ |
840 |
++#if __CYGWIN__ |
841 |
++ freea (name_alt); |
842 |
++#endif /* __CYGWIN__ */ |
843 |
+ return 0; |
844 |
+ } |
845 |
+ |
846 |
+@@ -3430,6 +3465,9 @@ |
847 |
+ f->name = xstrdup (name); |
848 |
+ cwd_n_used++; |
849 |
+ |
850 |
++#if __CYGWIN__ |
851 |
++ freea (name_alt); |
852 |
++#endif /* __CYGWIN__ */ |
853 |
+ return blocks; |
854 |
+ } |
855 |
+ |
856 |
+@@ -5277,6 +5315,11 @@ |
857 |
+ -1 list one file per line. Avoid '\\n' with -q or -b\ |
858 |
+ \n\ |
859 |
+ "), stdout); |
860 |
++#if __CYGWIN__ |
861 |
++ fputs (_("\ |
862 |
++ --append-exe append .exe if cygwin magic was needed\n\ |
863 |
++"), stdout); |
864 |
++#endif /* __CYGWIN__ */ |
865 |
+ fputs (HELP_OPTION_DESCRIPTION, stdout); |
866 |
+ fputs (VERSION_OPTION_DESCRIPTION, stdout); |
867 |
+ emit_size_note (); |
868 |
+--- coreutils-8.28_prep/src/md5sum.c 2017-09-01 13:11:03.000000000 +0600 |
869 |
++++ coreutils-8.28_prep/src/md5sum.c 2017-11-20 17:27:01.925674000 +0600 |
870 |
+@@ -1019,6 +1019,8 @@ |
871 |
+ char **operand_lim = argv + argc; |
872 |
+ if (optind == argc) |
873 |
+ *operand_lim++ = bad_cast ("-"); |
874 |
++ if (O_BINARY) |
875 |
++ xset_binary_mode (STDIN_FILENO, O_BINARY); |
876 |
+ |
877 |
+ for (char **operandp = argv + optind; operandp < operand_lim; operandp++) |
878 |
+ { |
879 |
+--- coreutils-8.28_prep/src/mv.c 2017-09-01 13:11:03.000000000 +0600 |
880 |
++++ coreutils-8.28_prep/src/mv.c 2017-11-20 10:58:06.670586400 +0600 |
881 |
+@@ -92,7 +92,7 @@ |
882 |
+ x->require_restore_cwd = true; |
883 |
+ |
884 |
+ { |
885 |
+- static struct dev_ino dev_ino_buf; |
886 |
++ static struct root_dev_ino dev_ino_buf; |
887 |
+ x->root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
888 |
+ if (x->root_dev_ino == NULL) |
889 |
+ die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), |
890 |
+@@ -452,6 +452,16 @@ |
891 |
+ else if (!target_directory) |
892 |
+ { |
893 |
+ assert (2 <= n_files); |
894 |
++#if __CYGWIN__ |
895 |
++ struct stat s1, s2; |
896 |
++ if (2 == n_files |
897 |
++ && lstat (file[0], &s1) == 0 && lstat (file[1], &s2) == 0 |
898 |
++ && s1.st_ino == s2.st_ino) |
899 |
++ { |
900 |
++ /* Allow 'mv foo Foo' to change case of the directory foo. */ |
901 |
++ } |
902 |
++ else |
903 |
++#endif /* __CYGWIN__ */ |
904 |
+ if (target_directory_operand (file[n_files - 1])) |
905 |
+ target_directory = file[--n_files]; |
906 |
+ else if (2 < n_files) |
907 |
+--- coreutils-8.28_prep/src/pwd.c 2017-09-01 13:11:03.000000000 +0600 |
908 |
++++ coreutils-8.28_prep/src/pwd.c 2017-11-20 10:58:06.686330400 +0600 |
909 |
+@@ -268,8 +268,8 @@ |
910 |
+ robust_getcwd (struct file_name *file_name) |
911 |
+ { |
912 |
+ size_t height = 1; |
913 |
+- struct dev_ino dev_ino_buf; |
914 |
+- struct dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
915 |
++ struct root_dev_ino dev_ino_buf; |
916 |
++ struct root_dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
917 |
+ struct stat dot_sb; |
918 |
+ |
919 |
+ if (root_dev_ino == NULL) |
920 |
+@@ -282,7 +282,7 @@ |
921 |
+ while (1) |
922 |
+ { |
923 |
+ /* If we've reached the root, we're done. */ |
924 |
+- if (SAME_INODE (dot_sb, *root_dev_ino)) |
925 |
++ if (ROOT_DEV_INO_CHECK (root_dev_ino, &dot_sb)) |
926 |
+ break; |
927 |
+ |
928 |
+ find_dir_entry (&dot_sb, file_name, height++); |
929 |
+@@ -291,6 +291,9 @@ |
930 |
+ /* See if a leading slash is needed; file_name_prepend adds one. */ |
931 |
+ if (file_name->start[0] == '\0') |
932 |
+ file_name_prepend (file_name, "", 0); |
933 |
++ /* If we aren't in `/', we must be in `//'. */ |
934 |
++ if (! SAME_INODE (root_dev_ino->single_slash, dot_sb)) |
935 |
++ file_name_prepend (file_name, "", 0); |
936 |
+ } |
937 |
+ |
938 |
+ |
939 |
+--- coreutils-8.28_prep/src/remove.h 2017-09-01 13:11:03.000000000 +0600 |
940 |
++++ coreutils-8.28_prep/src/remove.h 2017-11-20 10:58:06.686330400 +0600 |
941 |
+@@ -54,7 +54,7 @@ |
942 |
+ |
943 |
+ /* Pointer to the device and inode numbers of '/', when --recursive |
944 |
+ and preserving '/'. Otherwise NULL. */ |
945 |
+- struct dev_ino *root_dev_ino; |
946 |
++ struct root_dev_ino *root_dev_ino; |
947 |
+ |
948 |
+ /* If nonzero, stdin is a tty. */ |
949 |
+ bool stdin_tty; |
950 |
+--- coreutils-8.28_prep/src/rm.c 2017-09-01 13:11:03.000000000 +0600 |
951 |
++++ coreutils-8.28_prep/src/rm.c 2017-11-20 10:58:06.686330400 +0600 |
952 |
+@@ -326,7 +326,7 @@ |
953 |
+ |
954 |
+ if (x.recursive && preserve_root) |
955 |
+ { |
956 |
+- static struct dev_ino dev_ino_buf; |
957 |
++ static struct root_dev_ino dev_ino_buf; |
958 |
+ x.root_dev_ino = get_root_dev_ino (&dev_ino_buf); |
959 |
+ if (x.root_dev_ino == NULL) |
960 |
+ die (EXIT_FAILURE, errno, _("failed to get attributes of %s"), |
961 |
+--- coreutils-8.28_prep/src/stat.c 2017-09-01 13:11:03.000000000 +0600 |
962 |
++++ coreutils-8.28_prep/src/stat.c 2017-11-20 10:58:06.686330400 +0600 |
963 |
+@@ -74,6 +74,13 @@ |
964 |
+ #include "find-mount-point.h" |
965 |
+ #include "xvasprintf.h" |
966 |
+ |
967 |
++#if __CYGWIN__ |
968 |
++# include "cygwin.h" |
969 |
++/* Whether .exe should be appended to command-line args as needed. */ |
970 |
++static bool append_exe; |
971 |
++# define APPEND_EXE_OPTION 10000 |
972 |
++#endif |
973 |
++ |
974 |
+ #if USE_STATVFS |
975 |
+ # define STRUCT_STATXFS_F_FSID_IS_INTEGER STRUCT_STATVFS_F_FSID_IS_INTEGER |
976 |
+ # define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS_F_TYPE |
977 |
+@@ -194,6 +201,9 @@ |
978 |
+ {"format", required_argument, NULL, 'c'}, |
979 |
+ {"printf", required_argument, NULL, PRINTF_OPTION}, |
980 |
+ {"terse", no_argument, NULL, 't'}, |
981 |
++#if __CYGWIN__ |
982 |
++ {"append-exe", no_argument, NULL, APPEND_EXE_OPTION}, |
983 |
++#endif /* __CYGWIN__ */ |
984 |
+ {GETOPT_HELP_OPTION_DECL}, |
985 |
+ {GETOPT_VERSION_OPTION_DECL}, |
986 |
+ {NULL, 0, NULL, 0} |
987 |
+@@ -1345,14 +1355,26 @@ |
988 |
+ return false; |
989 |
+ } |
990 |
+ |
991 |
++#if __CYGWIN__ |
992 |
++ char *name_alt = NULL; |
993 |
++ if (append_exe && 0 < cygwin_spelling (filename)) |
994 |
++ CYGWIN_APPEND_EXE (name_alt, filename); |
995 |
++#endif /* __CYGWIN__ */ |
996 |
++ |
997 |
+ if (STATFS (filename, &statfsbuf) != 0) |
998 |
+ { |
999 |
+ error (0, errno, _("cannot read file system information for %s"), |
1000 |
+ quoteaf (filename)); |
1001 |
++#if __CYGWIN__ |
1002 |
++ freea (name_alt); |
1003 |
++#endif /* __CYGWIN__ */ |
1004 |
+ return false; |
1005 |
+ } |
1006 |
+ |
1007 |
+ bool fail = print_it (format, -1, filename, print_statfs, &statfsbuf); |
1008 |
++#if __CYGWIN__ |
1009 |
++ freea (name_alt); |
1010 |
++#endif /* __CYGWIN__ */ |
1011 |
+ return ! fail; |
1012 |
+ } |
1013 |
+ |
1014 |
+@@ -1363,6 +1385,7 @@ |
1015 |
+ { |
1016 |
+ int fd = STREQ (filename, "-") ? 0 : -1; |
1017 |
+ struct stat statbuf; |
1018 |
++ char *name_alt = NULL; |
1019 |
+ |
1020 |
+ if (0 <= fd) |
1021 |
+ { |
1022 |
+@@ -1375,18 +1398,28 @@ |
1023 |
+ /* We can't use the shorter |
1024 |
+ (follow_links?stat:lstat) (filename, &statbug) |
1025 |
+ since stat might be a function-like macro. */ |
1026 |
+- else if ((follow_links |
1027 |
+- ? stat (filename, &statbuf) |
1028 |
+- : lstat (filename, &statbuf)) != 0) |
1029 |
++ else |
1030 |
+ { |
1031 |
+- error (0, errno, _("cannot stat %s"), quoteaf (filename)); |
1032 |
+- return false; |
1033 |
++ if ((follow_links |
1034 |
++ ? stat (filename, &statbuf) |
1035 |
++ : lstat (filename, &statbuf)) != 0) |
1036 |
++ { |
1037 |
++ error (0, errno, _("cannot stat %s"), quoteaf (filename)); |
1038 |
++ return false; |
1039 |
++ } |
1040 |
++#if __CYGWIN__ |
1041 |
++ if (append_exe && 0 < cygwin_spelling (filename)) |
1042 |
++ CYGWIN_APPEND_EXE (name_alt, filename); |
1043 |
++#endif /* __CYGWIN__ */ |
1044 |
+ } |
1045 |
+ |
1046 |
+ if (S_ISBLK (statbuf.st_mode) || S_ISCHR (statbuf.st_mode)) |
1047 |
+ format = format2; |
1048 |
+ |
1049 |
+ bool fail = print_it (format, fd, filename, print_stat, &statbuf); |
1050 |
++#if __CYGWIN__ |
1051 |
++ freea (name_alt); |
1052 |
++#endif /* __CYGWIN__ */ |
1053 |
+ return ! fail; |
1054 |
+ } |
1055 |
+ |
1056 |
+@@ -1508,6 +1541,11 @@ |
1057 |
+ if you want a newline, include \\n in FORMAT\n\ |
1058 |
+ -t, --terse print the information in terse form\n\ |
1059 |
+ "), stdout); |
1060 |
++#if __CYGWIN__ |
1061 |
++ fputs (_("\ |
1062 |
++ --append-exe append .exe if cygwin magic was needed\n\ |
1063 |
++"), stdout); |
1064 |
++#endif /* __CYGWIN__ */ |
1065 |
+ fputs (HELP_OPTION_DESCRIPTION, stdout); |
1066 |
+ fputs (VERSION_OPTION_DESCRIPTION, stdout); |
1067 |
+ |
1068 |
+@@ -1627,6 +1665,12 @@ |
1069 |
+ terse = true; |
1070 |
+ break; |
1071 |
+ |
1072 |
++#if __CYGWIN__ |
1073 |
++ case APPEND_EXE_OPTION: |
1074 |
++ append_exe = true; |
1075 |
++ break; |
1076 |
++#endif /* __CYGWIN__ */ |
1077 |
++ |
1078 |
+ case_GETOPT_HELP_CHAR; |
1079 |
+ |
1080 |
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); |