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

Posted on

QUESTION :

It’s easy to write two files to an NTFS partition from Linux, and have both of those files contain the same letters but with different case, e.g. some_file.txt and Some_File.txt. Linux distinguishes them.

How does Windows handle these?

ANSWER :

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:

HKLMSYSTEMCurrentControlSetControlSession Managerkernel 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:

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.

Leave a Reply

Your email address will not be published.