dcache and VFAT

Colin Plumb (colin@nyx.net)
Wed, 31 Dec 1997 18:43:14 -0700 (MST)


Bill Hawes wrote:
> After reading through this thread it seems to me that the key to making
> vfat work efficiently is to make sure that only the long filenames are
> ever instantiated as dentries. This can be done by looking up the short
> names in the d_compare operation, and if necessary creating the
> associated long filename dentry. Since a short filename can be detected
> by the presence of the ~ character, it shouldn't be necessary to do a
> disk lookup for long names, so this operation would remain fast.

The problem is, ~ is a legal character in a long filename.
For fun (and to find a bug in Windows 95), try the following from
the Windows 95 file manager:
- Create a new text file, foobarbaz.txt. Note that the
short name (File/pRoperties/MS-DOS name) is FOOBARBA.TXT.
- Now create another new file, foobarba.txt. Its short name
is FOOBAR~1.TXT.
- Now rename foobarbaz.txt to foobar~1.txt. The second file disappears!

(Well, until you hit refresh, and you find that its short name has
been magically changed to FOOBAR~3.TXT or some such.)

I'm still working on creating a file named "foobar~1.txt" with a short name
of "foobar~2.txt". Maybe it's not possible. (But VFAT better not crash
if fed a disk edited to contain such a nasty situation.)

But still, it's a bit tricky to distinguish short and long names.

-- 
	-Colin

(My ideas: Just maintain two dentries for VFAT files, one short and one long. The long is the "master", and the short is idnetified by the DCACHE_ALIAS bit being set in it. All of the VFAT operations know to instantiate both as needed, which is pretty easy in most cases since they're always neighbours on the d_child list; only occasionally do you have to do a full hash lookup.

The only externally-visible kludge you need is in d_lookup so that if the DCACHE_ALIAS flag is set in a dentry it finds, it searches along the d_child list for a "master" dentry and returns *that* instead of the alias. There may be a convention such as that the alias always comes after the master to make this easier.)