Filesystem Case Sensitivity

Filesystem Case Sensitivity

There may be many reasons why you must have filesystem that is case sensitive.  For example, you are trying to run ct-ng build command and it fails under Windows WSL.

Solution is to mount your filesystem with case sensitive enabled, or use per-directory control.   The second option gives your more control, but the sub-directories do not inherit properties from the parent (update: directory inheritance behavior has changed summer of 2019).  To do that, open a command shell as an administrator and run:

fsutil file setCaseSensitiveInfo <directory> enable

First option, to mount your directory under WSL as case-sensitive file system, edit (create if it doesn't exist) /etc/wsl.conf and add:

options = case=dir

Restart WSL shell so that the configuration can be read.  Type mount command and you should see:

C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=dir)

Notice case=dir option listed in the parenthesis.  Now ct-ng build command will not complain if the directory is case-sensitive.  This only works with file systems that support case sensitivity (for example NTFS, not FAT).

To mark a directory as case-sensitive use above fsutil command, or install attr command.  Then type:

setfattr -n system.wsl_case_sensitive -v 1 ...

Windows permission will take precedence over WSL, so use fsutil if setfattr does not work.  You can see if a directory handles case-sensitive names by typing:

getfattr -n system.wsl_case_sensitive ...

With the new inheritance behavior and the option to create new directories as case-sensitive, you should be able to create a case-sensitive top level parent directory and never have to worry about conflicting file names again.

Mount Errors

If dmesg command complains of file translation errors after a version update and /mnt/c isn't automatically mounted in WSL, most likely the option you used to mount DrvFS isn't supported.

CMake and Compiler Errors

Compiling fails using Visual Studio 2015 under directory that is case sensitive.  Compiler will complain it is unable to find a file, but you can clearly see it right there.  You'll get error messages from cmake saying cl.exe -- broken.  Check and make sure the directory has case sensitivity disabled and cmake should work fine.

Visual Studio Code

Once tool chain is built, Visual Studio Code will always have problems with the directory because it does not know how to deal with symbolic links (they appear as NTFS junctions) and files with the same name but different cases (many header files do this).  You will get a message saying folder "contains emphasized items," which is no help at all.  Just remember not to manipulate files under the tool chain directory outside of WSL, in programs like Visual Studio Code.