Cygwin: don't use unlink/rename POSIX semantics on certain NTFS
If a host NTFS is mapped into a Hyper-V isolated container, the OPEN_BY_FILE_ID filesystem flag is missing, just as if that NTFS is a remote drive. However, NtQueryVolumeInformationFile claims the drive is a local drive. We can use this fact to learn that the process is running under Hyper-V, and that the Hyper-V isolated process can't use rename/unlink with POSIX semantics. Strange enough, the POSIX_UNLINK_RENAME filesystem flag is still set... Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
0a962aa2c2
commit
fe2545e9fa
|
@ -691,10 +691,12 @@ unlink_nt (path_conv &pc, bool shareable)
|
|||
pc.get_object_attr (attr, sec_none_nih);
|
||||
|
||||
/* 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. */
|
||||
For the OPEN_BY_FILE_ID flag, see MINIMAL_WIN_NTFS_FLAGS comment in
|
||||
fs_info::update. 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 ()
|
||||
&& !pc.isremote () && pc.fs_is_ntfs ())
|
||||
&& !pc.isremote () && pc.fs_is_ntfs ()
|
||||
&& pc.has_attribute (FILE_SUPPORTS_OPEN_BY_FILE_ID))
|
||||
{
|
||||
FILE_DISPOSITION_INFORMATION_EX fdie;
|
||||
|
||||
|
@ -2407,10 +2409,12 @@ rename2 (const char *oldpath, const char *newpath, unsigned int at2flags)
|
|||
__leave;
|
||||
}
|
||||
|
||||
/* POSIX semantics only on local NTFS drives. */
|
||||
/* POSIX semantics only on local NTFS drives. For the OPEN_BY_FILE_ID
|
||||
flag, see MINIMAL_WIN_NTFS_FLAGS comment in fs_info::update. */
|
||||
use_posix_semantics = wincap.has_posix_rename_semantics ()
|
||||
&& !oldpc.isremote ()
|
||||
&& oldpc.fs_is_ntfs ();
|
||||
&& oldpc.fs_is_ntfs ()
|
||||
&& oldpc.has_attribute (FILE_SUPPORTS_OPEN_BY_FILE_ID);
|
||||
|
||||
/* Opening the file must be part of the transaction. It's not sufficient
|
||||
to call only NtSetInformationFile under the transaction. Therefore we
|
||||
|
|
Loading…
Reference in New Issue