MS-DOS filenames are composed of a drive letter followed by a colon, a
subdirectory, and a filename. Only the filename part is mandatory, the
drive letter and the subdirectory are optional. Filenames without a
drive letter refer to Unix files. Subdirectory names can use either the
/' or '
\' separator. The use of the '
or wildcards requires the names to be enclosed in quotes to protect them
from the shell. However, wildcards in Unix filenames should not be
enclosed in quotes, because here we want the shell to expand
The regular expression "pattern matching" routines follow the Unix-style
rules. For example, `
*' matches all MS-DOS files in lieu of
*.*'. The archive, hidden, read-only and system attribute bits
are ignored during pattern matching.
All options use the
- (minus) as their first character, not
/ as you'd expect in MS-DOS.
Most mtools commands allow multiple filename parameters, which doesn't follow MS-DOS conventions, but which is more user-friendly.
Most mtools commands allow options that instruct them how to handle file
name clashes. See section Name clashes, for more details on these. All
commands accept the
-V flags which prints the version, and most
-v flag, which switches on verbose mode. In verbose
mode, these commands print out the name of the MS-DOS files upon which
they act, unless stated otherwise. See section Command list, for a description of
the options which are specific to each command.
mcd command (section Mcd) is used to establish the device and
the current working directory (relative to the MS-DOS filesystem),
otherwise the default is assumed to be
A:/. However, unlike
MS-DOS, there is only one working directory for all drives, and not one
This version of mtools supports VFAT style long filenames. If a Unix filename is too long to fit in a short DOS name, it is stored as a VFAT long name, and a companion short name is generated. This short name is what you see when you examine the disk with a pre-7.0 version of DOS. The following table shows some examples of short names:
Long name MS-DOS name Reason for the change --------- ---------- --------------------- thisisatest THISIS~1 filename too long alain.knaff ALAIN~1.KNA extension too long prn.txt PRN~1.TXT PRN is a device name .abc ABC~1 null filename hot+cold HOT_CO~1 illegal character
As you see, the following transformations happen to derive a short name:
~n number is generated,
The initial Unix-style file name (whether long or short) is also called the primary name, and the derived short name is also called the secondary name.
mcopy /etc/motd a:Reallylongname
Mtools creates a VFAT entry for Reallylongname, and uses REALLYLO as a short name. Reallylongname is the primary name, and REALLYLO is the secondary name.
mcopy /etc/motd a:motd
Motd fits into the DOS filename limits. Mtools doesn't need to derivate another name. Motd is the primary name, and there is no secondary name.
In a nutshell: The primary name is the long name, if one exists, or the short name if there is no long name.
Although VFAT is much more flexible than FAT, there are still names
that are not acceptable, even in VFAT. There are still some illegal
characters left (
\"*\\<>/?:|), and device names are still
Unix name Long name Reason for the change --------- ---------- --------------------- prn prn-1 PRN is a device name ab:c ab_c-1 illegal character
As you see, the following transformations happen if a long name is illegal:
-n number is generated,
When writing a file to disk, its long name (primary name) or short name
may collide with an already existing file or directory. This may happen
for all commands which create new directory entries, such as
mread. When a name clash happens, mtools
asks you what it should do. It offers several choices:
To chose one of these actions, type its first letter at the prompt. If you use a lower case letter, the action only applies for this file only, if you use an upper case letter, the action applies to all files, and you won't be prompted again.
You may also chose actions (for all files) on the command line, when invoking mtools:
By default, the user is prompted if the primary name clashes, and the secondary name is autorenamed.
If a name clash occurs in a Unix directory, mtools only asks whether to overwrite the file, or to skip it.
The VFAT filesystem is able to remember the case of the filenames. However, filenames which differ only in case are not allowed to coexist in the same directory. For example if you store a file called LongFileName on a VFAT filesystem, mdir shows this file as LongFileName, and not as Longfilename. However, if you then try to add LongFilename to the same directory, it is refused, because case is ignored for clash checks.
The VFAT filesystem allows to store the case of a filename in the attribute byte, if all letters of the filename are the same case, and if all letters of the extension are the same case too. Mtools uses this information when displaying the files, and also to generate the Unix filename when mcopying to a Unix directory. This may have unexpected results when applied to files written using an pre-7.0 version of DOS: Indeed, the old style filenames map to all upper case. This is different from the behavior of the old version of mtools which used to generate lower case Unix filenames.
XDF is a high capacity format used by OS/2. It can hold 1840 K per
disk. That's lower than the best 2m formats, but its main advantage is
that it is fast: 600 milliseconds per track. That's faster than the 21
sector format, and almost as fast as the standard 18 sector format. In
order to access these disks, make sure mtools has been compiled with XDF
support, and set the
use_xdf variable for the drive in the
configuration file. See section Architecture specific compilation flags and section General Purpose Drive Variables,
for details on how to do this. Fast XDF access is only available for
Linux kernels which are more recent than 1.1.34.
Caution / Attention distributors: If mtools is compiled on a Linux kernel more recent than 1.3.34, it won't run on an older kernel. However, if it has been compiled on an older kernel, it still runs on a newer kernel, except that XDF access is slower. It is recommended that distribution authors only include mtools binaries compiled on kernels older than 1.3.34 until 2.0 comes out. When 2.0 will be out, mtools binaries compiled on newer kernels may (and should) be distributed. Mtools binaries compiled on kernels older than 1.3.34 won't run on any 2.1 kernel or later.
All the Mtools commands return 0 on success, 1 on utter failure, or 2 on partial failure. All the Mtools commands perform a few sanity checks before going ahead, to make sure that the disk is indeed an MS-DOS disk (as opposed to, say an ext2 or minix disk). These checks may reject partially corrupted disks, which might otherwise still be readable. To avoid these checks, set the MTOOLS_SKIP_CHECK environmental variable or the corresponding configuration file variable (see section Global variables)
An unfortunate side effect of not guessing the proper device (when multiple disk capacities are supported) is an occasional error message from the device driver. These can be safely ignored.
The fat checking code chokes on 1.72 Mb disks mformatted with pre-2.0.7 mtools. Set the environmental variable MTOOLS_FAT_COMPATIBILITY (or the corresponding configuration file variable, section Global variables) to bypass the fat checking.
The support for non-Linux OS variants has not been tested for a long time. It may contain bugs, or even not work at all.
Go to the first, previous, next, last section, table of contents.