diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2018-12-25 03:09:12 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-12-25 03:09:12 +0300 |
commit | 4021509ba28e7ce6cec63ed15bc904805b566bbc (patch) | |
tree | e1172ec9911004a0c5f38e0a0c3e0ae716c682e9 | |
parent | 92edcf929ae862a97bb0b8d0494c84b4e1b748b9 (diff) |
Cygwin: mkdir: create case-sensitive dirs
On Windows 10 1803 and later, create dirs under the Cygwin
installation dir as case sensitive, if WSL is installed.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index b58b8442a..a8b7af44b 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1760,6 +1760,10 @@ fhandler_disk_file::mkdir (mode_t mode) I don't know what setting that is or how to recognize such a share, so for now we don't request WRITE_DAC on remote drives. */ access |= READ_CONTROL | WRITE_DAC; + /* Setting case sensitivity requires FILE_WRITE_ATTRIBUTES. */ + if (wincap.has_case_sensitive_dirs () + && !pc.isremote () && pc.fs_is_ntfs ()) + access |= FILE_WRITE_ATTRIBUTES; status = NtCreateFile (&dir, access, pc.get_object_attr (attr, sa), &io, NULL, FILE_ATTRIBUTE_DIRECTORY, FILE_SHARE_VALID_FLAGS, FILE_CREATE, @@ -1773,6 +1777,36 @@ fhandler_disk_file::mkdir (mode_t mode) pc.file_attributes (FILE_ATTRIBUTE_DIRECTORY); if (has_acls ()) set_created_file_access (dir, pc, mode & 07777); + /* Starting with Windows 10 1803, try to create all dirs below the + installation root as case-sensitive. If STATUS_NOT_SUPPORTED + is returned, WSL isn't installed (unfortunately a requirement + for this functionality. */ + if (wincap.has_case_sensitive_dirs () + && !pc.isremote () && pc.fs_is_ntfs ()) + { + PUNICODE_STRING new_dir = pc.get_nt_native_path (); + PUNICODE_STRING root_dir = &cygheap->installation_root; + + if (RtlEqualUnicodePathPrefix (new_dir, root_dir, TRUE) + && new_dir->Buffer[root_dir->Length / sizeof (WCHAR)] == L'\\') + { + FILE_CASE_SENSITIVE_INFORMATION fcsi; + + fcsi.Flags = FILE_CS_FLAG_CASE_SENSITIVE_DIR; + status = NtSetInformationFile (dir, &io, &fcsi, sizeof fcsi, + FileCaseSensitiveInformation); + if (!NT_SUCCESS (status)) + { + debug_printf ("Setting dir case sensitivity, status %y", + status); + if (status == STATUS_NOT_SUPPORTED) + { + debug_printf ("Dir case sensitivity requires WSL"); + wincap.disable_case_sensitive_dirs (); + } + } + } + } NtClose (dir); res = 0; } |