From 2fb0813caa2e30c7e90285264a26c95c9ab4d097 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 15 Dec 2015 14:30:03 +0100 Subject: [PATCH] Drop has_recycle_dot_bin --- winsup/cygwin/syscalls.cc | 63 ++++++--------------------------------- winsup/cygwin/wincap.cc | 7 ----- winsup/cygwin/wincap.h | 2 -- 3 files changed, 9 insertions(+), 63 deletions(-) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 0ffb8c18b..23b9d8261 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -223,12 +223,6 @@ static char desktop_ini[] = static char desktop_ini_ext[] = "LocalizedResourceName=@%SystemRoot%\\system32\\shell32.dll,-8964\r\n"; -static BYTE info2[] = -{ - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - enum bin_status { dont_move, @@ -303,14 +297,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) RtlInitEmptyUnicodeString (&recycler, recyclerbuf, sizeof recyclerbuf); if (!pc.isremote ()) { - if (wincap.has_recycle_dot_bin ()) /* NTFS and FAT since Vista, ReFS */ - RtlAppendUnicodeToString (&recycler, L"\\$Recycle.Bin\\"); - else if (pc.fs_is_ntfs ()) /* NTFS up to 2K3 */ - RtlAppendUnicodeToString (&recycler, L"\\RECYCLER\\"); - else if (pc.fs_is_fat ()) /* FAT up to 2K3 */ - RtlAppendUnicodeToString (&recycler, L"\\Recycled\\"); - else - goto out; + RtlAppendUnicodeToString (&recycler, L"\\$Recycle.Bin\\"); RtlInitCountedUnicodeString(&fname, pfni->FileName, pfni->FileNameLength); /* Is the file a subdir of the recycler? */ if (RtlEqualUnicodePathPrefix (&fname, &recycler, TRUE)) @@ -431,13 +418,9 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) } /* Then check if recycler exists by opening and potentially creating it. Yes, we can really do that. Typically the recycle bin is created - by the first user actually using the bin. Pre-Vista, the permissions - are the default permissions propagated from the root directory. - Since Vista the top-level recycle dir has explicit permissions. */ + by the first user actually using the bin. */ InitializeObjectAttributes (&attr, &recycler, OBJ_CASE_INSENSITIVE, - rootdir, - wincap.has_recycle_dot_bin () - ? recycler_sd (true, true) : NULL); + rootdir, recycler_sd (true, true)); recycler.Length = recycler_base_len; status = NtCreateFile (&recyclerdir, READ_CONTROL @@ -475,9 +458,8 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) goto out; } } - /* The desktop.ini and INFO2 (pre-Vista) files are expected by - Windows Explorer. Otherwise, the created bin is treated as - corrupted */ + /* The desktop.ini file is expected by Windows Explorer. Otherwise, + the created bin is treated as corrupted */ if (io.Information == FILE_CREATED) { RtlInitUnicodeString (&fname, L"desktop.ini"); @@ -495,42 +477,15 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) { status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, desktop_ini, sizeof desktop_ini - 1, NULL, NULL); + if (NT_SUCCESS (status)) + status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, + desktop_ini_ext, + sizeof desktop_ini_ext - 1, NULL, NULL); if (!NT_SUCCESS (status)) debug_printf ("NtWriteFile (%S) failed, status = %y", &fname, status); - else if (wincap.has_recycle_dot_bin ()) - { - status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, - desktop_ini_ext, - sizeof desktop_ini_ext - 1, NULL, NULL); - if (!NT_SUCCESS (status)) - debug_printf ("NtWriteFile (%S) failed, status = %y", - &fname, status); - } NtClose (tmp_fh); } - if (!wincap.has_recycle_dot_bin ()) /* No INFO2 file since Vista */ - { - RtlInitUnicodeString (&fname, L"INFO2"); - status = NtCreateFile (&tmp_fh, FILE_GENERIC_WRITE, &attr, &io, - NULL, FILE_ATTRIBUTE_ARCHIVE - | FILE_ATTRIBUTE_HIDDEN, - FILE_SHARE_VALID_FLAGS, FILE_CREATE, - FILE_SYNCHRONOUS_IO_NONALERT - | FILE_NON_DIRECTORY_FILE, NULL, 0); - if (!NT_SUCCESS (status)) - debug_printf ("NtCreateFile (%S) failed, status = %y", - &recycler, status); - else - { - status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, info2, - sizeof info2, NULL, NULL); - if (!NT_SUCCESS (status)) - debug_printf ("NtWriteFile (%S) failed, status = %y", - &fname, status); - NtClose (tmp_fh); - } - } } NtClose (recyclerdir); /* Shoot again. */ diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index ba11e243f..78c592313 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -23,7 +23,6 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = { is_server:false, has_mandatory_integrity_control:false, needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, has_gaa_on_link_prefix:false, has_gaa_largeaddress_bug:false, supports_all_posix_ai_flags:false, @@ -58,7 +57,6 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { is_server:false, has_mandatory_integrity_control:false, needs_count_in_si_lpres2:false, - has_recycle_dot_bin:false, has_gaa_on_link_prefix:false, has_gaa_largeaddress_bug:false, supports_all_posix_ai_flags:false, @@ -93,7 +91,6 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { is_server:false, has_mandatory_integrity_control:true, needs_count_in_si_lpres2:true, - has_recycle_dot_bin:true, has_gaa_on_link_prefix:true, has_gaa_largeaddress_bug:true, supports_all_posix_ai_flags:true, @@ -128,7 +125,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { is_server:false, has_mandatory_integrity_control:true, needs_count_in_si_lpres2:false, - has_recycle_dot_bin:true, has_gaa_on_link_prefix:true, has_gaa_largeaddress_bug:true, supports_all_posix_ai_flags:true, @@ -163,7 +159,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = { is_server:false, has_mandatory_integrity_control:true, needs_count_in_si_lpres2:false, - has_recycle_dot_bin:true, has_gaa_on_link_prefix:true, has_gaa_largeaddress_bug:false, supports_all_posix_ai_flags:true, @@ -198,7 +193,6 @@ wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = { is_server:false, has_mandatory_integrity_control:true, needs_count_in_si_lpres2:false, - has_recycle_dot_bin:true, has_gaa_on_link_prefix:true, has_gaa_largeaddress_bug:false, supports_all_posix_ai_flags:true, @@ -233,7 +227,6 @@ wincaps wincap_10_1511 __attribute__((section (".cygwin_dll_common"), shared)) = is_server:false, has_mandatory_integrity_control:true, needs_count_in_si_lpres2:false, - has_recycle_dot_bin:true, has_gaa_on_link_prefix:true, has_gaa_largeaddress_bug:false, supports_all_posix_ai_flags:true, diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index 2879b63b2..03b2213ba 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -16,7 +16,6 @@ struct wincaps unsigned is_server : 1; unsigned has_mandatory_integrity_control : 1; unsigned needs_count_in_si_lpres2 : 1; - unsigned has_recycle_dot_bin : 1; unsigned has_gaa_on_link_prefix : 1; unsigned has_gaa_largeaddress_bug : 1; unsigned supports_all_posix_ai_flags : 1; @@ -76,7 +75,6 @@ public: bool IMPLEMENT (is_server) bool IMPLEMENT (has_mandatory_integrity_control) bool IMPLEMENT (needs_count_in_si_lpres2) - bool IMPLEMENT (has_recycle_dot_bin) bool IMPLEMENT (has_gaa_on_link_prefix) bool IMPLEMENT (has_gaa_largeaddress_bug) bool IMPLEMENT (supports_all_posix_ai_flags)