Drop has_fast_cwd flag

This commit is contained in:
Corinna Vinschen 2015-12-15 15:17:18 +01:00
parent 90e6582918
commit ffcef702e7
3 changed files with 77 additions and 111 deletions

View File

@ -3894,12 +3894,11 @@ fcwd_access_t::Free (PVOID heap)
{ {
/* Decrement the reference count. If it's down to 0, free /* Decrement the reference count. If it's down to 0, free
structure from heap. */ structure from heap. */
if (this && InterlockedDecrement (&ReferenceCount ()) == 0) if (InterlockedDecrement (&ReferenceCount ()) == 0)
{ {
/* In contrast to pre-Vista, the handle on init is always a /* The handle on init is always a fresh one, not the handle inherited
fresh one and not the handle inherited from the parent from the parent process. We always have to close it here.
process. So we always have to close it here. However, the Note: The handle could be NULL, if we cd'ed into a virtual dir. */
handle could be NULL, if we cd'ed into a virtual dir. */
HANDLE h = DirectoryHandle (); HANDLE h = DirectoryHandle ();
if (h) if (h)
NtClose (h); NtClose (h);
@ -4247,8 +4246,6 @@ cwdstuff::override_win32_cwd (bool init, ULONG old_dismount_count)
UNICODE_STRING &upp_cwd_str = peb.ProcessParameters->CurrentDirectoryName; UNICODE_STRING &upp_cwd_str = peb.ProcessParameters->CurrentDirectoryName;
HANDLE &upp_cwd_hdl = peb.ProcessParameters->CurrentDirectoryHandle; HANDLE &upp_cwd_hdl = peb.ProcessParameters->CurrentDirectoryHandle;
if (wincap.has_fast_cwd ())
{
if (fast_cwd_ptr == (fcwd_access_t **) -1) if (fast_cwd_ptr == (fcwd_access_t **) -1)
fast_cwd_ptr = find_fast_cwd (); fast_cwd_ptr = find_fast_cwd ();
if (fast_cwd_ptr) if (fast_cwd_ptr)
@ -4282,6 +4279,7 @@ cwdstuff::override_win32_cwd (bool init, ULONG old_dismount_count)
f_cwd->CopyPath (upp_cwd_str); f_cwd->CopyPath (upp_cwd_str);
upp_cwd_hdl = dir; upp_cwd_hdl = dir;
RtlLeaveCriticalSection (peb.FastPebLock); RtlLeaveCriticalSection (peb.FastPebLock);
if (old_cwd)
old_cwd->Free (heap); old_cwd->Free (heap);
} }
else else
@ -4328,31 +4326,8 @@ cwdstuff::override_win32_cwd (bool init, ULONG old_dismount_count)
h = upp_cwd_hdl; h = upp_cwd_hdl;
upp_cwd_hdl = dir; upp_cwd_hdl = dir;
RtlLeaveCriticalSection (peb.FastPebLock); RtlLeaveCriticalSection (peb.FastPebLock);
/* In contrast to pre-Vista, the handle on init is always a fresh one /* The handle on init is always a fresh one, not the handle inherited
and not the handle inherited from the parent process. So we always from the parent process. We always have to close it here. */
have to close it here. */
NtClose (h);
}
}
else
{
/* This method is used for all pre-Vista OSes. We simply set the values
for the CWD in the user process parameter block entirely by ourselves
under PEB lock condition. This is how RtlSetCurrentDirectory_U worked
in these older OSes, so we're safe.
Note that we can't just RtlEnterCriticalSection (peb.FastPebLock)
on pre-Vista. RtlAcquirePebLock was way more complicated back then. */
RtlAcquirePebLock ();
if (!init)
copy_cwd_str (&upp_cwd_str, error ? &ro_u_pipedir : &win32);
h = upp_cwd_hdl;
upp_cwd_hdl = dir;
RtlReleasePebLock ();
/* Only on init, the handle is potentially a native handle. However,
if it's identical to dir, it's the inherited handle from a Cygwin
parent process and must not be closed. */
if (h && h != dir)
NtClose (h); NtClose (h);
} }
} }

View File

