a little filename weirdness

I ran the following commands in WSL with PWD the home directory of an added user account.

echo 1 > aa
echo 12 > aA
echo 123 > Aa
echo 1234 > AA

In WSL ls shows 4 different files, and cat displays each of them as expected.

Then using Windows's CMD.EXE with the same working directory, the dir command shows 4 files named the same as under WSL, but the command type aa produces the output

1
1
1
1

Windows expects case-insensitive filenames. It sees 4 files named aa given case-insensitivity, and it seems to respond by displaying the aa file 4 times. Interesting possible way to hide files in plain sight.

Also problems with filenames containing valid chars under Linux but not allowed in Windows filenames. WSL seems to use UNICODE encodings of chas Windows doesn't support, so the valid Linux filename a:b becomes a#003Ab when listing the file under Windows.

Posted Aug 8, 2016, 8:11 PM UTC

48
[deleted]•

[deleted]

1
surface_book•

Yes, this is highly related to "the many reasons not to go from Windows -> lxss directories"

I remember playing with this and ended up in a situation with a different files I couldn't erase because Windows or Linux was confused. I don't remember exactly but I really did my best to break something, and I did.

1
hrlngrvOP•

From what I've seen, it's easier to create filenames in WSL which Windows can't handle rather than the opposite, but I'd like to see examples of the opposite.

IMO, it's a mistake to give Windows access to the WSL file system. Nasty anomalies due to file system difference are bound to show up over time.

1
surface_book•

To be fair, MS said don't touch it, and they did their best to hide it. I don't think it even shows up in File Explorer, even with hidden files shown.

1
hrlngrvOP•

Yes, the lxss directory has hidden and system attributes, so it doesn't show up in File Explorer with default settings.

MSFT could have ensured Windows couldn't touch it had MSFT followed, IIRC, the Lindows approach of using a single large Windows file as the entire WSL file system, thus making it impossible for Windows to access WSL-produced files except through WSL.

I have to try the same WSL commands with a /mnt/c subdirectory as the working directory. If WSL creates multiple files with case-sensitive filenames/same case-insensitive filename, then there'll almost certainly be problems going forward.

1
surface_book•

NTFS does support case sensitive file names, it's just not enabled by default. Then again, it's often argued that no one should rely on case sensitivity in a file system

1