From 48fdc86de290bab776e57277d52ecae48ea08b3a Mon Sep 17 00:00:00 2001 From: corinna Date: Sun, 13 Apr 2008 16:47:21 +0000 Subject: [PATCH] * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Simplify code which checks for symlinks. Fix problem with UNC paths. * environ.cc (struct parse_thing): Remove transparent_exe option. * syscalls.cc (transparent_exe): Remove. (unlink): Always add stat_suffixes, drop transparent_exe check. (open): Ditto. (link): Ditto. (pathconf): Ditto. * fhandler_disk_file.cc (fhandler_disk_file::link): Ditto. * fhandler_process.cc (fhandler_process::fill_filebuf): Always remove .exe suffix. * path.cc (realpath): Never attach known_suffix. --- winsup/cygwin/ChangeLog | 16 ++++++++++++++++ winsup/cygwin/environ.cc | 1 - winsup/cygwin/fhandler_disk_file.cc | 26 ++++++++++++++------------ winsup/cygwin/fhandler_process.cc | 15 +++++---------- winsup/cygwin/path.cc | 14 +------------- winsup/cygwin/syscalls.cc | 13 ++++--------- 6 files changed, 40 insertions(+), 45 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1875ede012..2ce01ea674 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,19 @@ +2008-04-13 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Simplify + code which checks for symlinks. Fix problem with UNC paths. + + * environ.cc (struct parse_thing): Remove transparent_exe option. + * syscalls.cc (transparent_exe): Remove. + (unlink): Always add stat_suffixes, drop transparent_exe check. + (open): Ditto. + (link): Ditto. + (pathconf): Ditto. + * fhandler_disk_file.cc (fhandler_disk_file::link): Ditto. + * fhandler_process.cc (fhandler_process::fill_filebuf): Always remove + .exe suffix. + * path.cc (realpath): Never attach known_suffix. + 2008-04-10 Corinna Vinschen * cygwin.din (wprintf): Remove. diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index ab068ac259..ae202cf904 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -626,7 +626,6 @@ static struct parse_thing {"title", {&display_title}, justset, NULL, {{false}, {true}}}, {"tty", {NULL}, set_process_state, NULL, {{0}, {PID_USETTY}}}, {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}}, - {"transparent_exe", {&transparent_exe}, justset, NULL, {{false}, {true}}}, {NULL, {0}, justset, 0, {{0}, {0}}} }; diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 112ad9c1dc..0f400bbe89 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -22,6 +22,7 @@ details. */ #include "shared_info.h" #include "pinfo.h" #include "ntdll.h" +#include "tls_pbuf.h" #include #define _COMPILING_NEWLIB @@ -1063,8 +1064,7 @@ fhandler_disk_file::link (const char *newpath) { extern bool allow_winsymlinks; - path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX, - transparent_exe ? stat_suffixes : NULL); + path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes); if (newpc.error) { set_errno (newpc.case_clash ? ECASECLASH : newpc.error); @@ -1607,21 +1607,23 @@ fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err, fname->Buffer + fname->Length / sizeof (WCHAR) - 4, 4 * sizeof (WCHAR)); - RtlInitCountedUnicodeString (&lname, (PWCHAR) L".lnk", - 4 * sizeof (WCHAR)); - + RtlInitUnicodeString (&lname, (PWCHAR) L".lnk"); if (RtlEqualUnicodeString (&uname, &lname, TRUE)) { - UNICODE_STRING dirname = *pc.get_nt_native_path (); - dirname.Buffer += 4; /* Skip leading \??\ */ - dirname.Length -= 4 * sizeof (WCHAR); + tmp_pathbuf tp; UNICODE_STRING fbuf; - ULONG len = dirname.Length + fname->Length + 2 * sizeof (WCHAR); - - RtlInitEmptyUnicodeString (&fbuf, (PCWSTR) alloca (len), len); - RtlCopyUnicodeString (&fbuf, &dirname); + + tp.u_get (&fbuf); + RtlCopyUnicodeString (&fbuf, pc.get_nt_native_path ()); RtlAppendUnicodeToString (&fbuf, L"\\"); RtlAppendUnicodeStringToString (&fbuf, fname); + fbuf.Buffer += 4; /* Skip leading \??\ */ + fbuf.Length -= 4 * sizeof (WCHAR); + if (*fbuf.Buffer == L'U') /* UNC path */ + { + *(fbuf.Buffer += 2) = L'\\'; + fbuf.Length -= 2 * sizeof (WCHAR); + } path_conv fpath (&fbuf, PC_SYM_NOFOLLOW); if (fpath.issymlink () || fpath.is_fs_special ()) fname->Length -= 4 * sizeof (WCHAR); diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index a752bfb1c8..b64f221756 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -446,17 +446,12 @@ fhandler_process::fill_filebuf () else { mount_table->conv_to_posix_path (p->progname, filebuf, 1); - /* If transparent_exe isn't set, the link keeps its suffix so that - an open(2) call will succeed on /proc/$PID/exe. */ - if (transparent_exe) + int len = strlen (filebuf); + if (len > 4) { - int len = strlen (filebuf); - if (len > 4) - { - char *s = filebuf + len - 4; - if (ascii_strcasematch (s, ".exe")) - *s = 0; - } + char *s = filebuf + len - 4; + if (ascii_strcasematch (s, ".exe")) + *s = 0; } } filesize = strlen (filebuf); diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 0b94890b1c..c44a932cbe 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2872,25 +2872,13 @@ realpath (const char *path, char *resolved) if (!real_path.error && real_path.exists ()) { - /* Check for the suffix being tacked on. */ - int tack_on = 0; - if (!transparent_exe && real_path.known_suffix) - { - char *c = strrchr (real_path.normalized_path, '.'); - if (!c || !ascii_strcasematch (c, real_path.known_suffix)) - tack_on = strlen (real_path.known_suffix); - } - if (!resolved) { - resolved = (char *) malloc (strlen (real_path.normalized_path) - + tack_on + 1); + resolved = (char *) malloc (strlen (real_path.normalized_path) + 1); if (!resolved) return NULL; } strcpy (resolved, real_path.normalized_path); - if (tack_on) - strcat (resolved, real_path.known_suffix); return resolved; } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 881b9d1ebe..28533a58b9 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -78,8 +78,6 @@ suffix_info stat_suffixes[] = suffix_info (NULL) }; -bool transparent_exe = false; - SYSTEM_INFO system_info; static int __stdcall mknod_worker (const char *, mode_t, mode_t, _major_t, @@ -517,8 +515,7 @@ unlink (const char *ourname) DWORD devn; NTSTATUS status; - path_conv win32_name (ourname, PC_SYM_NOFOLLOW, - transparent_exe ? stat_suffixes : NULL); + path_conv win32_name (ourname, PC_SYM_NOFOLLOW, stat_suffixes); if (win32_name.error) { @@ -885,7 +882,7 @@ open (const char *unix_path, int flags, ...) if (!(fh = build_fh_name (unix_path, NULL, (flags & (O_NOFOLLOW | O_EXCL)) ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW, - transparent_exe ? stat_suffixes : NULL))) + stat_suffixes))) res = -1; // errno already set else if ((flags & O_NOFOLLOW) && fh->issymlink ()) { @@ -1010,8 +1007,7 @@ link (const char *oldpath, const char *newpath) int res = -1; fhandler_base *fh; - if (!(fh = build_fh_name (oldpath, NULL, PC_SYM_NOFOLLOW, - transparent_exe ? stat_suffixes : NULL))) + if (!(fh = build_fh_name (oldpath, NULL, PC_SYM_NOFOLLOW, stat_suffixes))) goto error; if (fh->error ()) @@ -1903,8 +1899,7 @@ pathconf (const char *file, int v) set_errno (ENOENT); return -1; } - if (!(fh = build_fh_name (file, NULL, PC_SYM_FOLLOW, - transparent_exe ? stat_suffixes : NULL))) + if (!(fh = build_fh_name (file, NULL, PC_SYM_FOLLOW, stat_suffixes))) return -1; if (!fh->exists ()) { -- 2.11.0