@ -25,7 +25,6 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_gaa_largeaddress_bug:false, has_gaa_largeaddress_bug:false,
has_transactions:false, has_transactions:false,
has_broken_alloc_console:false, has_broken_alloc_console:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false, has_restricted_raw_disk_access:false,
use_dont_resolve_hack:true, use_dont_resolve_hack:true,
has_console_logon_sid:false, has_console_logon_sid:false,
@ -51,7 +50,6 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_gaa_largeaddress_bug:false, has_gaa_largeaddress_bug:false,
has_transactions:false, has_transactions:false,
has_broken_alloc_console:false, has_broken_alloc_console:false,
has_fast_cwd:false,
has_restricted_raw_disk_access:false, has_restricted_raw_disk_access:false,
use_dont_resolve_hack:true, use_dont_resolve_hack:true,
has_console_logon_sid:false, has_console_logon_sid:false,
@ -77,7 +75,6 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
has_gaa_largeaddress_bug:true, has_gaa_largeaddress_bug:true,
has_transactions:true, has_transactions:true,
has_broken_alloc_console:false, has_broken_alloc_console:false,
has_fast_cwd:true,
has_restricted_raw_disk_access:true, has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false, use_dont_resolve_hack:false,
has_console_logon_sid:false, has_console_logon_sid:false,
@ -103,7 +100,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_gaa_largeaddress_bug:true, has_gaa_largeaddress_bug:true,
has_transactions:true, has_transactions:true,
has_broken_alloc_console:true, has_broken_alloc_console:true,
has_fast_cwd:true,
has_restricted_raw_disk_access:true, has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false, use_dont_resolve_hack:false,
has_console_logon_sid:true, has_console_logon_sid:true,
@ -129,7 +125,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_gaa_largeaddress_bug:false, has_gaa_largeaddress_bug:false,
has_transactions:true, has_transactions:true,
has_broken_alloc_console:true, has_broken_alloc_console:true,
has_fast_cwd:true,
has_restricted_raw_disk_access:true, has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false, use_dont_resolve_hack:false,
has_console_logon_sid:true, has_console_logon_sid:true,
@ -155,7 +150,6 @@ wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_gaa_largeaddress_bug:false, has_gaa_largeaddress_bug:false,
has_transactions:true, has_transactions:true,
has_broken_alloc_console:true, has_broken_alloc_console:true,
has_fast_cwd:true,
has_restricted_raw_disk_access:true, has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false, use_dont_resolve_hack:false,
has_console_logon_sid:true, has_console_logon_sid:true,
@ -181,7 +175,6 @@ wincaps wincap_10_1511 __attribute__((section (".cygwin_dll_common"), shared)) =
has_gaa_largeaddress_bug:false, has_gaa_largeaddress_bug:false,
has_transactions:true, has_transactions:true,
has_broken_alloc_console:true, has_broken_alloc_console:true,
has_fast_cwd:true,
has_restricted_raw_disk_access:true, has_restricted_raw_disk_access:true,
use_dont_resolve_hack:false, use_dont_resolve_hack:false,
has_console_logon_sid:true, has_console_logon_sid:true,

View File

@ -18,7 +18,6 @@ struct wincaps
unsigned has_gaa_largeaddress_bug : 1; unsigned has_gaa_largeaddress_bug : 1;
unsigned has_transactions : 1; unsigned has_transactions : 1;
unsigned has_broken_alloc_console : 1; unsigned has_broken_alloc_console : 1;
unsigned has_fast_cwd : 1;
unsigned has_restricted_raw_disk_access : 1; unsigned has_restricted_raw_disk_access : 1;
unsigned use_dont_resolve_hack : 1; unsigned use_dont_resolve_hack : 1;
unsigned has_console_logon_sid : 1; unsigned has_console_logon_sid : 1;
@ -69,7 +68,6 @@ public:
bool IMPLEMENT (has_gaa_largeaddress_bug) bool IMPLEMENT (has_gaa_largeaddress_bug)
bool IMPLEMENT (has_transactions) bool IMPLEMENT (has_transactions)
bool IMPLEMENT (has_broken_alloc_console) bool IMPLEMENT (has_broken_alloc_console)
bool IMPLEMENT (has_fast_cwd)
bool IMPLEMENT (has_restricted_raw_disk_access) bool IMPLEMENT (has_restricted_raw_disk_access)
bool IMPLEMENT (use_dont_resolve_hack) bool IMPLEMENT (use_dont_resolve_hack)
bool IMPLEMENT (has_console_logon_sid) bool IMPLEMENT (has_console_logon_sid)