Specification of the Umsdos file system for LINUX

# File name mangling

[linux/fs/umsdos/mangle.c,261]
#Specification: file name / non MSDOS conforming / mangling

Non MSDOS conforming file name must use some alias to fit in the MSDOS name space.

The strategy is simple. The name is simply truncated to 8 char. points are replace with underscore and a number is given as an extension. This number correspond to the entry number in the EMD file. The EMD file only need to carry the real name.

Upper case is also convert to lower case. Control character are converted to #. Space are converted to #. The following character are also converted to #.

    	    " * + , / : ; < = > ? [ \ ] | ~

Sometime, the problem is not in MsDOS itself but in command.com.

[linux/fs/umsdos/mangle.c,26]
#Specification: file name / non MSDOS conforming / mangling

Each non MSDOS conforming file has a special extension build from the entry position in the EMD file.

This number is then transform in a base 32 number, where each digit is expressed like hexadecimal number, using digit and letter, except it uses 22 letters from 'a' to 'v'. The number 32 comes from 2**5. It is faster to split a binary number using a base which is a power of two. And I was 32 when I started this project. Pick your answer :-) .

If the result is '0', it is replace with '_', simply to make it odd.

This is true for the first two character of the extension. The last one is taken from a list of odd character, which are:

{ } ( ) ! ` ^ & @

With this scheme, we can produce 9216 ( 9* 32 * 32) different extensions which should not clash with any useful extension already popular or meaningful. Since most directory have much less than 32 * 32 files in it, the first character of the extension of any mangle name will be {.

Here are the reason to do this (this kind of mangling).

-The mangling is deterministic. Just by the extension, we are able to locate the entry in the EMD file.

-By keeping to beginning of the file name almost unchanged, we are helping the MSDOS user.

-The mangling produces names not too ugly, so an msdos user may live with it (remember it, type it, etc...).

-The mangling produces names ugly enough so no one will ever think of using such a name in real life. This is not fool proof. I don't think there is a total solution to this.

[linux/fs/umsdos/mangle.c,306]
#Specification: file name / MSDOS devices / mangling

To avoid unreachable file from MsDOS, any MsDOS conforming file with a basename equal to one of the MsDOS pseudo devices will be mangled.

If a file such as "prn" was created, it would be unreachable under MsDOS because prn is assumed to be the printer, even if the file does have an extension.

Since the extension is unimportant to MsDOS, we must patch the basename also. We simply insert a minus '-'. To avoid conflict with valid file with a minus in front (such as "-prn"), we add an mangled extension like any other mangled file name.

Here is the list of DOS pseudo devices:

    	    "prn","con","aux","nul",
    	    "lpt1","lpt2","lpt3","lpt4",
    	    "com1","com2","com3","com4",
    	    "clock$"

and some standard ones for common DOS programs

"emmxxxx0","xmsxxxx0","setverxx"

(Thanks to Chris Hall for pointing these to me).

Is there one missing ?

[linux/fs/umsdos/mangle.c,257]
#Specification: file name / --linux-.---

The name of the EMD file --linux-.--- is map to a mangled name. So UMSDOS does not restrict its use.

[linux/fs/umsdos/mangle.c,147]
#Specification: file name / non MSDOS conforming / base length 0

file name beginning with a period '.' are invalid for MsDOS. It needs absolutely a base name. So the file name is mangled

[linux/fs/umsdos/mangle.c,220]
#Specification: file name / non MSDOS conforming / mangling clash

To avoid clash with the umsdos mangling, any file with a special character as the first character of the extension will be mangled. This solve the following problem:

    	touch FILE
    	# FILE is invalid for DOS, so mangling is applied
    	# file.{_1 is created in the DOS directory
    	touch file.{_1
    	# To UMSDOS file point to a single DOS entry.
    	# So file.{_1 has to be mangled.

[linux/fs/umsdos/mangle.c,212]
#Specification: file name / non MSDOS conforming / last char == .

If the last character of a file name is a period, mangling is applied. MsDOS do not support those file name.

[linux/fs/umsdos/mangle.c,139]
#Specification: file name / too long

If a file name exceed UMSDOS maxima, the file name is silently truncated. This makes it conformant with the other file system of Linux (minix and ext2 at least).