Why is NTFS case sensitive?

25

7

I personally thought that NTFS was case insensitive, since you can type cmd, CMD, cMd or even CmD and still get the command prompt. However, why is it that during a CHKDSK x: /f /r, sometimes it fixes capitalization in some files? If it didn't care about the case, it shouldn't matter about that, and CHKDSK shouldn't be checking if it's actually CMD or cmd. Am I right? Where does it actually matter in the file system?

Canadian Luke

Posted 2011-12-02T20:45:43.783

Reputation: 22 162

26Note that "case-sensitive" and "case-preserving" are two separate things. NTFS is case-preserving but case-insensitive in the Win32 namespace, but can be case-sensitive in POSIX namespace. – user1686 – 2011-12-02T22:09:27.457

Answers

35

The case sensitivity of a file system is a separate issue from that of an operating system. Latest Windows releases are based on the NT kernel, which inherits a lot of properties of the non-NT Windows 95 and even MS-DOS. Along with the NT kernel the file system, NTFS, was designed to be case sensitive -- to be POSIX compliant.

Although the Win32 subsystem does not support file names that only differ by case sensitivity, it is possible to create those files with lower level system calls.

Frank

Posted 2011-12-02T20:45:43.783

Reputation: 730

Good find! I wouldn't mind learning then how to create those same 3 files in one folder – Canadian Luke – 2011-12-02T23:03:04.170

1I'm not aware of an easy way to create such files in Windows. However, calling CreateFile() API with FILE_FLAG_POSIX_SEMANTICS bit should do the job programmatically. – Frank – 2011-12-02T23:19:45.760

2

@Luke: Win32 does not support case sensitive files. YOu'll have to make API calls into the OS subsystem. http://www.osronline.com/article.cfm?id=91

– surfasb – 2011-12-02T23:26:12.413

2@Luke: One easy way would be to mount the NTFS drive from a Linux system and create the files you wish there :) – Hippo – 2011-12-03T04:40:17.853

1Just make sure that you have the right version of Windows NT and install the Subsystem for UNIX-based Applications utilities, people. – JdeBP – 2011-12-03T21:05:00.330

@JdeBP Just for the sake of curiosity... What different versions of NTFS are there? – Canadian Luke – 2011-12-08T17:35:07.133

1

@Luke: As usual, Wikipedia to the rescue. :-)

– afrazier – 2011-12-08T17:57:53.673

7

It actually isn't NTFS that you are inquiring about.

NTFS is the filesystem. Your question is really about the case-sensitivity of the Windows command shell. They're completely different. Windows Explorer is a graphical command shell. By entring cmd (in Start | Run for example) you're telling the Windows command shell to execute the command cmd (which itself is actually another command shell, but command line based rather than graphical).

Similarly, CHKDSK is not doing any kind of check on whether you used CMD or cmd. All CHKDSK knows about are the parameters you pass to it, which in this case are x:, /f and /r.

As for CHKDSK "fixing capitalization", I'm not really sure what you mean there.

squillman

Posted 2011-12-02T20:45:43.783

Reputation: 5 676

4The NTFS is case-sensitive. According to MS KB article 100625: In NTFS, you can create unique file names, stored in the same directory, that differ only in case. For example, the following filenames can coexist in one directory on an NTFS volume: CASE.TXT case.txt case.TXT However, if you attempt to open one of these files in a Win32 application, such as Notepad, you would only have access to one of the files, regardless of the case of the filename you type in the Open File dialog box. – Frank – 2011-12-02T21:03:04.510

That is true, thank you for clarifying that. I've taken that bit out of my answer since it's not really what is in question here anyway. – squillman – 2011-12-02T21:10:27.623

> However, if you attempt to open one of these files in a Win32 application, such as Notepad, you would only have access to one of the files, regardless of the case of the filename you type in the Open File dialog box Which one? – Synetech – 2011-12-03T23:03:44.717

4@Synetech: The first one, perhaps? Depends on the file order in the directory, and possibly the moon phase. – user1686 – 2011-12-04T00:10:35.357

5

I suspect the question asker's claim that chkdsk.exe is "fixing capitalization in some files" is actually prompted by the message from CHKDSK that occurs under some circumstances:

correcting errors in the uppercase file

Basically, this results from a Windows XP version of chkdsk.exe running against an NTFS volume that has been formatted in a later version of Windows, as described in Error message when you run Chkdsk.exe on a Windows XP-based or on a Windows Server 2003-based computer: “Correcting errors in the uppercase file”. The upshot is that this is really not an error, and has nothing to do with case sensitivity.

kreemoweet

Posted 2011-12-02T20:45:43.783

Reputation: 3 884