MTOOLS version 2.0 Mtools is a public domain collection of programs to allow Unix systems to read, write, and manipulate files on an MSDOS filesystem (typically a diskette). The following MSDOS commands are emulated: Mtool MSDOS name equivalent Description ----- ---- ----------- mattrib ATTRIB change MSDOS file attribute flags mcd CD change MSDOS directory mcopy COPY copy MSDOS files to/from Unix mdel DEL/ERASE delete an MSDOS file mdir DIR display an MSDOS directory mformat FORMAT add MSDOS filesystem to a low-level format mlabel LABEL make an MSDOS volume label. mmd MD/MKDIR make an MSDOS subdirectory mrd RD/RMDIR remove an MSDOS subdirectory mread COPY low level read (copy) an MSDOS file to Unix mren REN/RENAME rename an existing MSDOS file mtype TYPE display contents of an MSDOS file mwrite COPY low level write (copy) a Unix file to MSDOS You should be able to just close your eyes and pretend you're on an MSDOS system. Everything should work the same... except for the added 'm' at the beginning of each command. I really wanted to avoid the use of a 'text' mode and a 'data' mode when transferring files, but I couldn't find a better way. It gets rather confusing and it's quite possible to mess up a file if you apply the text mode when it is not appropriate (ie: to a COM or EXE file). The pattern matching routine more closely resembles Unix than MSDOS. For example, "*" matches all MSDOS files in lieu of "*.*". The use of wildcards (or the '\' separator) will require the names to be enclosed in quotes to protect them from the shell. For example: RIGHT: mcopy "a:*.c" . will copy all files on the A: disk with the extension .C to the current Unix directory. WRONG: mcopy a:*.c . will cause the shell to expand a:*.c in the current Unix directory (which is probably not what you wanted) then copy that list of files (if there were any) from A: to the current Unix directory. RIGHT: mcopy *.c a: will copy all files with the extension .c in the current Unix directory to the A: drive. (This time you *want* the shell the expand the *.c). The manuals are very terse... it's assumed that the reader is already familiar with MSDOS. Mcopy is really a front-end to the low level Mread and Mwrite commands. Emmet P. Gray US Army, HQ III Corps & Fort Hood ...!uunet!uiucuxc!fthood!egray Attn: AFZF-DE-ENV fthood!egray@uxc.cso.uiuc.edu Directorate of Engineering & Housing Environmental Management Office Fort Hood, TX 76544-5057 README for Linux: This is an enhanced version of the Mtools program collection which was originally written by Emmet P. Gray . It is somewhat targetted at the Linux operating system, but should compile on systems, which run the original Mtools, with minor Makefile changes. Please send comments, bug reports, flames, etc. about the changes to Werner Almesberger . Changes to Mtools 2.0.5 ----------------------- - device configuration is read at run-time from a file /etc/mtools. - a sanity check is performed to detect incorrect FAT type settings. - stdout is flushed before reading stdin. - uses fgets instead of gets. Run-time configuration ---------------------- The mapping of DOS disk drives to UNIX devices is defined in a configura- tion file which is named /etc/mtools. An entry in /etc/mtools can have any of the following formats: drive device drive device fat drive device fat cylinders heads sectors drive device fat cylinders heads sectors offset drive is the DOS drive letter, device is the name of the device on UNIX, fat is the number of bits a FAT entry has (either 12 or 16), cylinders, heads and sectors describe the disk geometry. On hard disks, the geometry parameters should all be zero. offset specifies how many bytes should be skipped when accessing the device. This is necessary when using non- standard disk configurations. The abbreviated entries are only valid on systems for which Mtools can "guess" the disk parameters by looking at the UNIX device name. (Partial support for this feature is available if -DLINUX is set.) If this is not possible, an error message is issued. Comments begin with a number sign and end with a newline. Blank lines are ignored. A sample configuration file: # /etc/mtools - mtools device definitions A /dev/fd0 12 80 2 15 # A: 5.25" HD A /dev/fd0 12 40 2 9 # A: 5.25" B /dev/fd1 12 80 2 18 # B: 3.5" HD B /dev/fd1 12 80 2 9 # B: 3.5" C /dev/hda1 16 0 0 0 # C: 30 MB HD partition A portable /etc/mtools for floppies can be created by using zeroes for the disk geometry: # /etc/mtools - portable mtools device definitions A /dev/fd0 12 0 0 0 # any A: B /dev/fd1 12 0 0 0 # any B: This has the slight disadvantage, that mformat refuses to work. FAT type check -------------- It is important to set the FAT type right because this parameter can't be reliably computed from other parameters. Mtools tries to detect pos- sibly incorrect settings and issues an error message. If this check should be bypassed, the FAT type has to be specified as a negative number, e.g. D /dev/hda2 -16 0 0 0 Determining the correct FAT type is life critical for hard disks. Writing to a hard disks with an incorrectly set FAT type will destroy vital information. If you're not sure, whether you have a 12 or a 16 bit FAT, you should try reading a text file which is bigger than 8 kB with the mtype command. You can use the commands mcd and mdir to locate such a file. The FAT type is wrong if mtype outputs data from other files after a while. The first few kilobytes will always be read correctly, whether the FAT type is good or not.