What is the default expected behavior when Windows encounters two files with the same name but different capitalization in an NTFS partition?

Solution 1:

The MS-DOS, WOW, and Win32 personalities will return the first matching file. For some applications and APIs, case-insensitivity is enforced (e.g., MS-DOS just can't deal with it). The POSIX personality will differentiate and is case sensitive by default (if you have the UNIX tools installed, for example). The native Windows NT command prompt will display both but, depending on settings (ObCaseInsensitive) and which APIs the tools use, only access the first one it finds.

See Microsoft Technet article Filenames are Case Sensitive on NTFS Volumes (KB100625) and also a detailed discussion of the subtleties of case sensitivity in the various NT subsystems: Understanding case sensitivity in Windows: obcaseinsensitive, FILE_CASE_SENSITIVE_SEARCH

In particular, the ObCaseInsensitive value controls the case sensitivity of the entire NT Object Manager:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\ dword:ObCaseInsensitive
  • When set to 0, the object manager runs in case sensitive mode.
  • When set to 1, the object manager runs in case insensitive mode.
  • When unspecified, NT 5.1 (Windows XP) and later editions default to running in case insensitive mode.
  • obcaseinsensitive has no meaning in NT 5.0 (Windows 2000) and prior versions of NT, which always run in case sensitive mode.

Cygwin should pick up the underlying/effective case-sensitivity settings at this point.

The related SuperUser question How to configure folder name case sensitivity in Windows 7? and TechNet article Configure Case Sensitivity for File and Folder Names have more information on enabling full case sensitivity for files and folders in NT if you will need to handle this situation regularly.

Additional resources on case-sensitive tooling/access to NTFS/NFS volumes:

  • Windows Services for UNIX
  • Utilities and SDK for Subsystem for UNIX-based Applications in Windows 8 and Windows Server 2012

Solution 2:

It doesn't. It considers case differences but otherwise exact same names to be the same file.

You can test this by creating a file in all lowercase, then creating another with only one letter in upper and it will complain.