Kernel changes and vfat case
#42 Henry, Monday, 01 February 2010 9:46 PM (Category: Gadgets)
(Tags: camera slackware)

In September 2001, I got my first digital camera - a Sony P50. I've had a number of Sony cameras and a few Canon cameras since then. In all cases, I would mount them manually on my Linux system as vfat filesystems and move the files to my hard disk manually. Since September 2001 till last month, the files were named like this - dsc001234.jpg. All lower case.

Last month there was a Linux kernel change, and the most obvious change was that hard drives that used to be named /dev/hda became /dev/sda. A less obvious change has been that when I mount my cameras as vfat filesystems and move the files, they now come across like this - DSC001234.JPG. All upper case.

I've asked a few knowledgeable people, and I've done a lot of reading on the matter. It appears that technically, all these years, interpreting vfat filenames as lower case has been wrong, and the new upper case way is the technically wrong way.

This sucks.

I have 25,000 photos organised neatly, sorted and arranged and all lower case. I have many scripts written to handle them, convert them for email and web, and do lots of neat things with them, all assuming they are lower case names. I'm a bit OCD about this. I want them to fit together, to be able to sort them and arrange them, and I want my scripts to keep working.

What are my choices? One choice is to edit all my scripts, and go and rename 25,000 photos, and the backups. That's not palatable. Another choice is to rename the files as I pull them off each camera. That's what I have been doing since the change. Don't want to continue doing this if there is an easier solution.

What I am looking for is some way of specifying lower case filenames when I access files on a vfat filesystem. So I am investigating mount options and maybe even something to do with udev rules. If I find anything, I'll comment about it here. In the meantime, I will continue cursing at people who can't leave things good things alone.

Anyway, filenames in all upper case suck. That's the bottom line. It offends my lower case sensibilities. :-)

The answer

Richard supplied me with the answer. I have to change my /etc/fstab to force lower case.

The camera usually mounts as /dev/sdc. The line in /etc/fstab used to read:

/dev/sdc1       /mnt/sdc        auto    noauto,users,sync  0 0

and to go back to the original behaviour, I change that line to read:

/dev/sdc1       /mnt/sdc        auto    noauto,users,sync,shortname=lower  0 0

There are a number of good articles that describe the compromises of behaviour when mounting vfat filesystems. One good one from 2005 is The vfat filesystem and Linux. It appears that if the filename fits the old DOS 8.3 format, it was incorrectly treated as lower case. Once the filename does not fit the 8.3 format, it is correctly interpreted as lower case. The shortname mount option was introduced to help decide how you get the filenames. So my acceptance of lower case filenames in 8.3 format for all these years was wrong.

I do not like upper case filenames, and I know that's petty and I don't care. I've been used to the lower case photo filenames since 2001, and at this point I am not really interested in going back and cleaning up my data and my scripts. I'll use this /etc/fstab change to let me continue this way for a while. Who knows what will happen in the future? I might give up photography, or find a camera that does things differently. I might get a serious case of the OCDs and go back and fix all my data and scripts. Or I could just switch totally to Mac and never have to worry about this sort of thing again (having other more serious issues to worry about).