Copyright © 2007, 2009 Free Software Foundation, Inc. Copyright © 1996-2005,2007-2011,2013 Alain Knaff.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.
This is mtools' documentation.
Mtools is a collection of tools to allow Unix systems to manipulate MS-DOS files: read, write, and move around files on an MS-DOS file system (typically a floppy disk). Where reasonable, each program attempts to emulate the MS-DOS equivalent command. However, unnecessary restrictions and oddities of DOS are not emulated. For instance, it is possible to move subdirectories from one subdirectory to another.
Mtools is sufficient to give access to MS-DOS file systems. For
instance, commands such as mdir a: work on the a: floppy
without any preliminary mounting or initialization (assuming the default
/etc/mtools.conf works on your machine). With mtools, one can
change floppies too without unmounting and mounting.
Mtools can be found at the following places (and their mirrors):
http://ftp.gnu.org/gnu/mtools/mtools-4.0.18.tar.gz
http://mtools.linux.lu/mtools-4.0.18.tar.gz
ftp://www.tux.org/pub/knaff/mtools/mtools-4.0.18.tar.gz
ftp://ibiblio.unc.edu/pub/Linux/utils/disk-management/mtools-4.0.18.tar.gz
Before reporting a bug, make sure that it has not yet been fixed in the Alpha patches which can be found at:
http://ftp.gnu.org/gnu/mtools/
http://mtools.linux.lu/
ftp://www.tux.org/pub/knaff/mtools
These patches are named
mtools-version-ddmm.taz, where version
stands for the base version, dd for the day and mm for the
month. Due to a lack of space, I usually leave only the most recent
patch.
There is an mtools mailing list at mtools @ tux.org . Please send all bug reports to this list. You may subscribe to the list by sending a message with 'subscribe mtools @ tux.org' in its body to majordomo @ tux.org . (N.B. Please remove the spaces around the "@" both times. I left them there in order to fool spambots.) Announcements of new mtools versions will also be sent to the list, in addition to the Linux announce newsgroups. The mailing list is archived at http://lists.gnu.org/pipermail/info-mtools/
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 '\' separator
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
them.
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 name clashes, for more details on these. All
commands accept the -V flags which prints the version, and most
accept the -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 Commands, for a description of
the options which are specific to each command.
The meaning of the drive letters depends on the target architectures. However, on most target architectures, drive A is the first floppy drive, drive B is the second floppy drive (if available), drive J is a Jaz drive (if available), and drive Z is a Zip drive (if available). On those systems where the device name is derived from the SCSI id, the Jaz drive is assumed to be at SCSI target 4, and the Zip at SCSI target 5 (factory default settings). On Linux, both drives are assumed to be the second drive on the SCSI bus (/dev/sdb). The default settings can be changes using a configuration file (see Configuration).
The drive letter : (colon) has a special meaning. It is used to access
image files which are directly specified on the command line using the
-i options.
Example:
mcopy -i my-image-file.bin ::file1 ::file2 .
This copies file1 and file2 from the image file
(my-image-file.bin) to the /tmp directory.
You can also supply an offset within the image file by including
@@offset into the file name.
Example:
mcopy -i my-image-file.bin@@1M ::file1 ::file2 .
This looks for the image at the offset of 1M in the file, rather than at its beginning.
The mcd command (mcd) is used to establish the device and
the current working directory (relative to the MS-DOS file system),
otherwise the default is assumed to be A:/. However, unlike
MS-DOS, there is only one working directory for all drives, and not one
per drive.
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.
Example:
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
reserved.
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 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 mcopy,
mmd, mren, mmove. When a name clash happens, mtools
asks you what it should do. It offers several choices:
overwriterenameautorenameskipTo 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:
-D o-D O-D r-D R-D a-D A-D s-D S-D m-D MNote that for command line switches lower/upper differentiates between primary/secondary name whereas for interactive choices, lower/upper differentiates between just-this-time/always.
The primary name is the name as displayed in Windows 95 or Windows NT: i.e. the long name if it exists, and the short name otherwise. The secondary name is the "hidden" name, i.e. the short name if a long name exists.
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 file system 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 file system, 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 file system 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.
Mtools supports a number of formats which allow to store more data on disk as usual. Due to different operating system abilities, these formats are not supported on all operating systems. Mtools recognizes these formats transparently where supported.
In order to format these disks, you need to use an operating system
specific tool. For Linux, suitable floppy tools can be found in the
fdutils package at the following locations~:
ftp://www.tux.org/pub/knaff/fdutils/.ftp://ibiblio.unc.edu/pub/Linux/utils/disk-management/fdutils-*
See the manual pages included in that package for further detail: Use
superformat to format all formats except XDF, and use
xdfcopy to format XDF.
The oldest method of fitting more data on a disk is to use more sectors and more cylinders. Although the standard format uses 80 cylinders and 18 sectors (on a 3 1/2 high density disk), it is possible to use up to 83 cylinders (on most drives) and up to 21 sectors. This method allows to store up to 1743K on a 3 1/2 HD disk. However, 21 sector disks are twice as slow as the standard 18 sector disks because the sectors are packed so close together that we need to interleave them. This problem doesn't exist for 20 sector formats.
These formats are supported by numerous DOS shareware utilities such as
fdformat and vgacopy. In his infinite hubris, Bill Gate$
believed that he invented this, and called it ‘DMF disks’, or
‘Windows formatted disks’. But in reality, it has already existed
years before! Mtools supports these formats on Linux, on SunOS and on
the DELL Unix PC.
By using bigger sectors it is possible to go beyond the capacity which can be obtained by the standard 512-byte sectors. This is because of the sector header. The sector header has the same size, regardless of how many data bytes are in the sector. Thus, we save some space by using fewer, but bigger sectors. For example, 1 sector of 4K only takes up header space once, whereas 8 sectors of 512 bytes have also 8 headers, for the same amount of useful data.
This method allows to store up to 1992K on a 3 1/2 HD disk.
Mtools supports these formats only on Linux.
The 2m format was originally invented by Ciriaco Garcia de Celis. It also uses bigger sectors than usual in order to fit more data on the disk. However, it uses the standard format (18 sectors of 512 bytes each) on the first cylinder, in order to make these disks easier to handle by DOS. Indeed this method allows to have a standard sized boot sector, which contains a description of how the rest of the disk should be read.
However, the drawback of this is that the first cylinder can hold less data than the others. Unfortunately, DOS can only handle disks where each track contains the same amount of data. Thus 2m hides the fact that the first track contains less data by using a shadow FAT. (Usually, DOS stores the FAT in two identical copies, for additional safety. XDF stores only one copy, but tells DOS that it stores two. Thus the space that would be taken up by the second FAT copy is saved.) This also means that you should never use a 2m disk to store anything else than a DOS file system.
Mtools supports these formats only on Linux.
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 Compiling mtools, and miscellaneous 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.
Mtools supports this format only on Linux.
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 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, global variables) to bypass the fat checking.
This sections explains the syntax of the configurations files for
mtools. The configuration files
are called /etc/mtools.conf and ~/.mtoolsrc. If
the environmental variable MTOOLSRC is set, its contents is used
as the filename for a third configuration file. These configuration
files describe the following items:
/etc/mtools.conf is the system-wide configuration file, and ~/.mtoolsrc is the user's private configuration file.
On some systems, the system-wide configuration file is called /etc/default/mtools.conf instead.
The configuration files is made up of sections. Each section starts with a keyword identifying the section followed by a colon. Then follow variable assignments and flags. Variable assignments take the following form:
name=value
Flags are lone keywords without an equal sign and value following them. A section either ends at the end of the file or where the next section begins.
Lines starting with a hash (#) are comments. Newline characters
are equivalent to whitespace (except where ending a comment). The
configuration file is case insensitive, except for item enclosed in
quotes (such as filenames).
For most platforms, mtools contains reasonable compiled-in defaults for physical floppy drives. Thus, you usually don't need to bother with the configuration file, if all you want to do with mtools is to access your floppy drives. On the other hand, the configuration file is needed if you also want to use mtools to access your hard disk partitions and DOSEMU image files.
Global flags may be set to 1 or to 0.
The following global flags are recognized:
MTOOLS_SKIP_CHECKMTOOLS_FAT_COMPATIBILITYMTOOLS_LOWER_CASEMTOOLS_NO_VFATMTOOLS_DOTTED_DIRMTOOLS_NAME_NUMERIC_TAILMTOOLS_TWENTY_FOUR_HOUR_CLOCKExample: Inserting the following line into your configuration file instructs mtools to skip the sanity checks:
MTOOLS_SKIP_CHECK=1
Global variables may also be set via the environment:
export MTOOLS_SKIP_CHECK=1
Global string variables may be set to any value:
MTOOLS_DATE_STRING
Per drive flags and values may be described in a drive section. A
drive section starts with
drive "driveletter" :
Then follow variable-value pairs and flags.
This is a sample drive description:
drive a:
file="/dev/fd0" use_xdf=1
For each drive, you need to describe where its data is physically stored (image file, physical device, partition, offset).
filepartitionoffset variable. The partition variable
is intended for removable media such as Syquest disks, ZIP drives, and
magneto-optical disks. Although traditional DOS sees Syquest disks and
magneto-optical disks as ‘giant floppy disks’ which are
unpartitioned, OS/2 and Windows NT treat them like hard disks,
i.e. partitioned devices. The partition flag is also useful DOSEMU
hdimages. It is not recommended for hard disks for which direct access
to partitions is available through mounting.
offsetGeometry information describes the physical characteristics about the disk. Its has three purposes:
If no geometry information is supplied in the configuration file, all disks are accepted. On Linux (and on SPARC) there exist device nodes with configurable geometry (/dev/fd0, /dev/fd1 etc), and thus filtering is not needed (and ignored) for disk drives. (Mtools still does do filtering on plain files (disk images) in Linux: this is mainly intended for test purposes, as I don't have access to a Unix which would actually need filtering).
If you do not need filtering, but want still a default geometry for
mformatting, you may switch off filtering using the mformat_only
flag.
If you want filtering, you should supply the filter flag. If you
supply a geometry, you must supply one of both flags.
mformat_only flag is supplied, no
initial configuration is done.
On Linux, initial geometry is not really needed, as the configurable devices are able to auto-detect the disk type accurately enough (for most common formats) to read the boot sector.
Wrong geometry information may lead to very bizarre errors. That's why I
strongly recommend that you add the mformat_only flag to your
drive description, unless you really need filtering or initial geometry.
The following geometry related variables are available:
cylinderstrackscylinders is the preferred form,
tracks is considered obsolete)
headssectorsExample: the following drive section describes a 1.44M drive:
drive a:
file="/dev/fd0H1440"
fat_bits=12
cylinders=80 heads=2 sectors=18
mformat_only
The following shorthand geometry descriptions are available:
1.44mfat_bits=12 cylinders=80 heads=2 sectors=18
1.2mfat_bits=12 cylinders=80 heads=2 sectors=15
720kfat_bits=12 cylinders=80 heads=2 sectors=9
360kfat_bits=12 cylinders=40 heads=2 sectors=9
The shorthand format descriptions may be amended. For example,
360k sectors=8
describes a 320k disk and is equivalent to:
fat_bits=12 cylinders=40 heads=2 sectors=8
Moreover, the following flags are available:
syncnodelayexclusiveThe following general purpose drive variables are available. Depending to their type, these variables can be set to a string (precmd) or an integer (all others)
fat_bitscodepagedefault_codepage parameter
(outside of any drive description). This parameters exists starting at
version 4.0.0
precmdprecmd="volcheck -v" in the
drive clause establishes the desired behavior.
blocksizeOnly the file variable is mandatory. The other parameters may
be left out. In that case a default value or an auto-detected value is
used.
A flag can either be set to 1 (enabled) or 0 (disabled). If the value is
omitted, it is enabled. For example, scsi is equivalent to
scsi=1
nolockscsiread and write system calls, because the OS expects
them to contain a Sun specific "disk label".
As raw SCSI access always uses the whole device, you need to specify the "partition" flag in addition
On some architectures, such as Solaris, mtools needs root privileges to
be able to use the scsi option. Thus mtools should be installed
setuid root on Solaris if you want to access Zip/Jaz drives. Thus, if
the scsi flag is given, privileged is automatically
implied, unless explicitly disabled by privileged=0
Mtools uses its root privileges to open the device, and to issue the
actual SCSI I/O calls. Moreover, root privileges are only used for
drives described in a system-wide configuration file such as
/etc/mtools.conf, and not for those described in
~/.mtoolsrc or $MTOOLSRC.
privilegedscsi=1 is set.
Mtools only needs to be installed setuid if you use the
privileged or scsi drive variables. If you do not use
these options, mtools works perfectly well even when not installed
setuid root.
voldmedia_findname() and
media_oldaliases() functions of the volmgt library. This
flag is only available if you configured mtools with the
--enable-new-vold option before compilation.
swapuse_xdfmformat_onlyfilterremoteIt is possible to supply multiple descriptions for a drive. In that case, the descriptions are tried in order until one is found that fits. Descriptions may fail for several reasons:
Multiple definitions are useful when using physical devices which are only able to support one single disk geometry. Example:
drive a: file="/dev/fd0H1440" 1.44m
drive a: file="/dev/fd0H720" 720k
This instructs mtools to use /dev/fd0H1440 for 1.44m (high density) disks and /dev/fd0H720 for 720k (double density) disks. On Linux, this feature is not really needed, as the /dev/fd0 device is able to handle any geometry.
You may also use multiple drive descriptions to access both of your physical drives through one drive letter:
drive z: file="/dev/fd0"
drive z: file="/dev/fd1"
With this description, mdir z: accesses your first physical
drive if it contains a disk. If the first drive doesn't contain a disk,
mtools checks the second drive.
When using multiple configuration files, drive descriptions in the files
parsed last override descriptions for the same drive in earlier
files. In order to avoid this, use the drive+ or +drive
keywords instead of drive. The first adds a description to the
end of the list (i.e. it will be tried last), and the first adds it to
the start of the list.
The configuration files are parsed in the following order:
MTOOLSRC environmental
variable)
Options described in the later files override those described in the
earlier files. Drives defined in earlier files persist if they are not
overridden in the later files. For instance, drives A and B may be
defined in /etc/mtools.conf and drives C and D may be
defined in ~/.mtoolsrc However, if ~/.mtoolsrc also
defines drive A, this new description would override the description of
drive A in /etc/mtools.conf instead of adding to it. If
you want to add a new description to a drive already described in an
earlier file, you need to use either the +drive or drive+
keyword.
The syntax described herein is new for version mtools-3.0. The
old line-oriented syntax is still supported. Each line beginning with a
single letter is considered to be a drive description using the old
syntax. Old style and new style drive sections may be mixed within the
same configuration file, in order to make upgrading easier. Support for
the old syntax will be phased out eventually, and in order to discourage
its use, I purposefully omit its description here.
This section describes the available mtools commands, and the command line parameters that each of them accepts. Options which are common to all mtools commands are not described here, arguments for a description of those.
Floppyd is used as a server to grant access to the floppy drive
to clients running on a remote machine, just as an X server grants
access to the display to remote clients. It has the following syntax:
floppyd [-d] [-l] [-s port] [-r
user] [-b ipaddr] [-x display] devicenames
floppyd is always associated with an X server. It runs on the
same machine as its X server, and listens on port 5703 and above.
floppyd authenticates remote clients using the Xauthority
protocol. Xhost authentication is not supported. Each floppyd is
associated with an X server. When a remote client attempts to connect
to floppyd, it sends floppyd the X authority record corresponding to
floppyd's X server. Floppyd in turn then tries to open up a connection
to the X server in order to verify the authenticity of the xauth record.
If the connection to the X server succeeds, the client is granted
access.
DISPLAY.
Caution: In order to make authentication work correctly, the
local host should not be listed in the xhost list of
allowed hosts.
Indeed, hosts listed in xhost do not need a correct
Xauthority cookie to connect to the X server. As floppyd
runs on the same host as the X server, all its probe connection would
succeed even for clients who supplied a bad cookie. This means that
your floppy drive would be open to the world, i.e. a huge security hole.
If your X server does not allow you to remove localhost:0 and
:0 from the xhost list, you can prevent floppyd from
probing those display names with the -l option.
dinetd.conf
s porthitchhiker:5, the port would be 5708.
b ipaddrr userx displayDISPLAY variable. If neither the x attribute is present
nor DISPLAY is set, floppyd uses :0.0.
devicenames is a list of device nodes to be opened. Default
is /dev/fd0. Multiple devices are only supported on mtools
versions newer than 3.9.11.
In order to use floppyd, add the flag remote to the device
description in your ~/.mtoolsrc file. If the flag remote
is given, the file parameter of the device description is taken
to be a remote address. It's format is the following:
hostname:displaynumber[/[baseport][/drive]]. When
using this entry, mtools connects to port
baseport+displaynumber at hostname. By default
baseport is 5703. The drive parameter is to distinguish among
multiple drives associated with a single display (only mtools versions
more recent than 3.9.11)
The following starts a floppy daemon giving access to /dev/fd0, listening on the default port 5703, tied to the default X servers:
floppyd -d /dev/fd0
Each of the following starts a floppy daemon giving access to
/dev/fd1, tied to the :1 local X servers, and listening on port
5704. We assume that the local host is named hitchhiker.
floppyd -d /dev/fd0
floppyd -d -x :1 -p 5704 /dev/fd0
If you want to start floppyd by inetd instead of running it as a
daemon, insert the following lines into /etc/services:
# floppy daemon
floppyd-0 5703/tcp # floppy daemon for X server :0
floppyd-1 5704/tcp # floppy daemon for X server :1
And insert the following into /etc/inetd.conf (assuming that you have defined a user named floppy in your /etc/passwd):
# floppy daemon
floppyd-0 stream tcp wait floppy /usr/sbin/floppyd floppyd /dev/fd0
floppyd-1 stream tcp wait floppy /usr/sbin/floppyd floppyd -x :1 /dev/fd0
Note that you need to supply the X display names for the second floppyd. This is because the port is opened by inetd.conf, and hence floppyd cannot know its number to interfere the display number.
On the client side, insert the following into your ~/.mtoolsrc to define a drive letter accessing floppy drive in your X terminal:
drive x: file="$DISPLAY" remote
If your X terminal has more than one drive, you may access the additional drives as follows:
drive y: file="$DISPLAY//1" remote
drive z: file="$DISPLAY//2" remote
Floppyd_installtest is used to check for the presence of a running
floppyd daemon. This is useful, if you have a small front-end script to
mtools, which decides whether to use floppyd or not.
floppyd_installtest [-f] Connect-String
If the -f option is specified, floppyd_installtest does a
full X-Cookie authentication and complains if this does not work.
The connect-String has the format described in the floppyd-section:
hostname:displaynumber[/baseport]
Mattrib is used to change MS-DOS file attribute flags. It has the
following syntax:
mattrib [-a|+a] [-h|+h] [-r|+r]
[-s|+s] [-/] [-p] [-X] msdosfile [ msdosfiles ... ]
Mattrib adds attribute flags to an MS-DOS file (with the
`+' operator) or remove attribute flags (with the `-'
operator).
Mattrib supports the following attribute bits:
arDEL nor modified.
shDIR.
Mattrib supports the following command line flags:
/Xpreadonly attribute is not taken into account, as tar can
set that one itself.
The mbadblocks command is used to mark some clusters on an
MS-DOS filesystem bad. It has the following syntax:
mbadblocks [-s sectorlist|-c clusterlist|-w] drive:
If no command line flags are supplied, Mbadblocks scans an
MS-DOS filesystem for bad blocks by simply trying to read them and
flag them if read fails. All blocks that are unused are scanned, and
if detected bad are marked as such in the FAT.
This command is intended to be used right after mformat. It is
not intended to salvage data from bad disks.
c files filewMbadblocks should (but doesn't yet :-( ) also try to salvage bad
blocks which are in use by reading them repeatedly, and then mark them
bad.
The mcat command is used to copy an entire disk image from or
to the floppy device. It uses the following syntax:
mcat [-w] drive:
Mcat performs the same task as the Unix cat command. It
is included into the mtools package, since cat cannot access
remote floppy devices offered by the mtools floppy daemon.
Now it is possible to create boot floppies remotely.
The default operation is reading. The output is written to stdout.
If the -w option is specified, mcat reads a disk-image from
stdin and writes it to the given device.
Use this carefully! Because of the low-level nature of this
command, it will happily destroy any data written before on the
disk without warning!
The mcd command is used to change the mtools working directory
on the MS-DOS disk. It uses the following syntax:
mcd [msdosdirectory]
Without arguments, mcd reports the current device and working
directory. Otherwise, mcd changes the current device and current
working directory relative to an MS-DOS file system.
The environmental variable MCWD may be used to locate the file
where the device and current working directory information is stored.
The default is $HOME/.mcwd. Information in this file is ignored
if the file is more than 6 hours old.
Mcd returns 0 on success or 1 on failure.
Unlike MS-DOS versions of CD, mcd can be used to change to
another device. It may be wise to remove old .mcwd files at logout.
The mclasserase command is used to wipe memory cards by
overwriting it three times: first with 0xff, then with
0x00, then with 0xff again. The command uses the following
syntax:
mclasserase[-d] msdosdrive
MS-DOS drive is optional, if none is specified, use A:. If more than
one drive are specified, all but the last are ignored.
Mclasserase accepts the following command line options:
dpMclasserase returns 0 on success or -1 on failure.
The mcopy command is used to copy MS-DOS files to and from
Unix. It uses the following syntax:
mcopy[-bspanvmQT] [-Dclash_option] sourcefile targetfilemcopy[-bspanvmQT] [-Dclash_option] sourcefile [ sourcefiles... ] targetdirectorymcopy[-tnvm] MSDOSsourcefile
Mcopy copies the specified file to the named file, or copies
multiple files to the named directory. The source and target can be
either MS-DOS or Unix files.
The use of a drive letter designation on the MS-DOS files, 'a:' for
example, determines the direction of the transfer. A missing drive
designation implies a Unix file whose path starts in the current
directory. If a source drive letter is specified with no attached file
name (e.g. mcopy a: .), all files are copied from that drive.
If only a single, MS-DOS source parameter is provided (e.g. "mcopy
a:foo.exe"), an implied destination of the current directory
(`.') is assumed.
A filename of `-' means standard input or standard output, depending
on its position on the command line.
Mcopy accepts the following command line options:
tbspQaASCII translates incoming carriage
return/line feeds to line feeds.
T-a in the ASCII also translates incoming PC-8 characters
to ISO-8859-1 equivalents as far as possible. When reading DOS files,
untranslatable characters are replaced by '#'; when writing DOS files,
untranslatable characters are replaced by '.'.
nASCII doesn't warn
the user when overwriting an existing Unix file. If the target file already exists,
and the -n option is not in effect, mcopy asks whether to
overwrite the file or to rename the new file (name clashes) for
details). In order to switch off confirmation for DOS files, use -o.
mvUnlike MS-DOS, the '+' operator (append) from MS-DOS is not
supported. However, you may use mtype to produce the same effect:
mtype a:file1 a:file2 a:file3 >unixfile
mtype a:file1 a:file2 a:file3 | mcopy - a:msdosfile
The mdel command is used to delete an MS-DOS file. Its syntax
is:
mdel[-v] msdosfile [ msdosfiles ... ]
Mdel deletes files on an MS-DOS file system.
Mdel asks for verification prior to removing a read-only file.
The mdeltree command is used to delete an MS-DOS file. Its syntax
is:
mdeltree[-v] msdosdirectory [msdosdirectories...]
Mdeltree removes a directory and all the files and subdirectories
it contains from an MS-DOS file system. An error occurs if the directory
to be removed does not exist.
The mdir command is used to display an MS-DOS directory. Its
syntax is:
mdir [-/] [-f] [-w] [-a] [-b] msdosfile [ msdosfiles...]
Mdir
displays the contents of MS-DOS directories, or the entries for some
MS-DOS files.
Mdir supports the following command line options:
/-s option
wmdir prints the filenames across
the page without displaying the file size or creation date.
af-f flag bypasses
this step. This flag is not needed on FAT32 file systems, which store
the size explicitly.
bAn error occurs if a component of the path is not a directory.
Mdu is used to list the space occupied by a directory, its
subdirectories and its files. It is similar to the du command on
Unix. The unit used are clusters. Use the minfo command to find out
the cluster size.
mdu [-a] [ msdosfiles ... ]
as
The mformat command is used to add an MS-DOS file system to a
low-level formatted diskette. Its syntax is:
mformat[-tcylinders|-Ttot_sectors] [-hheads] [-ssectors] [-fsize] [-1] [-4] [-8] [-vvolume_label] [-F] [-Ssizecode] [-Msoftware_sector_size] [-Nserial_number] [-a] [-C] [-Hhidden_sectors] [-IfsVersion] [-rroot_sectors] [-Lfat_len] [-Bboot_sector] [-k] [-mmedia_descriptor] [-Kbackup_boot] [-cclusters_per_sector] [-dfat_copies] [-X] [-2sectors_on_track_0] [-3] [-0rate_on_track_0] [-Arate_on_other_tracks] drive:
Mformat adds a minimal MS-DOS file system (boot sector, FAT, and
root directory) to a diskette that has already been formatted by a Unix
low-level format.
The following options are supported: (The S, 2, 1 and M options may not exist if this copy of mtools has been compiled without the USE_2M option)
The following options are the same as for MS-DOS's format command:
vftThs148MS-DOS format's q, u and b options are not
supported, and s has a different meaning.
The following options are specific to mtools:
FSX230AMNaCHIcdMTOOLS_NFATS environment variable.
rMTOOLS_DIR_LEN environment variable.
LBkKmTo format a diskette at a density other than the default, you must supply (at least) those command line parameters that are different from the default.
Mformat returns 0 on success or 1 on failure.
It doesn't record bad block information to the Fat, use
mbadblocks for that.
The mkmanifest command is used to create a shell script (packing
list) to restore Unix filenames. Its syntax is:
mkmanifest [ files ]
Mkmanifest creates a shell script that aids in the restoration of
Unix filenames that got clobbered by the MS-DOS filename restrictions.
MS-DOS filenames are restricted to 8 character names, 3 character
extensions, upper case only, no device names, and no illegal characters.
The mkmanifest program is compatible with the methods used in
pcomm, arc, and mtools to change perfectly good Unix
filenames to fit the MS-DOS restrictions. This command is only useful if
the target system which will read the diskette cannot handle VFAT long
names.
You want to copy the following Unix files to a MS-DOS diskette (using the
mcopy command).
very_long_name
2.many.dots
illegal:
good.c
prn.dev
Capital
ASCII
converts the names to:
very_lon
2xmany.dot
illegalx
good.c
xprn.dev
capital
The command:
mkmanifest very_long_name 2.many.dots illegal: good.c prn.dev Capital >manifest
would produce the following:
mv very_lon very_long_name
mv 2xmany.dot 2.many.dots
mv illegalx illegal:
mv xprn.dev prn.dev
mv capital Capital
Notice that "good.c" did not require any conversion, so it did not appear in the output.
Suppose I've copied these files from the diskette to another Unix system, and I now want the files back to their original names. If the file "manifest" (the output captured above) was sent along with those files, it could be used to convert the filenames.
The short names generated by mkmanifest follow the old convention
(from mtools-2.0.7) and not the one from Windows 95 and mtools-3.0.
The minfo command prints the parameters of a MS-DOS file system, such
as number of sectors, heads and cylinders. It also prints an mformat
command line which can be used to create a similar MS-DOS file system on
another media. However, this doesn't work with 2m or XDF media, and
with MS-DOS 1.0 file systems
minfo drive:
Minfo supports the following option:
v
The mlabel command adds a volume label to a disk. Its syntax is:
mlabel[-vcsn] [-Nserial] drive:[new_label]
Mlabel displays the current volume label, if present. If
new_label is not given, and if neither the c nor the
s options are set, it prompts the user for a new volume label.
To delete an existing volume label, press return at the prompt.
The label is limited to 11 single-byte characters,
e.g. Name1234567.
Reasonable care is taken to create a valid MS-DOS volume label. If an
invalid label is specified, mlabel changes the label (and
displays the new label if the verbose mode is set). Mlabel
returns 0 on success or 1 on failure.
Mlabel supports the following options:
csnN serial
The mmd command is used to make an MS-DOS subdirectory. Its
syntax is:
mmd [-D clash_option] msdosdirectory [
msdosdirectories... ]
Mmd makes a new directory on an MS-DOS file system. An error occurs
if the directory already exists.
The mmount command is used to mount an MS-DOS disk. It is only
available on Linux, as it is only useful if the OS kernel allows to
configure the disk geometry. Its syntax is:
mmount msdosdrive [mountargs]
Mmount
reads the boot sector of an MS-DOS disk, configures the drive geometry,
and finally mounts it passing
mountargs to mount.
If no mount arguments are specified, the name of the device is
used. If the disk is write protected, it is automatically mounted read
only.
The mmove command is used to moves or renames an existing MS-DOS
file or subdirectory.
mmove[-v] [-Dclash_option] sourcefile targetfilemmove[-v] [-Dclash_option] sourcefile [ sourcefiles... ] targetdirectory
Mmove moves or renames an existing MS-DOS file or
subdirectory. Unlike the MS-DOS version of MOVE, mmove is
able to move subdirectories. Files or directories can only be moved
within one file system. Data cannot be moved from MS-DOS to Unix or
vice-versa. If you omit the drive letter from the target file or
directory, the same letter as for the source is assumed. If you omit
the drive letter from all parameters, drive a: is assumed by default.
The mpartition command is used to create MS-DOS file systems as
partitions. This is intended to be used on non-Linux systems,
i.e. systems where fdisk and easy access to SCSI devices are not
available. This command only works on drives whose partition variable
is set.
mpartition-pdrivempartition-rdrivempartition-I[-BbootSector] drivempartition-adrivempartition-ddrivempartition-c[-ssectors] [-hheads] [-tcylinders] [-v[-Ttype] [-bbegin] [-llength] [-f]
Mpartition supports the following operations:
p-v) is also set,
prints the current partition table.
rIcadIf no operation is given, the current settings are printed.
For partition creations, the following options are available:
s sectorsh headst cylindersb beginl lengthThe following option is available for all operation which modify the partition table:
f-f allows you to override
these safeguards.
The following options are available for all operations:
v-p prints the partition table as it is now (no
change operation), or as it is after it is modified.
vvThe following option is available for partition table initialization:
B bootSector
The mrd command is used to remove an MS-DOS subdirectory. Its
syntax is:
mrd[-v] msdosdirectory [ msdosdirectories... ]
Mrd removes a directory from an MS-DOS file system. An error occurs
if the directory does not exist or is not empty.
The mren command is used to rename or move an existing MS-DOS
file or subdirectory. Its syntax is:
mren[-voOsSrRA] sourcefile targetfile
Mren
renames an existing file on an MS-DOS file system.
In verbose mode, Mren displays the new filename if the name
supplied is invalid.
If the first syntax is used (only one source file), and if the target
name doesn't contain any slashes or colons, the file (or subdirectory)
is renamed in the same directory, instead of being moved to the current
mcd directory as would be the case with mmove. Unlike the
MS-DOS version of REN, mren can be used to rename
directories.
The mshortname command is used to display the short name of a
file. Syntax:
mshortname files
The shortname is displayed as it is stored in raw format on disk, without any character set conversion.
The mshowfat command is used to display the FAT entries for a
file. Syntax:
mshowfat[-ooffset] files
If no offset is given, a list of all clusters occupied by the file is printed. If an offset is given, only the number of the cluster containing that offset is printed.
The mtoolstest command is used to tests the mtools configuration
files. To invoke it, just type mtoolstest without any arguments.
Mtoolstest reads the mtools configuration files, and prints the
cumulative configuration to stdout. The output can be used as a
configuration file itself (although you might want to remove redundant
clauses). You may use this program to convert old-style configuration
files into new style configuration files.
The mtype command is used to display contents of an MS-DOS
file. Its syntax is:
mtype[-ts] msdosfile [ msdosfiles... ]
Mtype displays the specified MS-DOS file on the screen.
In addition to the standard options, Mtype allows the following
command line options:
tMtype translates incoming carriage
return/line feeds to line feeds.
sMtype strips the high bit from the data.
The mcd command may be used to establish the device and the
current working directory (relative to MS-DOS), otherwise the default is
A:/.
Mtype returns 0 on success, 1 on utter failure, or 2 on partial
failure.
Unlike the MS-DOS version of TYPE, mtype allows multiple
arguments.
The mzip command is used to issue ZIP disk specific commands on
Linux, Solaris or HP-UX. Its syntax is:
mzip[-epqrwx]
Mzip allows the following
command line options:
ef-e).
rwpxuqTo remove the password, set it to one of the password-less modes
-r or -w: mzip will then ask you for the password, and
unlock the disk. If you have forgotten the password, you can get rid of
it by low-level formatting the disk (using your SCSI adapter's BIOS
setup).
The ZipTools disk shipped with the drive is also password protected. On
MS-DOS or on a Mac, this password is automatically removed once the
ZipTools have been installed. From various articles posted to Usenet, I
learned that the password for the tools disk is
APlaceForYourStuff1. Mzip knows about this
password, and tries it first, before prompting you for a password. Thus
mzip -w z: unlocks the tools disk2. The tools disk is
formatted in a special way so as to be usable both in a PC and in a Mac.
On a PC, the Mac file system appears as a hidden file named
partishn.mac. You may erase it to reclaim the 50 Megs of space
taken up by the Mac file system.
This command is a big kludge. A proper implementation would take a rework of significant parts of mtools, but unfortunately I don't have the time for this right now. The main downside of this implementation is that it is inefficient on some architectures (several successive calls to mtools, which defeats mtools' caching).
To compile mtools, first invoke ./configure before
make. In addition to the standard autoconfigure flags,
there are two architecture specific flags available.
./configure --enable-xdf./configure --disable-xdf./configure --enable-vold./configure --disable-vold./configure --enable-new-vold./configure --disable-new-vold./configure --enable-floppyd./configure --disable-floppydThis chapter is only interesting for those who want to port mtools to an architecture which is not yet supported. For most common systems, default drives are already defined. If you want to add default drives for a still unsupported system, run configuration.guess, to see which identification autoconf uses for that system. This identification is of the form cpu-vendor-os (for example sparc-sun-sunos). The cpu and the OS parts are passed to the compiler as preprocessor flags. The OS part is passed to the compiler in three forms.
All three versions are passed, if they are different.
To define the devices, use the entries for the systems that are already present as templates. In general, they have the following form:
#if (defined (my_cpu) && defined(my_os))
#define predefined_devices
struct device devices[] = {
{ "/dev/first_drive", 'drive_letter', drive_description},
...
{ "/dev/last_drive", 'drive_letter', drive_description}
}
#define INIT_NOOP
#endif
"/dev/first_drive" is the name of the device or image file representing the drive. Drive_letter is a letter ranging from a to z giving access to the drive. Drive_description describes the type of the drive:
ED312HD312DD312HD514DD514DDsmallSS514SSsmallGENFDGENHDGENZIPJAZ(flags)Flags are any special flags to be passed to open.
RZIPJAZ(flags)Flags are any special flags to be passed to open.
REMOTEEntries may be described in more detail:
fat_bits,open_flags,cylinders,heads,sectors,DEF_ARG
or, if you need to describe an offset (file system doesn't start at beginning of file system)
fat_bits, open_flags, cylinders, heads, sectors, offset, DEF_ARG0
fat_bitsopen_flagscylinders,heads,sectorsoffsetDefinition of defaults in the devices file should only be done if these
same devices are found on a large number of hosts of this type. In that
case, could you also let me know about your new definitions, so that I
can include them into the next release. For purely local file, I
recommend that you use the /etc/mtools.conf and
~/.mtoolsrc configuration files.
However, the devices files also allows to supply geometry setting routines. These are necessary if you want to access high capacity disks.
Two routines should be supplied:
static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
This probes the current configured geometry, and return it in the structure generic_floppy_struct (which must also be declared). Fd is an open file descriptor for the device, and buf is an already filled in stat structure, which may be useful. This routine should return 1 if the probing fails, and 0 otherwise.
static inline int set_parameters(int fd, struct generic_floppy_struct *floppy)
struct stat *buf)
This configures the geometry contained in floppy on the file descriptor fd. Buf is the result of a stat call (already filled in). This should return 1 if the new geometry cannot be configured, and 0 otherwise.
A certain number of preprocessor macros should also be supplied:
TRACKS(floppy)HEADS(floppy)SECTORS(floppy)SECTORS_PER_DISK(floppy)BLOCK_MAJORCHAR_MAJORFor the truly high capacity formats (XDF, 2m, etc), there is no clean and documented interface yet.
cylinders: geometry descriptiondrive: general informationexclusive: open flagsfat_bits: miscellaneous variablesfile: location informationfilter: miscellaneous flagsheads: geometry descriptionmformat_only: miscellaneous flagsMTOOLS_FAT_COMPATIBILITY: global variablesMTOOLS_LOWER_CASE: global variablesMTOOLS_NO_VFAT: global variablesMTOOLS_SKIP_CHECK: global variablesMTOOLSRC: Configurationnodelay: open flagssectors: geometry descriptionsync: open flagstracks: geometry descriptionuse_xdf: miscellaneous flagsfloppyd: floppydfloppyd_installtest: floppyd_installtestmattrib: mattribmbadblocks: mbadblocksmcat: mcatmcd: mcdmcd (introduction): directorymclasserase: mclasserasemcopy: mcopymdel: mdelmdeltree: mdeltreemdir: mdirmdu: mdumformat: mformatmformat (geometry used for): geometry descriptionminfo: minfomkmanifest: mkmanifestmlabel: mlabelmmd: mmdmmount: mmountmmove: mmovempartition: mpartitionmrd: mrdmren: mrenmshortname: mshortnamemshowfat: mshowfatmtoolstest: mtoolstestmzip: mzip[1] To see the articles, search for
APlaceForYourStuff using Google Groups
[2] I didn't know about this yet when I bought my own Zip drive. Thus I ended up reformatting my tools disk, and hence I haven't had the opportunity to test the password yet. If anybody still has their tools disk with the original password, could you try it out? Thanks in advance