Description of the program VFATCONF (for MagiC 5.01 onwards)
------------------------------------------------------------

Andreas Kromke
30.6.96
English translation: Peter West, April 99


1. What is VFATCONF?
--------------------

With this program one can find out on which floppy disks and hard disk 
drives long filenames are supported.


2. What kind of long filenames?
-------------------------------

Microsoft¾ has introduced with "Windows¾ 95¾" the possibility to store 
long¾ filenames¾ with up to 256¾ characters on normal DOS¾ media (floppy 
disks, hard drives, ...). A further restriction is, however, that the 
total path may be only up to 256 characters long, which is why MagiC also 
limits the maximum length for a single filename to 64 characters (i.e. 
including the terminating nullbyte there are 65 characters in total).

The long filenames are present in so-called Unicode, i.e. they may 
contain characters beyond the normal ASCII-coded ones - for instance even 
Japanese characters! (Unicode contains 65536 characters in total, the 
ASCII-code only 256). MagiC however is not capable of displaying these 
'exotics', and replaces them when reading in the directory with "¼".
Long filenames may contain mixed capitals and lower case letters and also 
spaces or several dots. The filetype is determined by the characters 
after the last dot, i.e. the file "Letter.to.taxoffice.Pap" has the 
filetype "*.PAP", so is a document of the Papyrus text processor.

In order to ensure compatibility with older software as well as 
interchangeability with other computer platforms, each file with a long 
filename also gets a unique second short-form name, i.e. in 8+3 form.
Older software finds only this short-form name on the drive, so instead 
of "this_is_a_long.name" it may be "THIS_~1.NAM", say. (The short-form 
names are decribed in Microsoft-jargon as aliases; to avoid confusion 
with the Macintosh-aliases and symbolic links, we refer to them as 
short-form names here.) If, however, a name already corresponds to the 
8+3 capitals format, then only one short-form name will be saved.

The difficulty for MagiC arises because one has to ensure that on certain 
drives no filenames longer than 8+3 are saved for compatibility reasons.
Otherwise some older software (KOBOLD, CORRECT, ...) could get totally 
confused. Since the information about whether or not long filenames are 
permitted on a given drive can not be saved to this drive, one needs 
VFATCONF. The name of this program derives from the fact that Microsoft 
describes the Windows95 filesystem as a "VFAT" system (virtual FAT), 
where the old system (also used in TOS) is called a FAT system.

So how can it happen that unintentional long filenames are created, if 
these are permitted on the corresponding drive? Some programs, even older 
ones, have the peculiarity of using filenames in lower case instead of 
capital letters. On the old FAT system this is immaterial, because the 
filenames are saved in capitals in any case (TOS fails here with Umlauts, 
but luckily there are only English-speakers in this world :-)). On a VFAT 
system, however, a file "label.txt" will be saved with a long filename 
"label.txt" and an associated short-form name "LABEL.TXT".


3. When is VFATCONF usable?
---------------------------

The version of VFATCONF described here runs with MagiC 5.01 for Atari,
Mac and PC.

With Ease versions older than 5.00 only short filenames in the 8+3 format 
are possible. So make absolutely sure that when using older versions of 
Ease you deactivate long filenames on all drives, including the floppy 
disk drives.
All other current shells (Gemini, Thing, Magxdesk) on the other hand are 
compatible to MagiC and hence can service long filenames.


4. Operation
------------

Start up the program. At the top the drives on which long filenames are 
currently permitted will appear as selected buttons. At bottom left there 
is a "temporary" button. Should you want to permit long filenames on an 
inserted and opened floppy disk for the short term without altering the 
basic settings, activate the button for drive A: or B: (as appropriate) 
and then the OK button. The shell will now rebuild the corresponding 
directory windows. If you change the diskette then the basic setting will 
be restored for the newly inserted floppy. The "temporary" setting is 
provided mainly for interchangeable media (floppies or hard drive 
cartridges etc.).

You can alter the basic setting after clicking on the "permanent" button 
at bottom left. You can now specify for each drive letter whether the 
drive on opening ("mounting") is to be operated with long or short-form 
filenames. These settings are only effective for drives that have not yet 
been opened; those already open have to be dealt with by means of the 
"temporary" function. If you have changed the "permanent" settings then 
VFATCONF saves the new settings in the configuration file MAGX.INF. For 
this MAGX.INF contains in the section "#[vfat]" the assignment, say,
"drives=fgh". With the aid of a text editor you can also enter this 
setting "manually" into MAGX.INF.

Note that with this program you can also activate long filenames on the 
boot drive. If, however, you wish to boot sometimes with older system 
software (TOS or derivatives), this could lead to conflicts; in 
particular write accesses may destroy the long filenames so that only 
the short-form names remain.

I recommend that on a hard disk you organise some partitions with long 
filenames and install on these partitions such software that can handle 
long filenames without problems. If you have to boot in TOS sometimes 
then the files saved there can be accessed by their short-form names.
But under no circumstances should you delete (or move or rename) files 
with long filenames under TOS, as in this case the long filename will 
remain, 'dead', in the directory and can not be deleted any more. On the 
other hand under MagiC, access (including deletion) is always possible 
via the short-form name and the long filename will be dealt with 
automatically at the same time. However this does not apply with long 
filenames on a drive where they have been deactivated with VFATCONF; in 
that case the same problems arise as access under TOS.

It is to be hoped that disk correction programs such as CHKDISK or 
CORRECT will be available soon that recognise long filenames correctly 
and can remove 'dead' entries if appropriate.


5. Technical description of the VFAT filesystem
-----------------------------------------------

typedef struct {
 char		head;		/* Bit 0..4: Number, bit 6: Endofname	*/
 unsigned char	name1[10];	/* 5 Unicode characters				*/
 char		attr;		/* Attribute (0x0f)					*/
 char		unused;
 char		chksum;		/* Checksum of the short-form name		*/
 unsigned char	name2[12];	/* 6 Unicode characters				*/
 WORD		stcl;		/* First cluster (0)				*/
 unsigned char	name3[4];		/* 2 Unicode characters				*/
} LDIR;

Here <head> for the first entry is, for instance, 0x01, for the second 
0x02 and for the third 0x43, if the name needs three entries. Up to 13 
characters can be saved per entry. The entries with the long filename 
always lie immediately before the main entry. The Unicode characters are 
in the Intel format, i.e. bytes swapped over, which is why I have 
declared them here as char instead of WORD. In the last entry after the 
nullbyte the unused characters will be filled with 0xff,0xff.
<stcl> is always Null.
<code> is a checksum.

One should also mention that the order of the entries is reversed, i.e. 
the last 13 characters of the long filename lie physically at the start. 
The last directory entry, the one that is identified with a set bit 6 in 
the <head> field, lies physically in the first position.

<chksum> is calculated from the short-form name (11 characters in 
internal format) by add and rotate operations. 
Linux uses the <unused> field to save flags for capitals/l.c. styles. The 
current Windows95  version, on the other hand, always writes NULLS into 
this field, and MagiC behaves in the same way.
