FILE_DISPOSITION_DELETE = 0x01,
FILE_DISPOSITION_POSIX_SEMANTICS = 0x02,
FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x04,
- FILE_DISPOSITION_ON_CLOSE = 0x08
+ FILE_DISPOSITION_ON_CLOSE = 0x08,
+ FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x10,
};
enum
pc.get_object_attr (attr, sec_none_nih);
- /* First check if we can use POSIX unlink semantics: W10 1709++, local NTFS.
+ /* First check if we can use POSIX unlink semantics: W10 1709+, local NTFS.
With POSIX unlink semantics the entire job gets MUCH easier and faster.
Just try to do it and if it fails, it fails. */
if (wincap.has_posix_unlink_semantics ()
{
FILE_DISPOSITION_INFORMATION_EX fdie;
- if (pc.file_attributes () & FILE_ATTRIBUTE_READONLY)
+ /* POSIX unlink semantics are nice, but they still fail if the file has
+ the R/O attribute set. If so, ignoring might be an option: W10 1809+
+ Removing the file is very much a safe bet afterwards, so, no
+ transaction. */
+ if ((pc.file_attributes () & FILE_ATTRIBUTE_READONLY)
+ && !wincap.has_posix_unlink_semantics_with_ignore_readonly ())
access |= FILE_WRITE_ATTRIBUTES;
status = NtOpenFile (&fh, access, &attr, &io, FILE_SHARE_VALID_FLAGS,
flags);
if (!NT_SUCCESS (status))
goto out;
- /* Why didn't the devs add a FILE_DELETE_IGNORE_READONLY_ATTRIBUTE
- flag just like they did with FILE_LINK_IGNORE_READONLY_ATTRIBUTE
- and FILE_LINK_IGNORE_READONLY_ATTRIBUTE???
-
- POSIX unlink semantics are nice, but they still fail if the file
- has the R/O attribute set. Removing the file is very much a safe
- bet afterwards, so, no transaction. */
- if (pc.file_attributes () & FILE_ATTRIBUTE_READONLY)
+ if (access & FILE_WRITE_ATTRIBUTES)
{
status = NtSetAttributesFile (fh, pc.file_attributes ()
& ~FILE_ATTRIBUTE_READONLY);
}
}
fdie.Flags = FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS;
+ if (wincap.has_posix_unlink_semantics_with_ignore_readonly ())
+ fdie.Flags |= FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE;
status = NtSetInformationFile (fh, &io, &fdie, sizeof fdie,
FileDispositionInformationEx);
/* Restore R/O attribute in case we have multiple hardlinks. */
- if (pc.file_attributes () & FILE_ATTRIBUTE_READONLY)
+ if (access & FILE_WRITE_ATTRIBUTES)
NtSetAttributesFile (fh, pc.file_attributes ());
NtClose (fh);
/* Trying to delete in-use executables and DLLs using
has_unbiased_interrupt_time:false,
has_precise_interrupt_time:false,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:true,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:false,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:true,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:false,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:false,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:false,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:true,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:false,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:true,
+ has_posix_unlink_semantics_with_ignore_readonly:false,
has_case_sensitive_dirs:true,
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:true,
+ has_posix_unlink_semantics_with_ignore_readonly:true,
has_case_sensitive_dirs:true,
has_posix_rename_semantics:true,
no_msv1_0_s4u_logon_in_wow64:false,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:true,
+ has_posix_unlink_semantics_with_ignore_readonly:true,
has_case_sensitive_dirs:true,
has_posix_rename_semantics:true,
no_msv1_0_s4u_logon_in_wow64:false,
/* The bitfields must be 8 byte aligned on x86_64, otherwise the bitfield
ops generated by gcc are off by 4 bytes. */
struct __attribute__ ((aligned (8))) {
- unsigned is_server : 1;
- unsigned needs_count_in_si_lpres2 : 1;
- unsigned needs_query_information : 1;
- unsigned has_gaa_largeaddress_bug : 1;
- unsigned has_broken_alloc_console : 1;
- unsigned has_console_logon_sid : 1;
- unsigned has_precise_system_time : 1;
- unsigned has_microsoft_accounts : 1;
- unsigned has_processor_groups : 1;
- unsigned has_broken_prefetchvm : 1;
- unsigned has_new_pebteb_region : 1;
- unsigned has_broken_whoami : 1;
- unsigned has_unprivileged_createsymlink : 1;
- unsigned has_unbiased_interrupt_time : 1;
- unsigned has_precise_interrupt_time : 1;
- unsigned has_posix_unlink_semantics : 1;
- unsigned has_case_sensitive_dirs : 1;
- unsigned has_posix_rename_semantics : 1;
- unsigned no_msv1_0_s4u_logon_in_wow64 : 1;
- unsigned has_con_24bit_colors : 1;
- unsigned has_con_broken_csi3j : 1;
- unsigned has_con_broken_il_dl : 1;
- unsigned has_con_esc_rep : 1;
- unsigned has_extended_mem_api : 1;
- unsigned has_tcp_fastopen : 1;
- unsigned has_linux_tcp_keepalive_sockopts : 1;
- unsigned has_tcp_maxrtms : 1;
+ unsigned is_server : 1;
+ unsigned needs_count_in_si_lpres2 : 1;
+ unsigned needs_query_information : 1;
+ unsigned has_gaa_largeaddress_bug : 1;
+ unsigned has_broken_alloc_console : 1;
+ unsigned has_console_logon_sid : 1;
+ unsigned has_precise_system_time : 1;
+ unsigned has_microsoft_accounts : 1;
+ unsigned has_processor_groups : 1;
+ unsigned has_broken_prefetchvm : 1;
+ unsigned has_new_pebteb_region : 1;
+ unsigned has_broken_whoami : 1;
+ unsigned has_unprivileged_createsymlink : 1;
+ unsigned has_unbiased_interrupt_time : 1;
+ unsigned has_precise_interrupt_time : 1;
+ unsigned has_posix_unlink_semantics : 1;
+ unsigned has_posix_unlink_semantics_with_ignore_readonly : 1;
+ unsigned has_case_sensitive_dirs : 1;
+ unsigned has_posix_rename_semantics : 1;
+ unsigned no_msv1_0_s4u_logon_in_wow64 : 1;
+ unsigned has_con_24bit_colors : 1;
+ unsigned has_con_broken_csi3j : 1;
+ unsigned has_con_broken_il_dl : 1;
+ unsigned has_con_esc_rep : 1;
+ unsigned has_extended_mem_api : 1;
+ unsigned has_tcp_fastopen : 1;
+ unsigned has_linux_tcp_keepalive_sockopts : 1;
+ unsigned has_tcp_maxrtms : 1;
};
};
bool IMPLEMENT (has_unbiased_interrupt_time)
bool IMPLEMENT (has_precise_interrupt_time)
bool IMPLEMENT (has_posix_unlink_semantics)
+ bool IMPLEMENT (has_posix_unlink_semantics_with_ignore_readonly)
bool IMPLEMENT (has_case_sensitive_dirs)
bool IMPLEMENT (has_posix_rename_semantics)
bool IMPLEMENT (no_msv1_0_s4u_logon_in_wow64)