1- From 12471a5de6b1da5cafe9288fa68185e304caae21 Mon Sep 17 00:00:00 2001
1+ From 7721d4267a9478f789f2235e8761a29421663fc3 Mon Sep 17 00:00:00 2001
22From: Johannes Schindelin <
[email protected] >
33Date: Fri, 18 Dec 2015 20:19:57 +0100
4- Subject: [PATCH 43 /N] Make paths' WCS->MBS conversion explicit
4+ Subject: [PATCH 04 /N] Make paths' WCS->MBS conversion explicit
55
66 * dcrt0.cc (dll_crt0_1), dtable.cc (handle_to_fn), environ.cc
77 (environ_init, getwinenveq, build_env), external.cc
159159 13 files changed, 62 insertions(+), 59 deletions(-)
160160
161161diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
162- index 33cad1e..61ecb75 100644
162+ index f4c09be..57d4b88 100644
163163--- a/winsup/cygwin/dcrt0.cc
164164+++ b/winsup/cygwin/dcrt0.cc
165- @@ -912 ,9 +912 ,9 @@ dll_crt0_1 (void *)
165+ @@ -900 ,9 +900 ,9 @@ dll_crt0_1 (void *)
166166 if (!__argc)
167167 {
168168 PWCHAR wline = GetCommandLineW ();
@@ -175,10 +175,10 @@ index 33cad1e..61ecb75 100644
175175 /* Scan the command line and build argv. Expand wildcards if not
176176 called from another cygwin process. */
177177diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
178- index 6ccc19a..44ce756 100644
178+ index 7303f7e..b99c80b 100644
179179--- a/winsup/cygwin/dtable.cc
180180+++ b/winsup/cygwin/dtable.cc
181- @@ -1027 ,7 +1027 ,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
181+ @@ -1021 ,7 +1021 ,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
182182 if (wcsncasecmp (w32, DEVICE_PREFIX, DEVICE_PREFIX_LEN) != 0
183183 || !QueryDosDeviceW (NULL, fnbuf, sizeof (fnbuf) / sizeof (WCHAR)))
184184 {
@@ -188,10 +188,10 @@ index 6ccc19a..44ce756 100644
188188 }
189189
190190diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
191- index 4e04921..529535a 100644
191+ index d4cedcb..7077595 100644
192192--- a/winsup/cygwin/environ.cc
193193+++ b/winsup/cygwin/environ.cc
194- @@ -918 ,7 +918 ,7 @@ win32env_to_cygenv (PWCHAR rawenv, bool posify)
194+ @@ -873 ,7 +873 ,7 @@ win32env_to_cygenv (PWCHAR rawenv, bool posify)
195195 eventually want to use them). */
196196 for (i = 0, w = rawenv; *w != L'\0'; w = wcschr (w, L'\0') + 1, i++)
197197 {
@@ -200,7 +200,7 @@ index 4e04921..529535a 100644
200200 if (i >= envc)
201201 envp = (char **) realloc (envp, (4 + (envc += 100)) * sizeof (char *));
202202 envp[i] = newp;
203- @@ -978 ,7 +978 ,7 @@ getwinenveq (const char *name, size_t namelen, int x)
203+ @@ -919 ,7 +919 ,7 @@ getwinenveq (const char *name, size_t namelen, int x)
204204 int totlen = GetEnvironmentVariableW (name0, valbuf, 32768);
205205 if (totlen > 0)
206206 {
@@ -209,7 +209,7 @@ index 4e04921..529535a 100644
209209 if (x == HEAP_1_STR)
210210 totlen += namelen;
211211 else
212- @@ -986 ,7 +986 ,7 @@ getwinenveq (const char *name, size_t namelen, int x)
212+ @@ -927 ,7 +927 ,7 @@ getwinenveq (const char *name, size_t namelen, int x)
213213 char *p = (char *) cmalloc_abort ((cygheap_types) x, totlen);
214214 if (namelen)
215215 strcpy (p, name);
@@ -218,7 +218,7 @@ index 4e04921..529535a 100644
218218 debug_printf ("using value from GetEnvironmentVariable for '%W'", name0);
219219 return p;
220220 }
221- @@ -1144 ,7 +1144 ,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
221+ @@ -1084 ,7 +1084 ,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
222222 for (winnum = 0, var = cwinenv;
223223 *var;
224224 ++winnum, var = wcschr (var, L'\0') + 1)
@@ -228,7 +228,7 @@ index 4e04921..529535a 100644
228228 DestroyEnvironmentBlock (cwinenv);
229229 /* Eliminate variables which are already available in envp, as well as
230230diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
231- index a20ea07..fa9d696 100644
231+ index 50a5af2..945b9b8 100644
232232--- a/winsup/cygwin/external.cc
233233+++ b/winsup/cygwin/external.cc
234234@@ -92,7 +92,7 @@ fillout_pinfo (pid_t pid, int winpid)
@@ -393,10 +393,10 @@ index 606559a..c6ec5d8 100644
393393 return _sys_wcstombs_alloc (dst_p, type, src, nwc, false);
394394 }
395395diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
396- index ff02793..ceb3864 100644
396+ index 1cfee5c..61f06d0 100644
397397--- a/winsup/cygwin/mount.cc
398398+++ b/winsup/cygwin/mount.cc
399- @@ -506 ,7 +506 ,7 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
399+ @@ -508 ,7 +508 ,7 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
400400 {
401401 /* The filesystem name is only used in fillout_mntent and only if
402402 the filesystem isn't one of the well-known filesystems anyway. */
@@ -405,16 +405,16 @@ index ff02793..ceb3864 100644
405405 ffai_buf.ffai.FileSystemNameLength / sizeof (WCHAR));
406406 strlwr (fsn);
407407 }
408- @@ -547 ,7 +547 ,7 @@ mount_info::create_root_entry (const PWCHAR root)
408+ @@ -549 ,7 +549 ,7 @@ mount_info::create_root_entry (const PWCHAR root)
409409 /* Create a default root dir derived from the location of the Cygwin DLL.
410410 The entry is immutable, unless the "override" option is given in /etc/fstab. */
411411 char native_root[PATH_MAX];
412412- sys_wcstombs (native_root, PATH_MAX, root);
413413+ sys_wcstombs_path (native_root, PATH_MAX, root);
414414 assert (*native_root != '\0');
415415 if (add_item (native_root, "/",
416- MOUNT_SYSTEM | MOUNT_IMMUTABLE | MOUNT_AUTOMATIC | MOUNT_NOACL )
417- @@ -941 ,7 +941 ,7 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
416+ MOUNT_SYSTEM | MOUNT_IMMUTABLE | MOUNT_AUTOMATIC)
417+ @@ -942 ,7 +942 ,7 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
418418 }
419419 tmp_pathbuf tp;
420420 char *buf = tp.c_get ();
@@ -423,7 +423,7 @@ index ff02793..ceb3864 100644
423423 int ret = conv_to_posix_path (buf, posix_path, ccp_flags);
424424 if (changed)
425425 src_path[0] = L'C';
426- @@ -1275 ,7 +1275 ,7 @@ mount_info::from_fstab_line (char *line, bool user)
426+ @@ -1263 ,7 +1263 ,7 @@ mount_info::from_fstab_line (char *line, bool user)
427427 {
428428 tmp_pathbuf tp;
429429 char *mb_tmp = tp.c_get ();
@@ -432,7 +432,7 @@ index ff02793..ceb3864 100644
432432
433433 mount_flags |= MOUNT_USER_TEMP;
434434 int res = mount_table->add_item (mb_tmp, posix_path, mount_flags);
435- @@ -1890 ,7 +1890 ,7 @@ mount_info::cygdrive_getmntent ()
435+ @@ -1752 ,7 +1752 ,7 @@ mount_info::cygdrive_getmntent ()
436436 if (wide_path)
437437 {
438438 win32_path = tp.c_get ();
@@ -455,10 +455,10 @@ index f57465a..57af967 100644
455455 }
456456 }
457457diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
458- index ead7d16..66c829e 100644
458+ index 8aff97a..2c57e3f 100644
459459--- a/winsup/cygwin/path.cc
460460+++ b/winsup/cygwin/path.cc
461- @@ -653 ,7 +653 ,8 @@ path_conv::check (const UNICODE_STRING *src, unsigned opt,
461+ @@ -652 ,7 +652 ,8 @@ path_conv::check (const UNICODE_STRING *src, unsigned opt,
462462 char *path = tp.c_get ();
463463
464464 user_shared->warned_msdos = true;
@@ -468,7 +468,7 @@ index ead7d16..66c829e 100644
468468 path_conv::check (path, opt, suffixes);
469469 }
470470
471- @@ -2692 ,7 +2693 ,7 @@ symlink_info::check_shortcut (HANDLE h)
471+ @@ -2435 ,7 +2436 ,7 @@ symlink_info::check_shortcut (HANDLE h)
472472 if (*(PWCHAR) cp == 0xfeff) /* BOM */
473473 {
474474 char *tmpbuf = tp.c_get ();
@@ -477,7 +477,7 @@ index ead7d16..66c829e 100644
477477 > SYMLINK_MAX)
478478 return 0;
479479 res = posixify (tmpbuf);
480- @@ -2773 ,7 +2774 ,7 @@ symlink_info::check_sysfile (HANDLE h)
480+ @@ -2516 ,7 +2517 ,7 @@ symlink_info::check_sysfile (HANDLE h)
481481 else
482482 srcbuf += 2;
483483 char *tmpbuf = tp.c_get ();
@@ -486,7 +486,7 @@ index ead7d16..66c829e 100644
486486 > SYMLINK_MAX)
487487 debug_printf ("symlink string too long");
488488 else
489- @@ -3041 ,8 +3042 ,8 @@ symlink_info::check_reparse_point (HANDLE h, bool remote)
489+ @@ -2784 ,8 +2785 ,8 @@ symlink_info::check_reparse_point (HANDLE h, bool remote)
490490 path_flags (path_flags () | ret);
491491 if (ret & PATH_SYMLINK)
492492 {
@@ -497,7 +497,7 @@ index ead7d16..66c829e 100644
497497 /* A symlink is never a directory. */
498498 fileattr (fileattr () & ~FILE_ATTRIBUTE_DIRECTORY);
499499 return posixify (srcbuf);
500- @@ -3076 ,7 +3077 ,7 @@ symlink_info::check_nfs_symlink (HANDLE h)
500+ @@ -2819 ,7 +2820 ,7 @@ symlink_info::check_nfs_symlink (HANDLE h)
501501 {
502502 PWCHAR spath = (PWCHAR)
503503 (pffei->EaName + pffei->EaNameLength + 1);
@@ -506,7 +506,7 @@ index ead7d16..66c829e 100644
506506 spath, pffei->EaValueLength);
507507 path_flags (path_flags () | PATH_SYMLINK);
508508 }
509- @@ -4275 ,7 +4276 ,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
509+ @@ -3950 ,7 +3951 ,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
510510 }
511511 PUNICODE_STRING up = p.get_nt_native_path ();
512512 buf = tp.c_get ();
@@ -515,7 +515,7 @@ index ead7d16..66c829e 100644
515515 up->Buffer, up->Length / sizeof (WCHAR));
516516 /* Convert native path to standard DOS path. */
517517 if (!strncmp (buf, "\\??\\", 4))
518- @@ -4288 ,11 +4289 ,11 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
518+ @@ -3963 ,11 +3964 ,11 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
519519 {
520520 /* Device name points to somewhere else in the NT namespace.
521521 Use GLOBALROOT prefix to convert to Win32 path. */
@@ -529,7 +529,7 @@ index ead7d16..66c829e 100644
529529 up->Buffer, up->Length / sizeof (WCHAR));
530530 }
531531 lsiz = strlen (buf) + 1;
532- @@ -4604 ,8 +4605 ,8 @@ cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, void *to,
532+ @@ -4279 ,8 +4280 ,8 @@ cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, void *to,
533533 switch (what & CCP_CONVTYPE_MASK)
534534 {
535535 case CCP_WIN_W_TO_POSIX:
@@ -540,7 +540,7 @@ index ead7d16..66c829e 100644
540540 return -1;
541541 what = (what & ~CCP_CONVTYPE_MASK) | CCP_WIN_A_TO_POSIX;
542542 from = (const void *) winp;
543- @@ -5391 ,9 +5392 ,9 @@ cwdstuff::get_error_desc () const
543+ @@ -5054 ,9 +5055 ,9 @@ cwdstuff::get_error_desc () const
544544 void
545545 cwdstuff::reset_posix (wchar_t *w_cwd)
546546 {
@@ -552,7 +552,7 @@ index ead7d16..66c829e 100644
552552 }
553553
554554 char *
555- @@ -5418 ,7 +5419 ,7 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
555+ @@ -5081 ,7 +5082 ,7 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
556556 if (!need_posix)
557557 {
558558 tocopy = tp.c_get ();
@@ -562,7 +562,7 @@ index ead7d16..66c829e 100644
562562 }
563563 else
564564diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
565- index 4323cb1..9f2685a 100644
565+ index ffe71ee..d2c829a 100644
566566--- a/winsup/cygwin/uinfo.cc
567567+++ b/winsup/cygwin/uinfo.cc
568568@@ -385,12 +385,12 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
0 commit comments