xref: /linux/Documentation/filesystems/vfat.rst (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
1a1986433SDaniel W. S. Almeida====
2a1986433SDaniel W. S. AlmeidaVFAT
3a1986433SDaniel W. S. Almeida====
4a1986433SDaniel W. S. Almeida
5a1986433SDaniel W. S. AlmeidaUSING VFAT
6a1986433SDaniel W. S. Almeida==========
7a1986433SDaniel W. S. Almeida
8a1986433SDaniel W. S. AlmeidaTo use the vfat filesystem, use the filesystem type 'vfat'.  i.e.::
9a1986433SDaniel W. S. Almeida
10a1986433SDaniel W. S. Almeida  mount -t vfat /dev/fd0 /mnt
11a1986433SDaniel W. S. Almeida
12a1986433SDaniel W. S. Almeida
13a1986433SDaniel W. S. AlmeidaNo special partition formatter is required,
14a1986433SDaniel W. S. Almeida'mkdosfs' will work fine if you want to format from within Linux.
15a1986433SDaniel W. S. Almeida
16a1986433SDaniel W. S. AlmeidaVFAT MOUNT OPTIONS
17a1986433SDaniel W. S. Almeida==================
18a1986433SDaniel W. S. Almeida
19a1986433SDaniel W. S. Almeida**uid=###**
20a1986433SDaniel W. S. Almeida	Set the owner of all files on this filesystem.
21a1986433SDaniel W. S. Almeida	The default is the uid of current process.
22a1986433SDaniel W. S. Almeida
23a1986433SDaniel W. S. Almeida**gid=###**
24a1986433SDaniel W. S. Almeida	Set the group of all files on this filesystem.
25a1986433SDaniel W. S. Almeida	The default is the gid of current process.
26a1986433SDaniel W. S. Almeida
27a1986433SDaniel W. S. Almeida**umask=###**
28a1986433SDaniel W. S. Almeida	The permission mask (for files and directories, see *umask(1)*).
29a1986433SDaniel W. S. Almeida	The default is the umask of current process.
30a1986433SDaniel W. S. Almeida
31a1986433SDaniel W. S. Almeida**dmask=###**
32a1986433SDaniel W. S. Almeida	The permission mask for the directory.
33a1986433SDaniel W. S. Almeida	The default is the umask of current process.
34a1986433SDaniel W. S. Almeida
35a1986433SDaniel W. S. Almeida**fmask=###**
36a1986433SDaniel W. S. Almeida	The permission mask for files.
37a1986433SDaniel W. S. Almeida	The default is the umask of current process.
38a1986433SDaniel W. S. Almeida
39a1986433SDaniel W. S. Almeida**allow_utime=###**
40a1986433SDaniel W. S. Almeida	This option controls the permission check of mtime/atime.
41a1986433SDaniel W. S. Almeida
42a1986433SDaniel W. S. Almeida		**-20**: If current process is in group of file's group ID,
43a1986433SDaniel W. S. Almeida                you can change timestamp.
44a1986433SDaniel W. S. Almeida
45a1986433SDaniel W. S. Almeida		**-2**: Other users can change timestamp.
46a1986433SDaniel W. S. Almeida
47a1986433SDaniel W. S. Almeida	The default is set from dmask option. If the directory is
48a1986433SDaniel W. S. Almeida	writable, utime(2) is also allowed. i.e. ~dmask & 022.
49a1986433SDaniel W. S. Almeida
50a1986433SDaniel W. S. Almeida	Normally utime(2) checks current process is owner of
51a1986433SDaniel W. S. Almeida	the file, or it has CAP_FOWNER capability. But FAT
52a1986433SDaniel W. S. Almeida	filesystem doesn't have uid/gid on disk, so normal
53*d56b699dSBjorn Helgaas	check is too inflexible. With this option you can
54a1986433SDaniel W. S. Almeida	relax it.
55a1986433SDaniel W. S. Almeida
56a1986433SDaniel W. S. Almeida**codepage=###**
57a1986433SDaniel W. S. Almeida	Sets the codepage number for converting to shortname
58a1986433SDaniel W. S. Almeida	characters on FAT filesystem.
59a1986433SDaniel W. S. Almeida	By default, FAT_DEFAULT_CODEPAGE setting is used.
60a1986433SDaniel W. S. Almeida
61a1986433SDaniel W. S. Almeida**iocharset=<name>**
62a1986433SDaniel W. S. Almeida	Character set to use for converting between the
63a1986433SDaniel W. S. Almeida	encoding is used for user visible filename and 16 bit
64a1986433SDaniel W. S. Almeida	Unicode characters. Long filenames are stored on disk
65a1986433SDaniel W. S. Almeida	in Unicode format, but Unix for the most part doesn't
66a1986433SDaniel W. S. Almeida	know how to deal with Unicode.
67a1986433SDaniel W. S. Almeida	By default, FAT_DEFAULT_IOCHARSET setting is used.
68a1986433SDaniel W. S. Almeida
69a1986433SDaniel W. S. Almeida	There is also an option of doing UTF-8 translations
70a1986433SDaniel W. S. Almeida	with the utf8 option.
71a1986433SDaniel W. S. Almeida
72a1986433SDaniel W. S. Almeida.. note:: ``iocharset=utf8`` is not recommended. If unsure, you should consider
73a1986433SDaniel W. S. Almeida	  the utf8 option instead.
74a1986433SDaniel W. S. Almeida
75a1986433SDaniel W. S. Almeida**utf8=<bool>**
76a1986433SDaniel W. S. Almeida	UTF-8 is the filesystem safe version of Unicode that
77a1986433SDaniel W. S. Almeida	is used by the console. It can be enabled or disabled
78a1986433SDaniel W. S. Almeida	for the filesystem with this option.
79a1986433SDaniel W. S. Almeida	If 'uni_xlate' gets set, UTF-8 gets disabled.
80a1986433SDaniel W. S. Almeida	By default, FAT_DEFAULT_UTF8 setting is used.
81a1986433SDaniel W. S. Almeida
82a1986433SDaniel W. S. Almeida**uni_xlate=<bool>**
83a1986433SDaniel W. S. Almeida	Translate unhandled Unicode characters to special
84a1986433SDaniel W. S. Almeida	escaped sequences.  This would let you backup and
85a1986433SDaniel W. S. Almeida	restore filenames that are created with any Unicode
86a1986433SDaniel W. S. Almeida	characters.  Until Linux supports Unicode for real,
87a1986433SDaniel W. S. Almeida	this gives you an alternative.  Without this option,
88a1986433SDaniel W. S. Almeida	a '?' is used when no translation is possible.  The
89a1986433SDaniel W. S. Almeida	escape character is ':' because it is otherwise
90a1986433SDaniel W. S. Almeida	illegal on the vfat filesystem.  The escape sequence
91a1986433SDaniel W. S. Almeida	that gets used is ':' and the four digits of hexadecimal
92a1986433SDaniel W. S. Almeida	unicode.
93a1986433SDaniel W. S. Almeida
94a1986433SDaniel W. S. Almeida**nonumtail=<bool>**
95a1986433SDaniel W. S. Almeida	When creating 8.3 aliases, normally the alias will
96a1986433SDaniel W. S. Almeida	end in '~1' or tilde followed by some number.  If this
97a1986433SDaniel W. S. Almeida	option is set, then if the filename is
98a1986433SDaniel W. S. Almeida	"longfilename.txt" and "longfile.txt" does not
99a1986433SDaniel W. S. Almeida	currently exist in the directory, longfile.txt will
100a1986433SDaniel W. S. Almeida	be the short alias instead of longfi~1.txt.
101a1986433SDaniel W. S. Almeida
102a1986433SDaniel W. S. Almeida**usefree**
103a1986433SDaniel W. S. Almeida	Use the "free clusters" value stored on FSINFO. It will
104a1986433SDaniel W. S. Almeida	be used to determine number of free clusters without
105a1986433SDaniel W. S. Almeida	scanning disk. But it's not used by default, because
106a1986433SDaniel W. S. Almeida	recent Windows don't update it correctly in some
107a1986433SDaniel W. S. Almeida	case. If you are sure the "free clusters" on FSINFO is
108a1986433SDaniel W. S. Almeida	correct, by this option you can avoid scanning disk.
109a1986433SDaniel W. S. Almeida
110a1986433SDaniel W. S. Almeida**quiet**
111a1986433SDaniel W. S. Almeida	Stops printing certain warning messages.
112a1986433SDaniel W. S. Almeida
113a1986433SDaniel W. S. Almeida**check=s|r|n**
114a1986433SDaniel W. S. Almeida	Case sensitivity checking setting.
115a1986433SDaniel W. S. Almeida
116a1986433SDaniel W. S. Almeida	**s**: strict, case sensitive
117a1986433SDaniel W. S. Almeida
118a1986433SDaniel W. S. Almeida	**r**: relaxed, case insensitive
119a1986433SDaniel W. S. Almeida
120a1986433SDaniel W. S. Almeida	**n**: normal, default setting, currently case insensitive
121a1986433SDaniel W. S. Almeida
122a1986433SDaniel W. S. Almeida**nocase**
123a1986433SDaniel W. S. Almeida	This was deprecated for vfat. Use ``shortname=win95`` instead.
124a1986433SDaniel W. S. Almeida
125a1986433SDaniel W. S. Almeida**shortname=lower|win95|winnt|mixed**
126a1986433SDaniel W. S. Almeida	Shortname display/create setting.
127a1986433SDaniel W. S. Almeida
128a1986433SDaniel W. S. Almeida	**lower**: convert to lowercase for display,
129a1986433SDaniel W. S. Almeida	emulate the Windows 95 rule for create.
130a1986433SDaniel W. S. Almeida
131a1986433SDaniel W. S. Almeida	**win95**: emulate the Windows 95 rule for display/create.
132a1986433SDaniel W. S. Almeida
133a1986433SDaniel W. S. Almeida	**winnt**: emulate the Windows NT rule for display/create.
134a1986433SDaniel W. S. Almeida
135a1986433SDaniel W. S. Almeida	**mixed**: emulate the Windows NT rule for display,
136a1986433SDaniel W. S. Almeida	emulate the Windows 95 rule for create.
137a1986433SDaniel W. S. Almeida
138a1986433SDaniel W. S. Almeida	Default setting is `mixed`.
139a1986433SDaniel W. S. Almeida
140a1986433SDaniel W. S. Almeida**tz=UTC**
141a1986433SDaniel W. S. Almeida	Interpret timestamps as UTC rather than local time.
142a1986433SDaniel W. S. Almeida	This option disables the conversion of timestamps
143a1986433SDaniel W. S. Almeida	between local time (as used by Windows on FAT) and UTC
144a1986433SDaniel W. S. Almeida	(which Linux uses internally).  This is particularly
145a1986433SDaniel W. S. Almeida	useful when mounting devices (like digital cameras)
146a1986433SDaniel W. S. Almeida	that are set to UTC in order to avoid the pitfalls of
147a1986433SDaniel W. S. Almeida	local time.
148a1986433SDaniel W. S. Almeida
149a1986433SDaniel W. S. Almeida**time_offset=minutes**
150a1986433SDaniel W. S. Almeida	Set offset for conversion of timestamps from local time
151a1986433SDaniel W. S. Almeida	used by FAT to UTC. I.e. <minutes> minutes will be subtracted
152a1986433SDaniel W. S. Almeida	from each timestamp to convert it to UTC used internally by
153a1986433SDaniel W. S. Almeida	Linux. This is useful when time zone set in ``sys_tz`` is
154a1986433SDaniel W. S. Almeida	not the time zone used by the filesystem. Note that this
155a1986433SDaniel W. S. Almeida	option still does not provide correct time stamps in all
156a1986433SDaniel W. S. Almeida	cases in presence of DST - time stamps in a different DST
157a1986433SDaniel W. S. Almeida	setting will be off by one hour.
158a1986433SDaniel W. S. Almeida
159a1986433SDaniel W. S. Almeida**showexec**
160a1986433SDaniel W. S. Almeida	If set, the execute permission bits of the file will be
161a1986433SDaniel W. S. Almeida	allowed only if the extension part of the name is .EXE,
162a1986433SDaniel W. S. Almeida	.COM, or .BAT. Not set by default.
163a1986433SDaniel W. S. Almeida
164a1986433SDaniel W. S. Almeida**debug**
165a1986433SDaniel W. S. Almeida	Can be set, but unused by the current implementation.
166a1986433SDaniel W. S. Almeida
167a1986433SDaniel W. S. Almeida**sys_immutable**
168a1986433SDaniel W. S. Almeida	If set, ATTR_SYS attribute on FAT is handled as
169a1986433SDaniel W. S. Almeida	IMMUTABLE flag on Linux. Not set by default.
170a1986433SDaniel W. S. Almeida
171a1986433SDaniel W. S. Almeida**flush**
172a1986433SDaniel W. S. Almeida	If set, the filesystem will try to flush to disk more
173a1986433SDaniel W. S. Almeida	early than normal. Not set by default.
174a1986433SDaniel W. S. Almeida
175a1986433SDaniel W. S. Almeida**rodir**
176a1986433SDaniel W. S. Almeida	FAT has the ATTR_RO (read-only) attribute. On Windows,
177a1986433SDaniel W. S. Almeida	the ATTR_RO of the directory will just be ignored,
178a1986433SDaniel W. S. Almeida	and is used only by applications as a flag (e.g. it's set
179a1986433SDaniel W. S. Almeida	for the customized folder).
180a1986433SDaniel W. S. Almeida
181a1986433SDaniel W. S. Almeida	If you want to use ATTR_RO as read-only flag even for
182a1986433SDaniel W. S. Almeida	the directory, set this option.
183a1986433SDaniel W. S. Almeida
184a1986433SDaniel W. S. Almeida**errors=panic|continue|remount-ro**
185a1986433SDaniel W. S. Almeida	specify FAT behavior on critical errors: panic, continue
186a1986433SDaniel W. S. Almeida	without doing anything or remount the partition in
187a1986433SDaniel W. S. Almeida	read-only mode (default behavior).
188a1986433SDaniel W. S. Almeida
189a1986433SDaniel W. S. Almeida**discard**
190a1986433SDaniel W. S. Almeida	If set, issues discard/TRIM commands to the block
191a1986433SDaniel W. S. Almeida	device when blocks are freed. This is useful for SSD devices
1921ccc4a39SBhaskar Chowdhury	and sparse/thinly-provisioned LUNs.
193a1986433SDaniel W. S. Almeida
194a1986433SDaniel W. S. Almeida**nfs=stale_rw|nostale_ro**
195a1986433SDaniel W. S. Almeida	Enable this only if you want to export the FAT filesystem
196a1986433SDaniel W. S. Almeida	over NFS.
197a1986433SDaniel W. S. Almeida
198a1986433SDaniel W. S. Almeida		**stale_rw**: This option maintains an index (cache) of directory
199a1986433SDaniel W. S. Almeida		*inodes* by *i_logstart* which is used by the nfs-related code to
200a1986433SDaniel W. S. Almeida		improve look-ups. Full file operations (read/write) over NFS is
201a1986433SDaniel W. S. Almeida		supported but with cache eviction at NFS server, this could
202a1986433SDaniel W. S. Almeida		result in ESTALE issues.
203a1986433SDaniel W. S. Almeida
204a1986433SDaniel W. S. Almeida		**nostale_ro**: This option bases the *inode* number and filehandle
205a1986433SDaniel W. S. Almeida		on the on-disk location of a file in the MS-DOS directory entry.
206a1986433SDaniel W. S. Almeida		This ensures that ESTALE will not be returned after a file is
207a1986433SDaniel W. S. Almeida		evicted from the inode cache. However, it means that operations
208a1986433SDaniel W. S. Almeida		such as rename, create and unlink could cause filehandles that
209a1986433SDaniel W. S. Almeida		previously pointed at one file to point at a different file,
210a1986433SDaniel W. S. Almeida		potentially causing data corruption. For this reason, this
211a1986433SDaniel W. S. Almeida		option also mounts the filesystem readonly.
212a1986433SDaniel W. S. Almeida
213a1986433SDaniel W. S. Almeida	To maintain backward compatibility, ``'-o nfs'`` is also accepted,
214a1986433SDaniel W. S. Almeida	defaulting to "stale_rw".
215a1986433SDaniel W. S. Almeida
216a1986433SDaniel W. S. Almeida**dos1xfloppy  <bool>: 0,1,yes,no,true,false**
217a1986433SDaniel W. S. Almeida	If set, use a fallback default BIOS Parameter Block
218a1986433SDaniel W. S. Almeida	configuration, determined by backing device size. These static
219a1986433SDaniel W. S. Almeida	parameters match defaults assumed by DOS 1.x for 160 kiB,
220a1986433SDaniel W. S. Almeida	180 kiB, 320 kiB, and 360 kiB floppies and floppy images.
221a1986433SDaniel W. S. Almeida
222a1986433SDaniel W. S. Almeida
223a1986433SDaniel W. S. Almeida
224a1986433SDaniel W. S. AlmeidaLIMITATION
225a1986433SDaniel W. S. Almeida==========
226a1986433SDaniel W. S. Almeida
227a1986433SDaniel W. S. AlmeidaThe fallocated region of file is discarded at umount/evict time
228a1986433SDaniel W. S. Almeidawhen using fallocate with FALLOC_FL_KEEP_SIZE.
229a1986433SDaniel W. S. AlmeidaSo, User should assume that fallocated region can be discarded at
230a1986433SDaniel W. S. Almeidalast close if there is memory pressure resulting in eviction of
231a1986433SDaniel W. S. Almeidathe inode from the memory. As a result, for any dependency on
232a1986433SDaniel W. S. Almeidathe fallocated region, user should make sure to recheck fallocate
233a1986433SDaniel W. S. Almeidaafter reopening the file.
234a1986433SDaniel W. S. Almeida
235a1986433SDaniel W. S. AlmeidaTODO
236a1986433SDaniel W. S. Almeida====
237a1986433SDaniel W. S. AlmeidaNeed to get rid of the raw scanning stuff.  Instead, always use
238a1986433SDaniel W. S. Almeidaa get next directory entry approach.  The only thing left that uses
239a1986433SDaniel W. S. Almeidaraw scanning is the directory renaming code.
240a1986433SDaniel W. S. Almeida
241a1986433SDaniel W. S. Almeida
242a1986433SDaniel W. S. AlmeidaPOSSIBLE PROBLEMS
243a1986433SDaniel W. S. Almeida=================
244a1986433SDaniel W. S. Almeida
245a1986433SDaniel W. S. Almeida- vfat_valid_longname does not properly checked reserved names.
246a1986433SDaniel W. S. Almeida- When a volume name is the same as a directory name in the root
247a1986433SDaniel W. S. Almeida  directory of the filesystem, the directory name sometimes shows
248a1986433SDaniel W. S. Almeida  up as an empty file.
249a1986433SDaniel W. S. Almeida- autoconv option does not work correctly.
250a1986433SDaniel W. S. Almeida
251a1986433SDaniel W. S. Almeida
252a1986433SDaniel W. S. AlmeidaTEST SUITE
253a1986433SDaniel W. S. Almeida==========
254a1986433SDaniel W. S. AlmeidaIf you plan to make any modifications to the vfat filesystem, please
255a1986433SDaniel W. S. Almeidaget the test suite that comes with the vfat distribution at
256a1986433SDaniel W. S. Almeida
257a1986433SDaniel W. S. Almeida`<http://web.archive.org/web/*/http://bmrc.berkeley.edu/people/chaffee/vfat.html>`_
258a1986433SDaniel W. S. Almeida
259a1986433SDaniel W. S. AlmeidaThis tests quite a few parts of the vfat filesystem and additional
260a1986433SDaniel W. S. Almeidatests for new features or untested features would be appreciated.
261a1986433SDaniel W. S. Almeida
262a1986433SDaniel W. S. AlmeidaNOTES ON THE STRUCTURE OF THE VFAT FILESYSTEM
263a1986433SDaniel W. S. Almeida=============================================
264a1986433SDaniel W. S. AlmeidaThis documentation was provided by Galen C. Hunt gchunt@cs.rochester.edu and
265a1986433SDaniel W. S. Almeidalightly annotated by Gordon Chaffee.
266a1986433SDaniel W. S. Almeida
267a1986433SDaniel W. S. AlmeidaThis document presents a very rough, technical overview of my
268a1986433SDaniel W. S. Almeidaknowledge of the extended FAT file system used in Windows NT 3.5 and
269a1986433SDaniel W. S. AlmeidaWindows 95.  I don't guarantee that any of the following is correct,
270a1986433SDaniel W. S. Almeidabut it appears to be so.
271a1986433SDaniel W. S. Almeida
272a1986433SDaniel W. S. AlmeidaThe extended FAT file system is almost identical to the FAT
273a1986433SDaniel W. S. Almeidafile system used in DOS versions up to and including *6.223410239847*
274a1986433SDaniel W. S. Almeida:-).  The significant change has been the addition of long file names.
275a1986433SDaniel W. S. AlmeidaThese names support up to 255 characters including spaces and lower
276a1986433SDaniel W. S. Almeidacase characters as opposed to the traditional 8.3 short names.
277a1986433SDaniel W. S. Almeida
278a1986433SDaniel W. S. AlmeidaHere is the description of the traditional FAT entry in the current
279a1986433SDaniel W. S. AlmeidaWindows 95 filesystem::
280a1986433SDaniel W. S. Almeida
281a1986433SDaniel W. S. Almeida        struct directory { // Short 8.3 names
282a1986433SDaniel W. S. Almeida                unsigned char name[8];          // file name
283a1986433SDaniel W. S. Almeida                unsigned char ext[3];           // file extension
284a1986433SDaniel W. S. Almeida                unsigned char attr;             // attribute byte
285a1986433SDaniel W. S. Almeida		unsigned char lcase;		// Case for base and extension
286a1986433SDaniel W. S. Almeida		unsigned char ctime_ms;		// Creation time, milliseconds
287a1986433SDaniel W. S. Almeida		unsigned char ctime[2];		// Creation time
288a1986433SDaniel W. S. Almeida		unsigned char cdate[2];		// Creation date
289a1986433SDaniel W. S. Almeida		unsigned char adate[2];		// Last access date
290a1986433SDaniel W. S. Almeida		unsigned char reserved[2];	// reserved values (ignored)
291a1986433SDaniel W. S. Almeida                unsigned char time[2];          // time stamp
292a1986433SDaniel W. S. Almeida                unsigned char date[2];          // date stamp
293a1986433SDaniel W. S. Almeida                unsigned char start[2];         // starting cluster number
294a1986433SDaniel W. S. Almeida                unsigned char size[4];          // size of the file
295a1986433SDaniel W. S. Almeida        };
296a1986433SDaniel W. S. Almeida
297a1986433SDaniel W. S. Almeida
298a1986433SDaniel W. S. AlmeidaThe lcase field specifies if the base and/or the extension of an 8.3
299a1986433SDaniel W. S. Almeidaname should be capitalized.  This field does not seem to be used by
300a1986433SDaniel W. S. AlmeidaWindows 95 but it is used by Windows NT.  The case of filenames is not
301a1986433SDaniel W. S. Almeidacompletely compatible from Windows NT to Windows 95.  It is not completely
302a1986433SDaniel W. S. Almeidacompatible in the reverse direction, however.  Filenames that fit in
303a1986433SDaniel W. S. Almeidathe 8.3 namespace and are written on Windows NT to be lowercase will
304a1986433SDaniel W. S. Almeidashow up as uppercase on Windows 95.
305a1986433SDaniel W. S. Almeida
306a1986433SDaniel W. S. Almeida.. note:: Note that the ``start`` and ``size`` values are actually little
307a1986433SDaniel W. S. Almeida          endian integer values.  The descriptions of the fields in this
308a1986433SDaniel W. S. Almeida          structure are public knowledge and can be found elsewhere.
309a1986433SDaniel W. S. Almeida
310a1986433SDaniel W. S. AlmeidaWith the extended FAT system, Microsoft has inserted extra
311a1986433SDaniel W. S. Almeidadirectory entries for any files with extended names.  (Any name which
312a1986433SDaniel W. S. Almeidalegally fits within the old 8.3 encoding scheme does not have extra
313a1986433SDaniel W. S. Almeidaentries.)  I call these extra entries slots.  Basically, a slot is a
314a1986433SDaniel W. S. Almeidaspecially formatted directory entry which holds up to 13 characters of
315a1986433SDaniel W. S. Almeidaa file's extended name.  Think of slots as additional labeling for the
316a1986433SDaniel W. S. Almeidadirectory entry of the file to which they correspond.  Microsoft
317a1986433SDaniel W. S. Almeidaprefers to refer to the 8.3 entry for a file as its alias and the
318a1986433SDaniel W. S. Almeidaextended slot directory entries as the file name.
319a1986433SDaniel W. S. Almeida
320a1986433SDaniel W. S. AlmeidaThe C structure for a slot directory entry follows::
321a1986433SDaniel W. S. Almeida
322a1986433SDaniel W. S. Almeida        struct slot { // Up to 13 characters of a long name
323a1986433SDaniel W. S. Almeida                unsigned char id;               // sequence number for slot
324a1986433SDaniel W. S. Almeida                unsigned char name0_4[10];      // first 5 characters in name
325a1986433SDaniel W. S. Almeida                unsigned char attr;             // attribute byte
326a1986433SDaniel W. S. Almeida                unsigned char reserved;         // always 0
327a1986433SDaniel W. S. Almeida                unsigned char alias_checksum;   // checksum for 8.3 alias
328a1986433SDaniel W. S. Almeida                unsigned char name5_10[12];     // 6 more characters in name
329a1986433SDaniel W. S. Almeida                unsigned char start[2];         // starting cluster number
330a1986433SDaniel W. S. Almeida                unsigned char name11_12[4];     // last 2 characters in name
331a1986433SDaniel W. S. Almeida        };
332a1986433SDaniel W. S. Almeida
333a1986433SDaniel W. S. Almeida
334a1986433SDaniel W. S. AlmeidaIf the layout of the slots looks a little odd, it's only
335a1986433SDaniel W. S. Almeidabecause of Microsoft's efforts to maintain compatibility with old
336a1986433SDaniel W. S. Almeidasoftware.  The slots must be disguised to prevent old software from
337a1986433SDaniel W. S. Almeidapanicking.  To this end, a number of measures are taken:
338a1986433SDaniel W. S. Almeida
339a1986433SDaniel W. S. Almeida        1) The attribute byte for a slot directory entry is always set
340a1986433SDaniel W. S. Almeida           to 0x0f.  This corresponds to an old directory entry with
341a1986433SDaniel W. S. Almeida           attributes of "hidden", "system", "read-only", and "volume
342a1986433SDaniel W. S. Almeida           label".  Most old software will ignore any directory
343a1986433SDaniel W. S. Almeida           entries with the "volume label" bit set.  Real volume label
344a1986433SDaniel W. S. Almeida           entries don't have the other three bits set.
345a1986433SDaniel W. S. Almeida
346a1986433SDaniel W. S. Almeida        2) The starting cluster is always set to 0, an impossible
347a1986433SDaniel W. S. Almeida           value for a DOS file.
348a1986433SDaniel W. S. Almeida
349a1986433SDaniel W. S. AlmeidaBecause the extended FAT system is backward compatible, it is
350a1986433SDaniel W. S. Almeidapossible for old software to modify directory entries.  Measures must
351a1986433SDaniel W. S. Almeidabe taken to ensure the validity of slots.  An extended FAT system can
352a1986433SDaniel W. S. Almeidaverify that a slot does in fact belong to an 8.3 directory entry by
353a1986433SDaniel W. S. Almeidathe following:
354a1986433SDaniel W. S. Almeida
355a1986433SDaniel W. S. Almeida        1) Positioning.  Slots for a file always immediately proceed
356a1986433SDaniel W. S. Almeida           their corresponding 8.3 directory entry.  In addition, each
357a1986433SDaniel W. S. Almeida           slot has an id which marks its order in the extended file
358a1986433SDaniel W. S. Almeida           name.  Here is a very abbreviated view of an 8.3 directory
359a1986433SDaniel W. S. Almeida           entry and its corresponding long name slots for the file
360a1986433SDaniel W. S. Almeida           "My Big File.Extension which is long"::
361a1986433SDaniel W. S. Almeida
362a1986433SDaniel W. S. Almeida                <proceeding files...>
363a1986433SDaniel W. S. Almeida                <slot #3, id = 0x43, characters = "h is long">
364a1986433SDaniel W. S. Almeida                <slot #2, id = 0x02, characters = "xtension whic">
365a1986433SDaniel W. S. Almeida                <slot #1, id = 0x01, characters = "My Big File.E">
366a1986433SDaniel W. S. Almeida                <directory entry, name = "MYBIGFIL.EXT">
367a1986433SDaniel W. S. Almeida
368a1986433SDaniel W. S. Almeida
369a1986433SDaniel W. S. Almeida           .. note:: Note that the slots are stored from last to first.  Slots
370a1986433SDaniel W. S. Almeida		     are numbered from 1 to N.  The Nth slot is ``or'ed`` with
371a1986433SDaniel W. S. Almeida		     0x40 to mark it as the last one.
372a1986433SDaniel W. S. Almeida
373a1986433SDaniel W. S. Almeida        2) Checksum.  Each slot has an alias_checksum value.  The
374a1986433SDaniel W. S. Almeida           checksum is calculated from the 8.3 name using the
375a1986433SDaniel W. S. Almeida           following algorithm::
376a1986433SDaniel W. S. Almeida
377a1986433SDaniel W. S. Almeida                for (sum = i = 0; i < 11; i++) {
378a1986433SDaniel W. S. Almeida                        sum = (((sum&1)<<7)|((sum&0xfe)>>1)) + name[i]
379a1986433SDaniel W. S. Almeida                }
380a1986433SDaniel W. S. Almeida
381a1986433SDaniel W. S. Almeida
382a1986433SDaniel W. S. Almeida	3) If there is free space in the final slot, a Unicode ``NULL (0x0000)``
383a1986433SDaniel W. S. Almeida	   is stored after the final character.  After that, all unused
384a1986433SDaniel W. S. Almeida	   characters in the final slot are set to Unicode 0xFFFF.
385a1986433SDaniel W. S. Almeida
386a1986433SDaniel W. S. AlmeidaFinally, note that the extended name is stored in Unicode.  Each Unicode
387a1986433SDaniel W. S. Almeidacharacter takes either two or four bytes, UTF-16LE encoded.
388