why mounted vfat volume is case sensitive partially?

1

2

I have strange observation. I mounted vfat filesystem like this:

mount -t vfat -o loop vfat.vol mnt

I expected it would be case insensitive. And it is as long as file name length is no longer than 8! I can't create two different files: x1234567 and X1234567, but I can create x12345678 and X12345678 ! It is 100% reproductible with simple echo "abc" >filename command. What is going on here? How to make fat volume 100% case insensitive?

ardabro

Posted 2015-04-02T06:24:44.730

Reputation: 383

Answers

2

This happens because file names longer than 8 characters are not supported by FAT directly, but via LFN extension. FAT is indeed case-insensitive, that's why you can't create x1234567 and X1234567 files. However, when you create files with long names, short file names are created instead, plus an LFN entry which holds the full name.

So when you create files x12345678 and X12345678, these files are given short names like X12345~1 and X12345~2, which are valid and different FAT names. Linux has a relaxed attitude towards checking the uniqueness of LFN entries, so you end up creating two entries which are differentiated only by case; something Windows wouldn't allow. But this is a limitation (or rather a feature) of Windows, not the FAT file system.

Sidenote: I bet you can also create a file named CON in linux on a FAT volume.

See vfat documentation for mount options which define how linux should work with file names.

Dmitry Grigoryev

Posted 2015-04-02T06:24:44.730

Reputation: 7 505

Ok, so I consider it a bug in linux driver. Thanks. – ardabro – 2015-04-03T05:59:41.243