Imported Upstream version 4.0.18
[platform/upstream/mtools.git] / mtools.texi
1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename mtools.info
4 @include version.texi
5 @settitle Mtools @value{VERSION}
6 @syncodeindex pg cp
7 @comment %**end of header
8
9 @comment MANskip 5
10
11 @copying
12 This manual is for Mtools (version @value{VERSION}, @value{UPDATED}),
13 which is a collection of tools to allow Unix systems to manipulate
14 MS-DOS files.
15
16 Copyright @copyright{} 2007, 2009 Free Software Foundation, Inc.
17 Copyright @copyright{} 1996-2005,2007-2011,2013 Alain Knaff.
18
19 @quotation
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
24 Texts.  A copy of the license is included in the section entitled
25 ``GNU Free Documentation License''.
26 @end quotation
27 @end copying
28
29 @ignore
30 @unnumbered Name
31 mtools - utilities to access DOS disks in Unix.
32 @end ignore
33
34 @include sysconfdir.texi
35
36 @iftex
37 @finalout
38 @end iftex
39
40 @dircategory DOS
41 @direntry
42 * Mtools: (mtools).        Mtools: utilities to access DOS disks in Unix.
43 @end direntry
44
45
46 @titlepage
47 @title Mtools
48
49 @c The following two commands start the copyright page.
50 @page
51 @vskip 0pt plus 1filll
52 @insertcopying
53 @end titlepage
54
55 @c Output the table contents at the beginning
56 @contents
57
58 @ifnottex
59 @node Top, Location, (dir), (dir)
60 @top Mtools doc
61
62 This is mtools' documentation.
63 @end ifnottex
64
65 @comment MANstart 1
66
67 @unnumbered Introduction
68 Mtools is a collection of tools to allow Unix systems to manipulate
69 MS-DOS files: read, write, and move around files on an MS-DOS
70 file system (typically a floppy disk).  Where reasonable, each program
71 attempts to emulate the MS-DOS equivalent command. However,
72 unnecessary restrictions and oddities of DOS are not emulated. For
73 instance, it is possible to move subdirectories from one subdirectory
74 to another.
75
76 Mtools is sufficient to give access to MS-DOS file systems.  For
77 instance, commands such as @code{mdir a:} work on the @code{a:} floppy
78 without any preliminary mounting or initialization (assuming the default
79 @file{@value{SYSCONFDIR}mtools.conf} works on your machine).  With mtools, one can
80 change floppies too without unmounting and mounting.
81
82 @insertcopying
83
84 @menu
85 * Location::          Where to find mtools and early bug fixes
86 * Common features::   Common features of all mtools commands
87 * Configuration::     How to configure mtools for your environment
88 * Commands::          The available mtools commands
89 * Compiling mtools::  Architecture specific compilation flags
90 * Porting mtools::    Porting mtools to architectures which are not
91                       yet supported
92
93 * Command Index::     Command Index
94 * Variable Index::    Variable Index
95 * Concept Index::     Concept Index
96 @end menu
97
98 @node Location, Common features, Top, Top
99 @chapter Where to get mtools
100 @cindex bugs
101 @cindex ALPHA patches
102 @cindex patches
103 @cindex diffs
104 @cindex mailing list
105
106 Mtools can be found at the following places (and their mirrors):
107 @example
108 http://ftp.gnu.org/gnu/mtools/mtools-@value{VERSION}.tar.gz
109 http://mtools.linux.lu/mtools-@value{VERSION}.tar.gz
110 ftp://www.tux.org/pub/knaff/mtools/mtools-@value{VERSION}.tar.gz
111 ftp://ibiblio.unc.edu/pub/Linux/utils/disk-management/mtools-@value{VERSION}.tar.gz
112 @end example
113
114 Before reporting a bug, make sure that it has not yet been fixed in the
115 Alpha patches which can be found at:
116 @example
117 http://ftp.gnu.org/gnu/mtools/
118 http://mtools.linux.lu/
119 ftp://www.tux.org/pub/knaff/mtools
120 @end example
121
122 These patches are named
123 @code{mtools-}@var{version}@code{-}@var{ddmm}@code{.taz}, where version
124 stands for the base version, @var{dd} for the day and @var{mm} for the
125 month. Due to a lack of space, I usually leave only the most recent
126 patch.
127
128 There is an mtools mailing list at mtools @@ tux.org .  Please
129 send all bug reports to this list.  You may subscribe to the list by
130 sending a message with 'subscribe mtools @@ tux.org' in its
131 body to majordomo @@ tux.org . (N.B. Please remove the spaces
132 around the "@@" both times. I left them there in order to fool
133 spambots.)  Announcements of new mtools versions will also be sent to
134 the list, in addition to the Linux announce newsgroups.  The mailing
135 list is archived at http://lists.gnu.org/pipermail/info-mtools/
136
137
138 @node Common features, Configuration, Location, Top
139 @chapter Common features of all mtools commands
140
141 @menu
142 * arguments::              What the command line parameters of mtools
143                            mean
144 * drive letters::          Which drives are defined by default
145 * directory::              Current working directory
146 * long names::             VFAT-style long filenames
147 * name clashes::           Name clash handling, and associated command
148                            line options
149 * case sensitivity::       Case sensitivity
150 * high capacity formats::  How to fit more data on your floppies
151 * exit codes::             Exit codes
152 * bugs::                   Happens to everybody
153 @end menu
154
155 @node arguments, drive letters, Common features, Common features
156 @section Options and filenames
157 @cindex Filenames
158 @cindex Options
159 MS-DOS filenames are composed of a drive letter followed by a colon, a
160 subdirectory, and a filename. Only the filename part is mandatory, the
161 drive letter and the subdirectory are optional. Filenames without a
162 drive letter refer to Unix files. Subdirectory names can use either the
163 '@code{/}' or '@code{\}' separator.  The use of the '@code{\}' separator
164 or wildcards requires the names to be enclosed in quotes to protect them
165 from the shell. However, wildcards in Unix filenames should not be
166 enclosed in quotes, because here we @strong{want} the shell to expand
167 them.
168
169 The regular expression "pattern matching" routines follow the Unix-style
170 rules.  For example, `@code{*}' matches all MS-DOS files in lieu of
171 `@code{*.*}'.  The archive, hidden, read-only and system attribute bits
172 are ignored during pattern matching.
173
174 All options use the @code{-} (minus) as their first character, not
175 @code{/} as you'd expect in MS-DOS.
176
177 Most mtools commands allow multiple filename parameters, which
178 doesn't follow MS-DOS conventions, but which is more user-friendly.
179
180 Most mtools commands allow options that instruct them how to handle file
181 name clashes. @xref{name clashes}, for more details on these. All
182 commands accept the @code{-V} flags which prints the version, and most
183 accept the @code{-v} flag, which switches on verbose mode. In verbose
184 mode, these commands print out the name of the MS-DOS files upon which
185 they act, unless stated otherwise. @xref{Commands}, for a description of
186 the options which are specific to each command.
187
188
189 @node drive letters, directory, arguments, Common features
190 @section Drive letters
191
192 The meaning of the drive letters depends on the target architectures.
193 However, on most target architectures, drive A is the first floppy
194 drive, drive B is the second floppy drive (if available), drive J is a
195 Jaz drive (if available), and drive Z is a Zip drive (if available).  On
196 those systems where the device name is derived from the SCSI id, the Jaz
197 drive is assumed to be at SCSI target 4, and the Zip at SCSI target 5
198 (factory default settings).  On Linux, both drives are assumed to be the
199 second drive on the SCSI bus (/dev/sdb). The default settings can be
200 changes using a configuration file (@pxref{Configuration}).
201
202 The drive letter : (colon) has a special meaning. It is used to access
203 image files which are directly specified on the command line using the
204 @code{-i} options.
205
206 Example:
207 @example
208  mcopy -i my-image-file.bin ::file1 ::file2 .
209 @end example
210
211 This copies @code{file1} and @code{file2} from the image file
212 (@code{my-image-file.bin}) to the @code{/tmp} directory.
213
214 You can also supply an offset within the image file by including
215 @code{@@@@}@var{offset} into the file name.
216
217 Example:
218 @example
219  mcopy -i my-image-file.bin@@@@1M ::file1 ::file2 .
220 @end example
221
222 This looks for the image at the offset of 1M in the file, rather than
223 at its beginning.
224
225 @node directory, long names, drive letters, Common features
226 @section Current working directory
227 @pindex mcd (introduction)
228 @cindex Directory
229 @cindex Working directory
230 @cindex Current working directory
231 @cindex Default directory
232
233 The @code{mcd} command (@ref{mcd}) is used to establish the device and
234 the current working directory (relative to the MS-DOS file system),
235 otherwise the default is assumed to be @code{A:/}. However, unlike
236 MS-DOS, there is only one working directory for all drives, and not one
237 per drive.
238
239 @node long names, name clashes, directory, Common features
240 @section VFAT-style long file names
241 @cindex Long file name
242 @cindex Windows 95-style file names
243 @cindex VFAT-style file names
244 @cindex Primary file name (long names)
245 @cindex Secondary file name (long names)
246
247 This version of mtools supports VFAT style long filenames. If a Unix
248 filename is too long to fit in a short DOS name, it is stored as a
249 VFAT long name, and a companion short name is generated. This short
250 name is what you see when you examine the disk with a pre-7.0 version
251 of DOS.
252  The following table shows some examples of short names:
253
254 @example
255 Long name       MS-DOS name     Reason for the change
256 ---------       ----------      ---------------------
257 thisisatest     THISIS~1        filename too long
258 alain.knaff     ALAIN~1.KNA     extension too long
259 prn.txt         PRN~1.TXT       PRN is a device name
260 .abc            ABC~1           null filename
261 hot+cold        HOT_CO~1        illegal character
262 @end example
263
264  As you see, the following transformations happen to derive a short
265 name:
266 @itemize @bullet
267 @item
268 Illegal characters are replaced by underscores. The illegal characters
269 are @code{;+=[]',\"*\\<>/?:|}.
270 @item
271 Extra dots, which cannot be interpreted as a main name/extension
272 separator are removed
273 @item
274 A @code{~}@var{n} number is generated,
275 @item
276 The name is shortened so as to fit in the 8+3 limitation
277 @end itemize
278
279  The initial Unix-style file name (whether long or short) is also called
280 the @dfn{primary} name, and the derived short name is also called the
281 @dfn{secondary} name.
282
283  Example:
284 @example
285  mcopy /etc/motd a:Reallylongname
286 @end example
287  Mtools creates a VFAT entry for Reallylongname, and uses REALLYLO as
288 a short name. Reallylongname is the primary name, and REALLYLO is the
289 secondary name.
290 @example
291  mcopy /etc/motd a:motd
292 @end example
293  Motd fits into the DOS filename limits. Mtools doesn't need to
294 derivate another name. Motd is the primary name, and there is no
295 secondary name.
296
297  In a nutshell: The primary name is the long name, if one exists, or
298 the short name if there is no long name.
299
300  Although VFAT is much more flexible than FAT, there are still names
301 that are not acceptable, even in VFAT. There are still some illegal
302 characters left (@code{\"*\\<>/?:|}), and device names are still
303 reserved.
304
305 @example
306 Unix name       Long name       Reason for the change
307 ---------       ----------      ---------------------
308 prn             prn-1           PRN is a device name
309 ab:c            ab_c-1          illegal character
310 @end example
311
312  As you see, the following transformations happen if a long name is
313 illegal:
314 @itemize @bullet
315 @item
316 Illegal characters are replaces by underscores,
317 @item
318 A @code{-}@var{n} number is generated,
319 @end itemize
320
321 @node name clashes, case sensitivity, long names, Common features
322 @section Name clashes
323 @cindex Name clashes
324 @cindex Duplicate file names
325 @cindex Overwriting files
326 @cindex Primary file name (name clashes)
327 @cindex Secondary file name (name clashes)
328
329 When writing a file to disk, its long name or short name may collide
330 with an already existing file or directory. This may happen for all
331 commands which create new directory entries, such as @code{mcopy},
332 @code{mmd}, @code{mren}, @code{mmove}. When a name clash happens, mtools
333 asks you what it should do. It offers several choices:
334
335 @table @code
336 @item overwrite
337 Overwrites the existing file. It is not possible to overwrite a
338 directory with a file.
339 @item rename
340 Renames the newly created file. Mtools prompts for the new filename
341 @item autorename
342 Renames the newly created file. Mtools chooses a name by itself, without
343 prompting
344 @item skip
345 Gives up on this file, and moves on to the next (if any)
346 @end table
347
348 To chose one of these actions, type its first letter at the prompt. If
349 you use a lower case letter, the action only applies for this file only,
350 if you use an upper case letter, the action applies to all files, and
351 you won't be prompted again.
352
353 You may also chose actions (for all files) on the command line, when
354 invoking mtools:
355
356 @table @code
357 @item -D o
358 Overwrites primary names by default.
359 @item -D O
360 Overwrites secondary names by default.
361 @item -D r
362 Renames primary name by default.
363 @item -D R
364 Renames secondary name by default.
365 @item -D a
366 Autorenames primary name by default.
367 @item -D A
368 Autorenames secondary name by default.
369 @item -D s
370 Skip primary name by default.
371 @item -D S
372 Skip secondary name by default.
373 @item -D m
374 Ask user what to do with primary name.
375 @item -D M
376 Ask user what to do with secondary name.
377 @end table
378
379 Note that for command line switches lower/upper differentiates between
380 primary/secondary name whereas for interactive choices, lower/upper
381 differentiates between just-this-time/always.
382
383 The primary name is the name as displayed in Windows 95 or Windows NT:
384 i.e. the long name if it exists, and the short name otherwise.  The
385 secondary name is the "hidden" name, i.e. the short name if a long name
386 exists.
387
388 By default, the user is prompted if the primary name clashes, and the
389 secondary name is autorenamed.
390
391 If a name clash occurs in a Unix directory, mtools only asks whether
392 to overwrite the file, or to skip it.
393
394 @node case sensitivity, high capacity formats, name clashes, Common features
395 @section Case sensitivity of the VFAT file system
396 @cindex Case sensitivity
397
398 The VFAT file system is able to remember the case of the
399 filenames. However, filenames which differ only in case are not allowed
400 to coexist in the same directory. For example if you store a file called
401 LongFileName on a VFAT file system, mdir shows this file as LongFileName,
402 and not as Longfilename. However, if you then try to add LongFilename to
403 the same directory, it is refused, because case is ignored for clash
404 checks.
405
406 The VFAT file system allows to store the case of a filename in the
407 attribute byte, if all letters of the filename are the same case, and if
408 all letters of the extension are the same case too. Mtools uses this
409 information when displaying the files, and also to generate the Unix
410 filename when mcopying to a Unix directory. This may have unexpected
411 results when applied to files written using an pre-7.0 version of DOS:
412 Indeed, the old style filenames map to all upper case. This is different
413 from the behavior of the old version of mtools which used to generate
414 lower case Unix filenames.
415
416 @node high capacity formats, exit codes, case sensitivity, Common features
417 @section high capacity formats
418 @cindex Special formats
419 @cindex High capacity formats
420 @cindex Odd formats
421 @cindex Weird formats
422 @cindex Formats, high capacity
423 @cindex Linux enhancements (High Capacity Formats)
424
425 Mtools supports a number of formats which allow to store more data on
426 disk as usual. Due to different operating system abilities, these
427 formats are not supported on all operating systems. Mtools recognizes
428 these formats transparently where supported.
429
430 In order to format these disks, you need to use an operating system
431 specific tool. For Linux, suitable floppy tools can be found in the
432 @code{fdutils} package at the following locations~:
433 @example
434 @code{ftp://www.tux.org/pub/knaff/fdutils/}.
435 @code{ftp://ibiblio.unc.edu/pub/Linux/utils/disk-management/fdutils-*}
436 @end example
437
438 See the manual pages included in that package for further detail: Use
439 @code{superformat} to format all formats except XDF, and use
440 @code{xdfcopy} to format XDF.
441
442 @menu
443 * more sectors::      Putting more sectors per track on the disk
444 * bigger sectors::    Use bigger sectors to save header space
445 * 2m::                Use a standard first track
446 * XDF::               OS/2's eXtended density format
447 @end menu
448
449 @node more sectors, bigger sectors, high capacity formats, high capacity formats
450 @subsection More sectors
451 @cindex fdformat
452 @cindex vgacopy
453 @cindex DMF disks
454 @cindex Windows 95 (DMF disks)
455
456 The oldest method of fitting more data on a disk is to use more sectors
457 and more cylinders. Although the standard format uses 80 cylinders and
458 18 sectors (on a 3 1/2 high density disk), it is possible to use up to
459 83 cylinders (on most drives) and up to 21 sectors. This method allows
460 to store up to 1743K on a 3 1/2 HD disk. However, 21 sector disks are
461 twice as slow as the standard 18 sector disks because the sectors are
462 packed so close together that we need to interleave them. This problem
463 doesn't exist for 20 sector formats.
464
465 These formats are supported by numerous DOS shareware utilities such as
466 @code{fdformat} and @code{vgacopy}. In his infinite hubris, Bill Gate$
467 believed that he invented this, and called it @samp{DMF disks}, or
468 @samp{Windows formatted disks}. But in reality, it has already existed
469 years before! Mtools supports these formats on Linux, on SunOS and on
470 the DELL Unix PC.
471
472 @node bigger sectors, 2m, more sectors, high capacity formats
473 @subsection Bigger sectors
474 @cindex bigger sectors
475 By using bigger sectors it is possible to go beyond the capacity which
476 can be obtained by the standard 512-byte sectors. This is because of the
477 sector header. The sector header has the same size, regardless of how
478 many data bytes are in the sector. Thus, we save some space by using
479 @emph{fewer}, but bigger sectors. For example, 1 sector of 4K only takes
480 up header space once, whereas 8 sectors of 512 bytes have also 8
481 headers, for the same amount of useful data.
482
483 This method allows to store up to 1992K on a 3 1/2 HD disk.
484
485 Mtools supports these formats only on Linux.
486
487 @node 2m, XDF, bigger sectors, high capacity formats
488 @subsection 2m
489 @cindex 2m
490
491 The 2m format was originally invented by Ciriaco Garcia de Celis. It
492 also uses bigger sectors than usual in order to fit more data on the
493 disk.  However, it uses the standard format (18 sectors of 512 bytes
494 each) on the first cylinder, in order to make these disks easier to
495 handle by DOS. Indeed this method allows to have a standard sized
496 boot sector, which contains a description of how the rest of the disk
497 should be read.
498
499 However, the drawback of this is that the first cylinder can hold less
500 data than the others. Unfortunately, DOS can only handle disks where
501 each track contains the same amount of data. Thus 2m hides the fact that
502 the first track contains less data by using a @dfn{shadow
503 FAT}. (Usually, DOS stores the FAT in two identical copies, for
504 additional safety.  XDF stores only one copy, but tells DOS that it
505 stores two. Thus the space that would be taken up by the second FAT copy
506 is saved.) This also means that you should @strong{never use a 2m disk
507 to store anything else than a DOS file system}.
508
509 Mtools supports these formats only on Linux.
510
511 @node XDF, , 2m, high capacity formats
512 @subsection XDF
513 @cindex XDF disks
514 @cindex OS/2 (XDF disks)
515
516 XDF is a high capacity format used by OS/2. It can hold 1840 K per
517 disk. That's lower than the best 2m formats, but its main advantage is
518 that it is fast: 600 milliseconds per track. That's faster than the 21
519 sector format, and almost as fast as the standard 18 sector format. In
520 order to access these disks, make sure mtools has been compiled with XDF
521 support, and set the @code{use_xdf} variable for the drive in the
522 configuration file. @xref{Compiling mtools}, and @ref{miscellaneous variables},
523 for details on how to do this. Fast XDF access is only available for
524 Linux kernels which are more recent than 1.1.34.
525
526 Mtools supports this format only on Linux.
527
528 @strong{Caution / Attention distributors}: If mtools is compiled on a
529 Linux kernel more recent than 1.3.34, it won't run on an older
530 kernel. However, if it has been compiled on an older kernel, it still
531 runs on a newer kernel, except that XDF access is slower. It is
532 recommended that distribution authors only include mtools binaries
533 compiled on kernels older than 1.3.34 until 2.0 comes out. When 2.0 will
534 be out, mtools binaries compiled on newer kernels may (and should) be
535 distributed. Mtools binaries compiled on kernels older than 1.3.34 won't
536 run on any 2.1 kernel or later.
537
538 @node exit codes, bugs, high capacity formats, Common features
539 @section Exit codes
540 All the Mtools commands return 0 on success, 1 on utter failure, or 2
541 on partial failure.  All the Mtools commands perform a few sanity
542 checks before going ahead, to make sure that the disk is indeed an
543 MS-DOS disk (as opposed to, say an ext2 or MINIX disk). These checks
544 may reject partially corrupted disks, which might otherwise still be
545 readable. To avoid these checks, set the MTOOLS_SKIP_CHECK
546 environmental variable or the corresponding configuration file variable
547 (@pxref{global variables})
548 @node bugs, , exit codes, Common features
549 @section Bugs
550 An unfortunate side effect of not guessing the proper device (when
551 multiple disk capacities are supported) is an occasional error message
552 from the device driver.  These can be safely ignored.  
553
554 The fat checking code chokes on 1.72 Mb disks mformatted with pre-2.0.7
555 mtools. Set the environmental variable MTOOLS_FAT_COMPATIBILITY (or the
556 corresponding configuration file variable, @ref{global variables}) to
557 bypass the fat checking.
558
559 @comment MANskip 1
560
561 @ignore
562 @unnumbered Name
563 mtools.conf - mtools configuration files
564
565 @comment MANend-skip 5
566 @section Description
567
568 This manual page describes the configuration files for mtools. They 
569 @comment MANskip 5
570 @end ignore
571
572
573 @node Configuration, Commands, Common features, Top
574
575
576 @chapter How to configure mtools for your environment
577 @section Description
578 @cindex Configuration files
579 @vindex MTOOLSRC
580
581  This sections explains the syntax of the configurations files for
582 mtools. The configuration files
583 @comment MANend-skip 5
584 are called @file{@value{SYSCONFDIR}mtools.conf} and @file{~/.mtoolsrc}. If
585 the environmental variable @code{MTOOLSRC} is set, its contents is used
586 as the filename for a third configuration file. These configuration
587 files describe the following items:
588
589 @itemize @bullet
590 @item Global configuration flags and variables
591 @item Per drive flags and variables
592 @end itemize
593
594
595 @menu
596 * configuration file location::  Where mtools looks for its configuration files
597 * general syntax::        The layout of the configuration files
598 * default values::        Why you don't need a configuration file in most cases
599 * global variables::      Variables that are independent of the drive
600 * per drive variables::   Variables that are specific to a given drive
601 * parsing order::         Location of configuration files and parsing order
602 * old style configuration::      Backwards compatibility
603 @end menu
604
605 @node configuration file location, general syntax, Configuration, Configuration
606 @section Location of the configuration files
607
608 @cindex Configuration file name
609 @cindex Name of configuration files
610 @cindex Location of configuration files
611
612 @file{@value{SYSCONFDIR}mtools.conf} is the system-wide configuration file,
613 and @file{~/.mtoolsrc} is the user's private configuration file.
614
615 On some systems, the system-wide configuration file is called
616 @file{/etc/default/mtools.conf} instead.
617
618
619 @node general syntax, default values, configuration file location, Configuration
620 @subsection General configuration file syntax
621 @cindex Syntax of the configuration file
622 @cindex Configuration file syntax
623
624 The configuration files is made up of sections. Each section starts
625 with a keyword identifying the section followed by a colon.
626 Then follow variable assignments and flags. Variable assignments take
627 the following form:
628 @display
629 name=value
630 @end display
631 Flags are lone keywords without an equal sign and value following
632 them.  A section either ends at the end of the file or where the next
633 section begins.
634
635 Lines starting with a hash (@code{#}) are comments. Newline characters
636 are equivalent to whitespace (except where ending a comment). The
637 configuration file is case insensitive, except for item enclosed in
638 quotes (such as filenames).
639
640 @node default values, global variables, general syntax, Configuration
641 @section Default values
642 @cindex Default values
643 @cindex Default configuration
644 @cindex Configuration file
645 For most platforms, mtools contains reasonable compiled-in defaults for
646 physical floppy drives.  Thus, you usually don't need to bother with the
647 configuration file, if all you want to do with mtools is to access your
648 floppy drives. On the other hand, the configuration file is needed if
649 you also want to use mtools to access your hard disk partitions and
650 DOSEMU image files.
651
652 @node global variables, per drive variables, default values, Configuration
653 @section Global variables
654 @cindex Global configuration variables
655 @cindex Drive independent configuration variables
656 @cindex Environmental variables
657 @vindex MTOOLS_SKIP_CHECK
658 @vindex MTOOLS_FAT_COMPATIBILITY
659 @vindex MTOOLS_LOWER_CASE
660 @vindex MTOOLS_NO_VFAT
661 @cindex FreeDOS
662
663 Global flags may be set to 1 or to 0.
664
665 The following global flags are recognized:
666
667 @table @code
668 @item MTOOLS_SKIP_CHECK
669 If this is set to 1, mtools skips most of its sanity checks. This is
670 needed to read some Atari disks which have been made with the earlier
671 ROMs, and which would not be recognized otherwise.
672 @item MTOOLS_FAT_COMPATIBILITY
673 If this is set to 1, mtools skips the fat size checks. Some disks have
674 a bigger FAT than they really need to. These are rejected if this
675 option is not set.
676 @item MTOOLS_LOWER_CASE
677 If this is set to 1, mtools displays all-upper-case short filenames as
678 lowercase. This has been done to allow a behavior which is consistent
679 with older versions of mtools which didn't know about the case bits.
680 @item MTOOLS_NO_VFAT
681 If this is set to 1, mtools won't generate VFAT entries for filenames
682 which are mixed-case, but otherwise legal dos filenames.  This is useful
683 when working with DOS versions which can't grok VFAT long names, such as
684 FreeDOS.
685 @item MTOOLS_DOTTED_DIR
686 In a wide directory, prints the short name with a dot instead of spaces
687 separating the basename and the extension.
688 @item MTOOLS_NAME_NUMERIC_TAIL
689 If this is set to one (default), generate numeric tails for all long
690 names (~1).  If set to zero, only generate numeric tails if otherwise a
691 clash would have happened.
692 @item MTOOLS_TWENTY_FOUR_HOUR_CLOCK
693 If 1, uses the European notation for times (twenty four hour clock),
694 else uses the UK/US notation (am/pm)
695 @end table
696
697 Example:
698 Inserting the following line into your configuration file instructs
699 mtools to skip the sanity checks:
700 @example
701   MTOOLS_SKIP_CHECK=1
702 @end example
703
704 Global variables may also be set via the environment:
705 @example
706   export MTOOLS_SKIP_CHECK=1
707 @end example
708
709 Global string variables may be set to any value:
710 @table @code
711 @item MTOOLS_DATE_STRING
712 The format used for printing dates of files.  By default, is dd-mm-yyyy.
713 @end table
714
715 @node per drive variables, parsing order, global variables, Configuration
716 @section Per drive flags and variables
717 @cindex Drive description
718 @cindex Drive configuration
719
720 @menu
721 * general information::   What a drive description looks like
722 * location information::  Where is the drive data physically stored
723 * geometry description::  Describes the physical characteristics of
724                           the media
725 * open flags::            Flags passed to the open system call when the
726                           device is opened
727 * miscellaneous variables::        Variables which don't fit in either category
728 * miscellaneous flags::           Switch variables, which can be enabled or disabled
729 * multiple descriptions:: How to supply several descriptions for a
730                           drive, to be tried one after the other.
731 @end menu
732
733 @node general information, location information, per drive variables, per drive variables
734 @subsection General information
735 @cindex Drive description, example
736 @cindex Drive configuration, example
737 @vindex drive
738
739 Per drive flags and values may be described in a drive section. A
740 drive section starts with
741 @code{drive} "@var{driveletter}" :
742
743 Then follow variable-value pairs and flags.
744
745 This is a sample drive description:
746 @example
747   drive a:
748     file="/dev/fd0" use_xdf=1
749 @end example
750
751 @node location information, geometry description, general information, per drive variables
752 @subsection Location information
753 @cindex Hdimage
754
755 For each drive, you need to describe where its data is physically
756 stored (image file, physical device, partition, offset).
757
758 @table @code
759 @item file
760 @cindex Image file
761 @cindex Name of device node
762 @cindex File name of device node
763 @vindex file
764 The name of the file or device holding the disk image. This is
765 mandatory. The file name should be enclosed in quotes.
766
767 @item partition
768 @cindex DOSEMU hard disk image
769 @cindex Zip disks (partitions)
770 @cindex Jaz disks (partitions)
771 @cindex Syquest disks
772 @cindex Magneto-optical disks
773 @cindex OS/2 (layout of removable media)
774 @cindex Windows NT (layout of removable media)
775 @cindex Removable media
776 @cindex Partitioned image file
777 Tells mtools to treat the drive as a partitioned device, and to use the
778 given partition. Only primary partitions are accessible using this
779 method, and they are numbered from 1 to 4. For logical partitions, use
780 the more general @code{offset} variable. The @code{partition} variable
781 is intended for removable media such as Syquest disks, ZIP drives, and
782 magneto-optical disks. Although traditional DOS sees Syquest disks and
783 magneto-optical disks as @samp{giant floppy disks} which are
784 unpartitioned, OS/2 and Windows NT treat them like hard disks,
785 i.e. partitioned devices. The @code{partition} flag is also useful DOSEMU
786 hdimages. It is not recommended for hard disks for which direct access
787 to partitions is available through mounting.
788
789 @item offset
790 @cindex Ram disk
791 @cindex Atari Ram disk
792 Describes where in the file the MS-DOS file system starts. This is useful
793 for logical partitions in DOSEMU hdimages, and for ATARI ram disks. By
794 default, this is zero, meaning that the file system starts right at the
795 beginning of the device or file.
796 @end table
797
798 @node geometry description, open flags, location information, per drive variables
799 @subsection Disk Geometry Configuration
800 @cindex Disk Geometry
801 @cindex Configuration of disk geometry
802 @cindex Description of disk geometry
803 @cindex Format of disk
804 @cindex High density disk
805 @cindex Low density disk
806 @pindex mformat (geometry used for)
807
808 Geometry information describes the physical characteristics about the
809 disk. Its has three purposes:
810
811 @table @asis
812 @item formatting
813 The geometry information is written into the boot sector of the newly
814 made disk. However, you may also describe the geometry information on
815 the command line. @xref{mformat}, for details.
816 @item filtering
817 On some Unixes there are device nodes which only support one physical
818 geometry. For instance, you might need a different node to access a disk
819 as high density or as low density. The geometry is compared to the
820 actual geometry stored on the boot sector to make sure that this device
821 node is able to correctly read the disk. If the geometry doesn't match,
822 this drive entry fails, and the next drive entry bearing the same drive
823 letter is tried. @xref{multiple descriptions}, for more details on
824 supplying several descriptions for one drive letter.
825
826 If no geometry information is supplied in the configuration file, all
827 disks are accepted. On Linux (and on SPARC) there exist device nodes
828 with configurable geometry (@file{/dev/fd0}, @file{/dev/fd1} etc),
829 and thus filtering is not needed (and ignored) for disk drives.  (Mtools
830 still does do filtering on plain files (disk images) in Linux: this is
831 mainly intended for test purposes, as I don't have access to a Unix
832 which would actually need filtering).
833
834 If you do not need filtering, but want still a default geometry for
835 mformatting, you may switch off filtering using the @code{mformat_only}
836 flag.
837
838 If you want filtering, you should supply the @code{filter} flag.  If you 
839 supply a geometry, you must supply one of both flags.
840
841 @item initial geometry
842 On devices that support it (usually floppy devices), the geometry
843 information is also used to set the initial geometry. This initial
844 geometry is applied while reading the boot sector, which contains the
845 real geometry.  If no geometry information is supplied in the
846 configuration file, or if the @code{mformat_only} flag is supplied, no
847 initial configuration is done.
848
849 On Linux, initial geometry is not really needed, as the configurable
850 devices are able to auto-detect the disk type accurately enough (for
851 most common formats) to read the boot sector.
852 @end table
853
854 Wrong geometry information may lead to very bizarre errors. That's why I
855 strongly recommend that you add the @code{mformat_only} flag to your
856 drive description, unless you really need filtering or initial geometry.
857
858 The following geometry related variables are available:
859
860 @table @code
861 @item cylinders
862 @itemx tracks
863 @vindex cylinders
864 @vindex tracks
865 The number of cylinders. (@code{cylinders} is the preferred form,
866 @code{tracks} is considered obsolete)
867 @item heads
868 @vindex heads
869 The number of heads (sides).
870 @item sectors
871 @vindex sectors
872 The number of sectors per track.
873 @end table
874
875 Example: the following drive section describes a 1.44M drive:
876
877 @example
878   drive a:
879       file="/dev/fd0H1440"
880       fat_bits=12
881       cylinders=80 heads=2 sectors=18
882       mformat_only
883 @end example
884
885 The following shorthand geometry descriptions are available:
886
887 @table @code
888 @item 1.44m
889 high density 3 1/2 disk. Equivalent to:
890 @code{fat_bits=12 cylinders=80 heads=2 sectors=18}
891 @item 1.2m
892 high density 5 1/4 disk. Equivalent to:
893 @code{fat_bits=12 cylinders=80 heads=2 sectors=15}
894 @item 720k
895 double density 3 1/2 disk. Equivalent to:
896 @code{fat_bits=12 cylinders=80 heads=2 sectors=9}
897 @item 360k
898 double density 5 1/4 disk. Equivalent to:
899 @code{fat_bits=12 cylinders=40 heads=2 sectors=9}
900 @end table
901
902 The shorthand format descriptions may be amended. For example,
903 @code{360k sectors=8}
904 describes a 320k disk and is equivalent to:
905 @code{fat_bits=12 cylinders=40 heads=2 sectors=8}
906
907 @node open flags, miscellaneous variables, geometry description, per drive variables
908 @subsection Open Flags
909 @vindex sync
910 @vindex nodelay
911 @vindex exclusive
912 @cindex open flags
913 @cindex synchronous writing
914 @cindex exclusive access to a drive
915
916 Moreover, the following flags are available:
917
918 @table @code
919 @item sync
920 All i/o operations are done synchronously
921 @item nodelay
922 The device or file is opened with the O_NDELAY flag. This is needed on
923 some non-Linux architectures.
924 @item exclusive
925 The device or file is opened with the O_EXCL flag. On Linux, this
926 ensures exclusive access to the floppy drive. On most other
927 architectures, and for plain files it has no effect at all.
928 @end table
929
930
931 @node miscellaneous variables, miscellaneous flags, open flags, per drive variables
932 @subsection General Purpose Drive Variables
933
934 The following general purpose drive variables are available.  Depending
935 to their type, these variables can be set to a string (precmd) or
936 an integer (all others)
937
938 @table @code
939 @item fat_bits
940 @vindex fat_bits
941 The number of FAT bits. This may be 12 or 16. This is very rarely
942 needed, as it can almost always be deduced from information in the
943 boot sector. On the contrary, describing the number of fat bits may
944 actually be harmful if you get it wrong. You should only use it if
945 mtools gets the auto-detected number of fat bits wrong, or if you want
946 to mformat a disk with a weird number of fat bits.
947 @item codepage
948 Describes the DOS code page used for short filenames. This is a number
949 between 1 and 999. By default, code page 850 is used. The reason for
950 this is because this code page contains most of the characters that are
951 also available in ISO-Latin-1. You may also specify a global code page
952 for all drives by using the global @code{default_codepage} parameter
953 (outside of any drive description). This parameters exists starting at
954 version 4.0.0
955 @item precmd
956 @cindex Solaris (volcheck)
957 @cindex Executing commands before opening the device
958 On some variants of Solaris, it is necessary to call 'volcheck -v'
959 before opening a floppy device, in order for the system to notice that
960 there is indeed a disk in the drive. @code{precmd="volcheck -v"} in the
961 drive clause establishes the desired behavior.
962
963 @item blocksize
964 @cindex raw device
965 @cindex character devices
966 @cindex blocksize
967 This parameter represents a default block size to be always used on this
968 device.  All I/O is done with multiples of this block size,
969 independently of the sector size registered in the file system's boot
970 sector.  This is useful for character devices whose sector size is not
971 512, such as for example CD-ROM drives on Solaris.
972
973 @end table
974
975 Only the @code{file} variable is mandatory. The other parameters may
976 be left out. In that case a default value or an auto-detected value is
977 used.
978
979
980
981 @node miscellaneous flags, multiple descriptions, miscellaneous variables, per drive variables
982 @subsection General Purpose Drive Flags
983
984 A flag can either be set to 1 (enabled) or 0 (disabled). If the value is
985 omitted, it is enabled.  For example, @code{scsi} is equivalent to
986 @code{scsi=1}
987
988 @table @code
989 @item nolock
990 @cindex disable locking
991 @cindex locking (disabling it)
992 @cindex plain floppy: device xxx busy
993 Instruct mtools to not use locking on this drive.  This is needed on
994 systems with buggy locking semantics.  However, enabling this makes
995 operation less safe in cases where several users may access the same
996 drive at the same time.
997
998 @item scsi
999 @cindex setuid installation (needed for raw SCSI I/O)
1000 @cindex Solaris (Raw access to SCSI devices such as Zip & Jaz)
1001 @cindex SunOS (Raw access to SCSI devices such as Zip & Jaz)
1002 @cindex Zip disks (raw SCSI access)
1003 @cindex Jaz disks (raw SCSI access)
1004 @cindex Syquest disks (raw SCSI access)
1005 @cindex SCSI devices
1006 When set to 1, this option tells mtools to use raw SCSI I/O instead of
1007 the standard read/write calls to access the device. Currently, this is
1008 supported on HP-UX, Solaris and SunOS.  This is needed because on some
1009 architectures, such as SunOS or Solaris, PC media can't be accessed
1010 using the @code{read} and @code{write} system calls, because the OS expects
1011 them to contain a Sun specific "disk label".
1012
1013 As raw SCSI access always uses the whole device, you need to specify the
1014 "partition" flag in addition
1015
1016 On some architectures, such as Solaris, mtools needs root privileges to
1017 be able to use the @code{scsi} option.  Thus mtools should be installed
1018 setuid root on Solaris if you want to access Zip/Jaz drives.  Thus, if
1019 the @code{scsi} flag is given, @code{privileged} is automatically
1020 implied, unless explicitly disabled by @code{privileged=0}
1021
1022 Mtools uses its root privileges to open the device, and to issue the
1023 actual SCSI I/O calls.  Moreover, root privileges are only used for
1024 drives described in a system-wide configuration file such as
1025 @file{@value{SYSCONFDIR}mtools.conf}, and not for those described in
1026 @file{~/.mtoolsrc} or @file{$MTOOLSRC}.  
1027
1028 @item privileged
1029 @cindex setuid installation
1030 @cindex setgid installation
1031 When set to 1, this instructs mtools to use its setuid and setgid
1032 privileges for opening the given drive.  This option is only valid for
1033 drives described in the system-wide configuration files (such as
1034 @file{@value{SYSCONFDIR}mtools.conf}, not @file{~/.mtoolsrc} or
1035 @file{$MTOOLSRC}).  Obviously, this option is also a no op if mtools is
1036 not installed setuid or setgid.  This option is implied by 'scsi=1', but
1037 again only for drives defined in system-wide configuration files.
1038 Privileged may also be set explicitly to 0, in order to tell mtools not
1039 to use its privileges for a given drive even if @code{scsi=1} is set.
1040
1041 Mtools only needs to be installed setuid if you use the
1042 @code{privileged} or @code{scsi} drive variables.  If you do not use
1043 these options, mtools works perfectly well even when not installed
1044 setuid root.
1045
1046 @item vold
1047 @cindex Solaris (vold)
1048 @cindex Vold (mediamgr)
1049
1050 Instructs mtools to interpret the device name as a vold identifier
1051 rather than as a filename.  The vold identifier is translated into a
1052 real filename using the @code{media_findname()} and
1053 @code{media_oldaliases()} functions of the @code{volmgt} library.  This
1054 flag is only available if you configured mtools with the
1055 @code{--enable-new-vold} option before compilation.
1056
1057 @item swap
1058 @cindex Atari
1059 @cindex Wordswapped
1060
1061 Consider the media as a word-swapped Atari disk.
1062
1063 @item use_xdf
1064 @cindex XDF disks (how to configure)
1065 @vindex use_xdf
1066 If this is set to a non-zero value, mtools also tries to access this
1067 disk as an XDF disk. XDF is a high capacity format used by OS/2. This
1068 is off by default. @xref{XDF}, for more details.
1069 @item mformat_only
1070 @vindex mformat_only
1071 Tells mtools to use the geometry for this drive only for mformatting and 
1072 not for filtering.
1073
1074 @item filter
1075 @vindex filter
1076 Tells mtools to use the geometry for this drive both for mformatting and 
1077 filtering.
1078
1079 @item remote
1080 Tells mtools to connect to floppyd (@pxref{floppyd}).
1081 @end table
1082
1083
1084 @node multiple descriptions, , miscellaneous flags, per drive variables
1085 @subsection Supplying multiple descriptions for a drive
1086
1087 It is possible to supply multiple descriptions for a drive. In that
1088 case, the descriptions are tried in order until one is found that
1089 fits. Descriptions may fail for several reasons:
1090
1091 @enumerate
1092 @item
1093 because the geometry is not appropriate,
1094 @item
1095 because there is no disk in the drive,
1096 @item
1097 or because of other problems.
1098 @end enumerate
1099
1100 Multiple definitions are useful when using physical devices which are
1101 only able to support one single disk geometry.
1102 Example:
1103 @example
1104   drive a: file="/dev/fd0H1440" 1.44m
1105   drive a: file="/dev/fd0H720" 720k
1106 @end example
1107
1108 This instructs mtools to use /dev/fd0H1440 for 1.44m (high density)
1109 disks and /dev/fd0H720 for 720k (double density) disks. On Linux, this
1110 feature is not really needed, as the /dev/fd0 device is able to handle
1111 any geometry.
1112
1113 You may also use multiple drive descriptions to access both of your
1114 physical drives through one drive letter:
1115
1116 @example
1117   drive z: file="/dev/fd0"
1118   drive z: file="/dev/fd1"
1119 @end example
1120
1121 With this description, @code{mdir z:} accesses your first physical
1122 drive if it contains a disk. If the first drive doesn't contain a disk,
1123 mtools checks the second drive.
1124
1125 When using multiple configuration files, drive descriptions in the files
1126 parsed last override descriptions for the same drive in earlier
1127 files. In order to avoid this, use the @code{drive+} or @code{+drive}
1128 keywords instead of @code{drive}. The first adds a description to the
1129 end of the list (i.e. it will be tried last), and the first adds it to
1130 the start of the list.
1131
1132 @node parsing order, old style configuration, per drive variables, Configuration
1133 @section Location of configuration files and parsing order
1134 @cindex Parsing order
1135 @cindex Configuration file parsing order
1136 @cindex Configuration file name (parsing order)
1137 @cindex Name of configuration files (parsing order)
1138 @cindex Location of configuration files (parsing order)
1139
1140 The configuration files are parsed in the following order:
1141 @enumerate
1142 @item
1143 compiled-in defaults
1144 @item
1145 @file{@value{SYSCONFDIR}mtools.conf}
1146 @item
1147 @file{~/.mtoolsrc}.
1148 @item
1149 @file{$MTOOLSRC} (file pointed by the @code{MTOOLSRC} environmental
1150 variable)
1151 @end enumerate
1152
1153 Options described in the later files override those described in the
1154 earlier files. Drives defined in earlier files persist if they are not
1155 overridden in the later files. For instance, drives A and B may be
1156 defined in @file{@value{SYSCONFDIR}mtools.conf} and drives C and D may be
1157 defined in @file{~/.mtoolsrc} However, if @file{~/.mtoolsrc} also
1158 defines drive A, this new description would override the description of
1159 drive A in @file{@value{SYSCONFDIR}mtools.conf} instead of adding to it. If
1160 you want to add a new description to a drive already described in an
1161 earlier file, you need to use either the @code{+drive} or @code{drive+}
1162 keyword.
1163
1164 @node old style configuration, , parsing order, Configuration
1165 @section Backwards compatibility with old configuration file syntax
1166 @cindex Backwards compatibility
1167 @cindex Old configuration file syntax
1168 @cindex Configuration file, old syntax
1169
1170 The syntax described herein is new for version @code{mtools-3.0}. The
1171 old line-oriented syntax is still supported. Each line beginning with a
1172 single letter is considered to be a drive description using the old
1173 syntax. Old style and new style drive sections may be mixed within the
1174 same configuration file, in order to make upgrading easier. Support for
1175 the old syntax will be phased out eventually, and in order to discourage
1176 its use, I purposefully omit its description here.
1177
1178 @comment MANskip 5
1179
1180 @node Commands, Compiling mtools, Configuration, Top
1181 @chapter Command list
1182 @cindex Command list
1183 @cindex List of available commands
1184
1185  This section describes the available mtools commands, and the command
1186 line parameters that each of them accepts. Options which are common to
1187 all mtools commands are not described here, @ref{arguments} for a
1188 description of those.
1189
1190 @menu
1191 * floppyd::           floppy daemon to run on your X server box
1192 * floppyd_installtest:: small utility to check for the presence of floppyd
1193 * mattrib::           change MS-DOS file attribute flags
1194 * mbadblocks::        tests a floppy disk, and marks the bad blocks in the FAT
1195 * mcat::              same as cat. Only useful with floppyd.
1196 * mcd::               change MS-DOS directory
1197 * mclasserase::       erase memory card
1198 * mcopy::             copy MS-DOS files to/from Unix
1199 * mdel::              delete an MS-DOS file
1200 * mdeltree::          recursively delete an MS-DOS directory
1201 * mdir::              display an MS-DOS directory
1202 * mdu::               list space occupied by directory and its contents
1203 * mformat::           add an MS-DOS file system to a low-level formatted floppy disk
1204 * minfo::             get information about an MS-DOS file system.
1205 * mlabel::            make an MS-DOS volume label
1206 * mkmanifest::        makes a list of short name equivalents
1207 * mmd::               make an MS-DOS subdirectory
1208 * mmount::            mount an MS-DOS disk
1209 * mpartition::        create an MS-DOS as a partition
1210 * mrd::               remove an MS-DOS subdirectory
1211 * mmove::             move or rename an MS-DOS file or subdirectory
1212 * mren::              rename an existing MS-DOS file
1213 * mshortname::        shows the short name of a file
1214 * mshowfat::          shows the FAT map of a file
1215 * mtoolstest::        tests and displays the configuration
1216 * mtype::             display contents of an MS-DOS file
1217 * mzip::              zip disk specific commands
1218 @end menu
1219
1220 @node floppyd, floppyd_installtest, Commands, Commands
1221 @section Floppyd
1222 @pindex floppyd
1223 @cindex X terminal
1224 @cindex remote floppy access
1225
1226 @code{Floppyd} is used as a server to grant access to the floppy drive
1227 to clients running on a remote machine, just as an X server grants
1228 access to the display to remote clients.  It has the following syntax:
1229
1230 @code{floppyd} [@code{-d}] [@code{-l}] [@code{-s} @var{port}] [@code{-r}
1231 @var{user}] [@code{-b} @var{ipaddr}] [@code{-x} @var{display}] @var{devicenames}
1232
1233
1234 @code{floppyd} is always associated with an X server.  It runs on the
1235 same machine as its X server, and listens on port 5703 and above.
1236
1237 @subsection Authentication
1238
1239 @code{floppyd} authenticates remote clients using the @code{Xauthority}
1240 protocol. Xhost authentication is not supported. Each floppyd is
1241 associated with an X server.  When a remote client attempts to connect
1242 to floppyd, it sends floppyd the X authority record corresponding to
1243 floppyd's X server.  Floppyd in turn then tries to open up a connection
1244 to the X server in order to verify the authenticity of the xauth record.
1245 If the connection to the X server succeeds, the client is granted
1246 access.
1247 @code{DISPLAY}.
1248
1249 @strong{Caution}: In order to make authentication work correctly, the
1250 local host should @strong{not} be listed in the @code{xhost} list of
1251 allowed hosts.
1252  Indeed, hosts listed in @code{xhost} do not need a correct
1253 @code{Xauthority} cookie to connect to the X server. As @code{floppyd}
1254 runs on the same host as the X server, all its probe connection would
1255 succeed even for clients who supplied a bad cookie.  This means that
1256 your floppy drive would be open to the world, i.e. a huge security hole.
1257  If your X server does not allow you to remove @code{localhost:0} and
1258 @code{:0} from the @code{xhost} list, you can prevent floppyd from
1259 probing those display names with the @code{-l} option.
1260
1261 @subsection Command line options
1262
1263 @table @code
1264 @item d
1265 Daemon mode. Floppyd runs its own server loop.  Do not supply this if
1266 you start floppyd from @code{inetd.conf}
1267 @item s  @var{port}
1268 Port number for daemon mode.  Default is 5703 + @var{displaynumber}.
1269 This flag implies daemon mode.  For example, for display
1270 @code{hitchhiker:5}, the port would be 5708.
1271 @item b  @var{ipaddr}
1272 Bind address (for multi homed hosts). This flag implies daemon mode
1273 @item r @var{user}
1274 Run the server under as the given user
1275 @item x @var{display}
1276 X display to use for authentication. By default, this is taken from the
1277 @code{DISPLAY} variable. If neither the @code{x} attribute is present
1278 nor @code{DISPLAY} is set, floppyd uses @code{:0.0}.
1279 @end table
1280
1281 @var{devicenames} is a list of device nodes to be opened.  Default
1282 is @code{/dev/fd0}. Multiple devices are only supported on mtools
1283 versions newer than 3.9.11.
1284
1285
1286 @subsection Connecting to floppyd
1287
1288  In order to use floppyd, add the flag @code{remote} to the device
1289 description in your @file{~/.mtoolsrc} file.  If the flag @code{remote}
1290 is given, the @code{file} parameter of the device description is taken
1291 to be a remote address.  It's format is the following:
1292 @var{hostname}@code{:}@var{displaynumber}[@code{/}[@var{baseport}][@code{/}@var{drive}]]. When
1293 using this entry, mtools connects to port
1294 @var{baseport}+@var{displaynumber} at @var{hostname}. By default
1295 @var{baseport} is 5703. The drive parameter is to distinguish among
1296 multiple drives associated with a single display (only mtools versions
1297 more recent than 3.9.11)
1298
1299 @subsection Examples:
1300
1301  The following starts a floppy daemon giving access to @file{/dev/fd0},
1302 listening on the default port 5703, tied to the default X servers:
1303
1304 @example
1305 floppyd -d /dev/fd0
1306 @end example
1307
1308  Each of the following starts a floppy daemon giving access to
1309 @file{/dev/fd1}, tied to the :1 local X servers, and listening on port
1310 5704. We assume that the local host is named @code{hitchhiker}.
1311
1312 @example
1313 floppyd -d /dev/fd0
1314 floppyd -d -x :1 -p 5704 /dev/fd0 
1315 @end example
1316
1317  If you want to start floppyd by @code{inetd} instead of running it as a 
1318 daemon, insert the following lines into @file{/etc/services}:
1319 @example
1320 # floppy daemon
1321 floppyd-0    5703/tcp    # floppy daemon for X server :0
1322 floppyd-1    5704/tcp    # floppy daemon for X server :1
1323 @end example
1324
1325  And insert the following into @file{/etc/inetd.conf} (assuming that you
1326 have defined a user named floppy in your @file{/etc/passwd}):
1327
1328 @example
1329 # floppy daemon
1330 floppyd-0 stream  tcp  wait  floppy  /usr/sbin/floppyd floppyd /dev/fd0 
1331 floppyd-1 stream  tcp  wait  floppy  /usr/sbin/floppyd floppyd -x :1 /dev/fd0 
1332 @end example
1333
1334  Note that you need to supply the X display names for the second
1335 floppyd.  This is because the port is opened by inetd.conf, and hence
1336 floppyd cannot know its number to interfere the display number.
1337
1338
1339 On the client side, insert the following into your @file{~/.mtoolsrc}
1340 to define a drive letter accessing floppy drive in your X terminal:
1341 @example
1342 drive x: file="$DISPLAY" remote
1343 @end example
1344
1345 If your X terminal has more than one drive, you may access the
1346 additional drives as follows:
1347 @example
1348 drive y: file="$DISPLAY//1" remote
1349 drive z: file="$DISPLAY//2" remote
1350 @end example
1351
1352 @node floppyd_installtest, mattrib, floppyd, Commands
1353 @section Floppyd_installtest
1354 @pindex floppyd_installtest
1355 @cindex X terminal
1356 @cindex remote floppy access
1357
1358 @code{Floppyd_installtest} is used to check for the presence of a running
1359 floppyd daemon. This is useful, if you have a small front-end script to
1360 mtools, which decides whether to use floppyd or not.
1361
1362 @code{floppyd_installtest} [@code{-f}]  Connect-String
1363
1364 If the @code{-f} option is specified, @code{floppyd_installtest} does a
1365 full X-Cookie authentication and complains if this does not work.
1366
1367 The connect-String has the format described in the floppyd-section:
1368 @var{hostname}@code{:}@var{displaynumber}[@code{/}@var{baseport}]
1369
1370 @node mattrib, mbadblocks, floppyd_installtest, Commands
1371 @section Mattrib
1372 @pindex mattrib
1373 @cindex Changing file attributes
1374 @cindex Hidden files
1375 @cindex Read-only files (changing the attribute)
1376 @cindex System files
1377 @cindex Archive bit
1378
1379 @code{Mattrib} is used to change MS-DOS file attribute flags. It has the
1380 following syntax:
1381
1382 @code{mattrib} [@code{-a|+a}] [@code{-h|+h}] [@code{-r|+r}]
1383 [@code{-s|+s}] [@code{-/}]  [@code{-p}] [@code{-X}] @var{msdosfile} [ @var{msdosfiles} @dots{} ]
1384
1385 @code{Mattrib} adds attribute flags to an MS-DOS file (with the
1386 `@code{+}' operator) or remove attribute flags (with the `@code{-}'
1387 operator).
1388
1389 @code{Mattrib} supports the following attribute bits:
1390
1391 @table @code
1392 @item a
1393 Archive bit.  Used by some backup programs to indicate a new file.
1394 @item r
1395 Read-only bit.  Used to indicate a read-only file.  Files with this bit
1396 set cannot be erased by @code{DEL} nor modified.
1397 @item s
1398 System bit.  Used by MS-DOS to indicate a operating system file.
1399 @item h
1400 Hidden bit.  Used to make files hidden from @code{DIR}.
1401 @end table
1402
1403 @code{Mattrib} supports the following command line flags:
1404 @table @code
1405 @item /
1406 Recursive.  Recursively list the attributes of the files in the subdirectories.
1407 @item X
1408 Concise. Prints the attributes without any whitespace padding.  If
1409 neither the "/" option is given, nor the @var{msdosfile} contains a
1410 wildcard, and there is only one MS-DOS file parameter on the command
1411 line, only the attribute is printed, and not the filename.  This option
1412 is convenient for scripts
1413 @item p
1414 Replay mode.  Outputs a series of mformat commands that will reproduce
1415 the current situation, starting from a situation as left by untarring
1416 the MS-DOS file system.  Commands are only output for attribute settings
1417 that differ from the default (archive bit set for files, unset for
1418 directories).  This option is intended to be used in addition to
1419 tar. The @code{readonly} attribute is not taken into account, as tar can
1420 set that one itself.
1421 @end table
1422
1423 @node mbadblocks, mcat, mattrib, Commands
1424 @section Mbadblocks
1425 @pindex mbadblocks
1426 @cindex Marking blocks as bad
1427 @cindex Bad blocks
1428 @cindex Read errors
1429
1430 The @code{mbadblocks} command is used to mark some clusters on an
1431 MS-DOS filesystem bad. It has the following syntax:
1432
1433 @code{mbadblocks} [@code{-s} @var{sectorlist}|@code{-c} @var{clusterlist}|-w] @var{drive}@code{:}
1434
1435 If no command line flags are supplied, @code{Mbadblocks} scans an
1436 MS-DOS filesystem for bad blocks by simply trying to read them and
1437 flag them if read fails. All blocks that are unused are scanned, and
1438 if detected bad are marked as such in the FAT.
1439
1440 This command is intended to be used right after @code{mformat}.  It is
1441 not intended to salvage data from bad disks.
1442
1443
1444 @subsection Command line options
1445
1446 @table @code
1447 @item c @var{file}
1448 Use a list of bad clusters, rather than scanning for bad clusters
1449 itself.
1450 @item s @var{file}
1451 Use a list of bad sectors (counted from beginning of filesystem),
1452 rather than trying for bad clusters itself.
1453 @item w
1454 Write a random pattern to each cluster, then read it back and flag
1455 cluster as bad if mismatch. Only free clusters are tested in such a
1456 way, so any file data is preserved.
1457 @end table
1458
1459 @subsection Bugs
1460 @code{Mbadblocks} should (but doesn't yet :-( ) also try to salvage bad
1461 blocks which are in use by reading them repeatedly, and then mark them
1462 bad.
1463
1464 @node mcat, mcd, mbadblocks, Commands
1465 @section Mcat
1466
1467 The @code{mcat} command is used to copy an entire disk image from or
1468 to the floppy device. It uses the following syntax:
1469
1470 @code{mcat} [@code{-w}] @var{drive}@code{:}
1471 @pindex mcat
1472 @cindex Copying an entire disk image
1473 @cindex Disk image
1474 @cindex Floppyd cat
1475
1476 @code{Mcat} performs the same task as the Unix @code{cat} command. It
1477 is included into the mtools package, since @code{cat} cannot access
1478 remote floppy devices offered by the mtools floppy daemon.
1479 Now it is possible to create boot floppies remotely.
1480
1481 The default operation is reading. The output is written to stdout.
1482
1483 If the @code{-w} option is specified, mcat reads a disk-image from 
1484 stdin and writes it to the given device. 
1485 @strong{Use this carefully!} Because of the low-level nature of this 
1486 command, it will happily destroy any data written before on the
1487 disk without warning!
1488
1489 @node mcd, mclasserase, mcat, Commands
1490 @section Mcd
1491 @pindex mcd
1492 @cindex Directory (changing)
1493 @cindex Working directory
1494 @cindex Current working directory (changing the)
1495 @cindex Default directory (changing the)
1496 @cindex Mcwd file
1497
1498 The @code{mcd} command is used to change the mtools working directory
1499 on the MS-DOS disk. It uses the following syntax:
1500
1501 @example
1502 @code{mcd} [@var{msdosdirectory}]
1503 @end example
1504
1505 Without arguments, @code{mcd} reports the current device and working
1506 directory.  Otherwise, @code{mcd} changes the current device and current
1507 working directory relative to an MS-DOS file system.
1508
1509 The environmental variable @code{MCWD} may be used to locate the file
1510 where the device and current working directory information is stored.
1511 The default is @file{$HOME/.mcwd}.  Information in this file is ignored
1512 if the file is more than 6 hours old.
1513
1514 @code{Mcd} returns 0 on success or 1 on failure.
1515
1516 Unlike MS-DOS versions of @code{CD}, @code{mcd} can be used to change to
1517 another device. It may be wise to remove old @file{.mcwd} files at logout.
1518
1519 @node mclasserase, mcopy, mcd, Commands
1520 @section Mclasserase
1521 @pindex mclasserase
1522 @cindex Memory Card
1523 @cindex Physically erase
1524
1525 The @code{mclasserase} command is used to wipe memory cards by
1526 overwriting it three times: first with @code{0xff}, then with
1527 @code{0x00}, then with @code{0xff} again. The command uses the following
1528 syntax:
1529
1530 @example
1531 @code{mclasserase} [@code{-d}] @var{msdosdrive}
1532 @end example
1533
1534 MS-DOS drive is optional, if none is specified, use @code{A:}. If more than
1535 one drive are specified, all but the last are ignored.
1536
1537 @code{Mclasserase} accepts the following command line options:
1538
1539 @table @code
1540 @item d
1541 Stop after each erase cycle, for testing purposes
1542 @item p
1543 Not yet implemented
1544 @end table
1545
1546
1547 @code{Mclasserase} returns 0 on success or -1 on failure.
1548
1549
1550 @node mcopy, mdel, mclasserase, Commands
1551 @section Mcopy
1552 @pindex mcopy
1553 @cindex Reading MS-DOS files
1554 @cindex Writing MS-DOS files
1555 @cindex Copying MS-DOS files
1556 @cindex Concatenating MS-DOS files
1557 @cindex Text files
1558 @cindex CR/LF conversions
1559
1560 The @code{mcopy} command is used to copy MS-DOS files to and from
1561 Unix. It uses the following syntax:
1562
1563 @example
1564 @code{mcopy} [@code{-bspanvmQT}] [@code{-D} @var{clash_option}] @var{sourcefile} @var{targetfile}
1565 @code{mcopy} [@code{-bspanvmQT}] [@code{-D} @var{clash_option}] @var{sourcefile} [ @var{sourcefiles}@dots{} ] @var{targetdirectory}
1566 @code{mcopy} [@code{-tnvm}] @var{MSDOSsourcefile}
1567 @end example
1568
1569
1570
1571 @code{Mcopy} copies the specified file to the named file, or copies
1572 multiple files to the named directory.  The source and target can be
1573 either MS-DOS or Unix files.
1574
1575 The use of a drive letter designation on the MS-DOS files, 'a:' for
1576 example, determines the direction of the transfer.  A missing drive
1577 designation implies a Unix file whose path starts in the current
1578 directory.  If a source drive letter is specified with no attached file
1579 name (e.g. @code{mcopy a: .}), all files are copied from that drive.
1580
1581 If only a single, MS-DOS source parameter is provided (e.g. "mcopy
1582 a:foo.exe"), an implied destination of the current directory
1583 (`@code{.}') is assumed.
1584
1585 A filename of `@code{-}' means standard input or standard output, depending
1586 on its position on the command line.
1587
1588 @code{Mcopy} accepts the following command line options:
1589
1590 @table @code
1591 @item t
1592 Text file transfer.  Mcopy translates incoming carriage return/line
1593 feeds to line feeds when copying from MS-DOS to Unix, and vice-versa when
1594 copying from Unix to MS-DOS.
1595 @item b
1596 Batch mode. Optimized for huge recursive copies, but less secure if a
1597 crash happens during the copy.
1598 @item s
1599 Recursive copy.  Also copies directories and their contents
1600 @item p
1601 Preserves the attributes of the copied files
1602 @item Q
1603 When mcopying multiple files, quits as soon as one copy fails (for
1604 example due to lacking storage space on the target disk)
1605 @item a
1606 Text (ASCII) file transfer.  @code{ASCII} translates incoming carriage
1607 return/line feeds to line feeds.
1608 @item T
1609 Text (ASCII) file transfer with character set conversion.  Differs from
1610 @code{-a} in the @code{ASCII} also translates incoming PC-8 characters
1611 to ISO-8859-1 equivalents as far as possible.  When reading DOS files,
1612 untranslatable characters are replaced by '@code{#}'; when writing DOS files,
1613 untranslatable characters are replaced by '@code{.}'.
1614 @item n
1615 No confirmation when overwriting Unix files.  @code{ASCII} doesn't warn
1616 the user when overwriting an existing Unix file. If the target file already exists,
1617 and the @code{-n} option is not in effect, @code{mcopy} asks whether to
1618 overwrite the file or to rename the new file (@ref{name clashes}) for
1619 details).  In order to switch off confirmation for DOS files, use @code{-o}.
1620 @item m
1621 Preserve the file modification time.
1622 @item v
1623 Verbose. Displays the name of each file as it is copied.
1624 @end table
1625
1626 @subsection Bugs
1627 Unlike MS-DOS, the '+' operator (append) from MS-DOS is not
1628 supported. However, you may use @code{mtype} to produce the same effect:
1629 @example
1630 mtype a:file1 a:file2 a:file3 >unixfile
1631 mtype a:file1 a:file2 a:file3 | mcopy - a:msdosfile
1632 @end example
1633
1634 @node mdel, mdeltree, mcopy, Commands
1635 @section Mdel
1636 @pindex mdel
1637 @cindex removing MS-DOS files
1638 @cindex erasing MS-DOS files
1639 @cindex deleting MS-DOS files
1640
1641 The @code{mdel} command is used to delete an MS-DOS file. Its syntax
1642 is:
1643
1644 @display
1645 @code{mdel} [@code{-v}] @var{msdosfile} [ @var{msdosfiles} @dots{}  ]
1646 @end display
1647
1648 @code{Mdel} deletes files on an MS-DOS file system.
1649
1650 @code{Mdel} asks for verification prior to removing a read-only file.
1651
1652 @node mdeltree, mdir, mdel, Commands
1653 @section Mdeltree
1654 @pindex mdeltree
1655 @cindex removing an MS-DOS directory recursively
1656 @cindex erasing an MS-DOS directory recursively
1657 @cindex deleting an MS-DOS directory recursively
1658 @cindex recursively removing an MS-DOS directory
1659
1660 The @code{mdeltree} command is used to delete an MS-DOS file. Its syntax
1661 is:
1662
1663 @display
1664 @code{mdeltree} [@code{-v}] @var{msdosdirectory} [@var{msdosdirectories}@dots{}]
1665 @end display
1666
1667 @code{Mdeltree} removes a directory and all the files and subdirectories
1668 it contains from an MS-DOS file system. An error occurs if the directory
1669 to be removed does not exist.
1670
1671 @node mdir, mdu, mdeltree, Commands
1672 @section Mdir
1673 @pindex mdir
1674 @cindex Read-only files (listing them)
1675 @cindex Listing a directory
1676 @cindex Directory listing
1677
1678 The @code{mdir} command is used to display an MS-DOS directory. Its
1679 syntax is:
1680
1681 @code{mdir} [@code{-/}] [@code{-f}] [@code{-w}] [@code{-a}] [@code{-b}] @var{msdosfile} [ @var{msdosfiles}@dots{}] 
1682
1683 @code{Mdir}
1684 displays the contents of MS-DOS directories, or the entries for some
1685 MS-DOS files.
1686
1687 @code{Mdir} supports the following command line options:
1688
1689 @table @code
1690 @item /
1691 Recursive output, just like MS-DOS' @code{-s} option
1692 @item w
1693 Wide output.  With this option, @code{mdir} prints the filenames across
1694 the page without displaying the file size or creation date.
1695 @item a
1696 Also list hidden files.
1697 @item f
1698 Fast.  Do not try to find out free space.  On larger disks, finding out
1699 the amount of free space takes up some non trivial amount of time, as
1700 the whole FAT must be read in and scanned.  The @code{-f} flag bypasses
1701 this step.  This flag is not needed on FAT32 file systems, which store
1702 the size explicitly.
1703 @item b
1704 Concise listing. Lists each directory name or filename, one per line
1705 (including the filename extension). This switch displays no heading
1706 information and no summary. Only a newline separated list of pathnames
1707 is displayed.
1708 @end table
1709
1710 An error occurs if a component of the path is not a directory.
1711
1712 @node mdu, mformat, mdir, Commands
1713 @section Mdu
1714 @pindex mdu
1715 @cindex Space occupied by directories and files
1716 @cindex du
1717 @cindex Listing space occupied by directories and files
1718 @cindex Occupation of space by directories and files
1719
1720 @code{Mdu} is used to list the space occupied by a directory, its
1721 subdirectories and its files. It is similar to the @code{du} command on
1722 Unix.  The unit used are clusters.  Use the minfo command to find out
1723 the cluster size.
1724
1725 @code{mdu} [@code{-a}] [ @var{msdosfiles} @dots{} ]
1726
1727
1728 @table @code
1729 @item a
1730 All files.  List also the space occupied for individual files.
1731 @item s
1732 Only list the total space, don't give details for each subdirectory.
1733 @end table
1734
1735
1736
1737 @node mformat, mkmanifest, mdu, Commands
1738 @section Mformat
1739 @pindex mformat
1740 @cindex Initializing disks
1741 @cindex Formatting disks
1742 @cindex File system creation
1743
1744 The @code{mformat} command is used to add an MS-DOS file system to a
1745 low-level formatted diskette. Its syntax is:
1746
1747 @display
1748 @code{mformat} [@code{-t} @var{cylinders}|@code{-T} @var{tot_sectors}] [@code{-h} @var{heads}] [@code{-s} @var{sectors}]
1749   [@code{-f} @var{size}] [@code{-1}] [@code{-4}] [@code{-8}]
1750   [@code{-v} @var{volume_label}]
1751   [@code{-F}] [@code{-S} @var{sizecode}]
1752   [@code{-M} @var{software_sector_size}]
1753   [@code{-N} @var{serial_number}] [@code{-a}]
1754   [@code{-C}] [@code{-H} @var{hidden_sectors}] [@code{-I} @var{fsVersion}]
1755   [@code{-r} @var{root_sectors}] [@code{-L} @var{fat_len}] 
1756   [@code{-B} @var{boot_sector}] [@code{-k}]
1757   [@code{-m} @var{media_descriptor}]
1758   [@code{-K} @var{backup_boot}]
1759   [@code{-c} @var{clusters_per_sector}]
1760   [@code{-d} @var{fat_copies}]
1761   [@code{-X}] [@code{-2} @var{sectors_on_track_0}] [@code{-3}]
1762   [@code{-0} @var{rate_on_track_0}] [@code{-A} @var{rate_on_other_tracks}]
1763   @var{drive:}
1764 @end display
1765
1766 @code{Mformat} adds a minimal MS-DOS file system (boot sector, FAT, and
1767 root directory) to a diskette that has already been formatted by a Unix
1768 low-level format.
1769
1770
1771 The following options are supported: (The S, 2, 1 and M options may not
1772 exist if this copy of mtools has been compiled without the USE_2M
1773 option)
1774
1775 The following options are the same as for MS-DOS's format command:
1776
1777 @comment xMANoptions
1778
1779 @table @code
1780 @item v
1781 Specifies the volume label. A volume label identifies the disk and can
1782 be a maximum of 11 characters. If you omit the -v switch, mformat will
1783 assign no label to the disk.
1784 @item f
1785 Specifies the size of the DOS file system to format. Only a certain
1786 number of predefined sizes are supported by this flag; for others use
1787 the -h/-t/-s flags. The following sizes are supported:
1788 @table @asis
1789 @item 160
1790 160K, single-sided, 8 sectors per track, 40 cylinders (for 5 1/4 DD)
1791 @item 180
1792 160K, single-sided, 9 sectors per track, 40 cylinders (for 5 1/4 DD)
1793 @item 320
1794 320K, double-sided, 8 sectors per track, 40 cylinders (for 5 1/4 DD)
1795 @item 360
1796 360K, double-sided, 9 sectors per track, 40 cylinders (for 5 1/4 DD)
1797 @item 720
1798 720K, double-sided, 9 sectors per track, 80 cylinders (for 3 1/2 DD)
1799 @item 1200
1800 1200K, double-sided, 15 sectors per track, 80 cylinders (for 5 1/4 HD)
1801 @item 1440
1802 1440K, double-sided, 18 sectors per track, 80 cylinders (for 3 1/2 HD)
1803 @item 2880
1804 2880K, double-sided, 36 sectors per track, 80 cylinders (for 3 1/2 ED)
1805 @end table
1806
1807 @item t
1808 Specifies the number of tracks on the disk.
1809 @item T
1810 Specifies the number of total sectors on the disk. Only one of these 2
1811 options may be specified (tracks or total sectors)
1812 @item h
1813 The number of heads (sides).
1814 @item s
1815 Specifies the number of sectors per track. If the 2m option is given,
1816 number of 512-byte sector equivalents on generic tracks (i.e. not head 0
1817 track 0).  If the 2m option is not given, number of physical sectors per
1818 track (which may be bigger than 512 bytes).
1819
1820 @item 1
1821 Formats a single side (equivalent to -h 1)
1822
1823 @item 4
1824 Formats a 360K double-sided disk (equivalent to -f 360). When used
1825 together with -the 1 switch, this switch formats a 180K disk
1826
1827 @item 8
1828 Formats a disk with 8 sectors per track.
1829
1830 @end table
1831
1832 MS-DOS format's @code{q}, @code{u} and @code{b} options are not
1833 supported, and @code{s} has a different meaning.
1834
1835 The following options are specific to mtools:
1836
1837 @table @code
1838
1839 @item F
1840 Format the partition as FAT32.
1841
1842 @item S
1843 The size code. The size of the sector is 2 ^ (sizecode + 7).
1844 @item X
1845 formats the disk as an XDF disk. @xref{XDF}, for more details. The disk
1846 has first to be low-level formatted using the xdfcopy utility included
1847 in the fdutils package. XDF disks are used for instance for OS/2 install
1848 disks.
1849 @item 2
1850 2m format. The parameter to this option describes the number of
1851 sectors on track 0, head 0. This option is recommended for sectors
1852 bigger than normal.
1853 @item 3
1854 don't use a 2m format, even if the current geometry of the disk is a 2m 
1855 geometry.
1856 @item 0
1857 Data transfer rate on track 0
1858 @item A
1859 Data transfer rate on tracks other than 0
1860 @item M
1861 software sector size. This parameter describes the sector size in bytes used
1862 by the MS-DOS file system. By default it is the physical sector size.
1863 @item N
1864 Uses the requested serial number, instead of generating one
1865 automatically
1866 @item a
1867 If this option is given, an Atari style serial number is generated.
1868 Ataris store their serial number in the OEM label.
1869 @item C
1870 creates the disk image file to install the MS-DOS file system on
1871 it. Obviously, this is useless on physical devices such as floppies
1872 and hard disk partitions, but is interesting for image files.
1873 @item H
1874 number of hidden sectors. This parameter is useful for formatting hard
1875 disk partition, which are not aligned on track boundaries (i.e. first
1876 head of first track doesn't belong to the partition, but contains a
1877 partition table). In that case the number of hidden sectors is in
1878 general the number of sectors per cylinder. This is untested.
1879 @item I
1880 Sets the fsVersion id when formatting a FAT32 drive.  In order to find
1881 this out, run minfo on an existing FAT32 drive, and mail me about it, so
1882 I can include the correct value in future versions of mtools.
1883 @item c
1884 Sets the size of a cluster (in sectors).  If this cluster size would
1885 generate a FAT that too big for its number of bits, mtools automatically
1886 increases the cluster size, until the FAT is small enough.
1887 @item d
1888 Sets the number of FAT copies. Default is 2. This setting can also be
1889 specified using the @code{MTOOLS_NFATS} environment variable.
1890 @item r
1891 Sets the size of the root directory (in sectors).  Only applicable to 12
1892 and 16 bit FATs. This setting can also be specified using the
1893 @code{MTOOLS_DIR_LEN} environment variable.
1894 @item L
1895 Sets the length of the FAT.
1896 @item B
1897 Use the boot sector stored in the given file or device, instead of using
1898 its own.  Only the geometry fields are updated to match the target disks
1899 parameters.
1900 @item k
1901 Keep the existing boot sector as much as possible.  Only the geometry
1902 fields and other similar file system data are updated to match the target
1903 disks parameters.
1904 @item K
1905 Sets the sector number where the backup of the boot sector should be
1906 stored (only relevant on FAT32).
1907
1908 @item m
1909 Use a non-standard media descriptor byte for this disk. The media
1910 descriptor is stored at position 21 of the boot sector, and as first
1911 byte in each FAT copy. Using this option may confuse DOS or older mtools
1912 version, and may make the disk unreadable. Only use if you know what you
1913 are doing.
1914
1915 @end table
1916
1917 To format a diskette at a density other than the default, you must supply
1918 (at least) those command line parameters that are different from the
1919 default.
1920
1921 @code{Mformat} returns 0 on success or 1 on failure.
1922
1923 It doesn't record bad block information to the Fat, use
1924 @code{mbadblocks} for that.
1925
1926 @node mkmanifest, minfo, mformat, Commands
1927 @section Mkmanifest
1928 @pindex mkmanifest
1929 @cindex packing list
1930
1931 The @code{mkmanifest} command is used to create a shell script (packing
1932 list) to restore Unix filenames. Its syntax is:
1933
1934 @code{mkmanifest} [ @var{files} ]
1935
1936 @code{Mkmanifest} creates a shell script that aids in the restoration of
1937 Unix filenames that got clobbered by the MS-DOS filename restrictions.
1938 MS-DOS filenames are restricted to 8 character names, 3 character
1939 extensions, upper case only, no device names, and no illegal characters.
1940
1941
1942 The mkmanifest program is compatible with the methods used in
1943 @code{pcomm, arc,} and @code{mtools} to change perfectly good Unix
1944 filenames to fit the MS-DOS restrictions. This command is only useful if
1945 the target system which will read the diskette cannot handle VFAT long
1946 names.
1947
1948 @subsection Example
1949 You want to copy the following Unix files to a MS-DOS diskette (using the
1950 @code{mcopy} command).
1951
1952 @example
1953   very_long_name
1954   2.many.dots
1955   illegal:
1956   good.c
1957   prn.dev
1958   Capital
1959 @end example
1960
1961 @code{ASCII}
1962 converts the names to:
1963
1964 @example
1965   very_lon
1966   2xmany.dot
1967   illegalx
1968   good.c
1969   xprn.dev
1970   capital
1971 @end example
1972
1973 The command:
1974 @example
1975 mkmanifest very_long_name 2.many.dots illegal: good.c prn.dev Capital >manifest
1976 @end example
1977 would produce the following:
1978 @example
1979   mv very_lon very_long_name
1980   mv 2xmany.dot 2.many.dots
1981   mv illegalx illegal:
1982   mv xprn.dev prn.dev
1983   mv capital Capital
1984 @end example
1985
1986 Notice that "good.c" did not require any conversion, so it did not
1987 appear in the output.
1988
1989 Suppose I've copied these files from the diskette to another Unix
1990 system, and I now want the files back to their original names.  If the
1991 file "manifest" (the output captured above) was sent along with those
1992 files, it could be used to convert the filenames.
1993
1994 @subsection Bugs
1995
1996 The short names generated by @code{mkmanifest} follow the old convention
1997 (from mtools-2.0.7) and not the one from Windows 95 and mtools-3.0.
1998
1999
2000 @node minfo, mlabel, mkmanifest, Commands
2001 @section Minfo
2002 @pindex minfo
2003 @cindex mformat parameters
2004 @cindex getting parameters of a MS-DOS file system
2005
2006 The @code{minfo} command prints the parameters of a MS-DOS file system, such
2007 as number of sectors, heads and cylinders.  It also prints an mformat
2008 command line which can be used to create a similar MS-DOS file system on
2009 another media.  However, this doesn't work with 2m or XDF media, and
2010 with MS-DOS 1.0 file systems
2011 @display
2012 @code{minfo} @var{drive}:
2013 @end display
2014
2015 Minfo supports the following option:
2016 @table @code
2017 @item v
2018 Prints a hexdump of the boot sector, in addition to the other information
2019 @end table
2020
2021
2022 @node mlabel, mmd, minfo, Commands
2023 @section Mlabel
2024 @pindex mlabel
2025 @cindex Labeling a disk
2026 @cindex Disk label
2027
2028 The @code{mlabel} command adds a volume label to a disk. Its syntax is:
2029 @display
2030 @code{mlabel} [@code{-vcsn}] [@code{-N} @var{serial}] @var{drive}:[@var{new_label}]
2031 @end display
2032
2033 @code{Mlabel} displays the current volume label, if present. If
2034 @var{new_label} is not given, and if neither the @code{c} nor the
2035 @code{s} options are set, it prompts the user for a new volume label.
2036 To delete an existing volume label, press return at the prompt.
2037
2038 The label is limited to 11 single-byte characters,
2039 e.g. @code{Name1234567}.
2040
2041 Reasonable care is taken to create a valid MS-DOS volume label.  If an
2042 invalid label is specified, @code{mlabel} changes the label (and
2043 displays the new label if the verbose mode is set). @code{Mlabel}
2044 returns 0 on success or 1 on failure.
2045
2046 Mlabel supports the following options:
2047 @table @code
2048 @item c
2049 Clears an existing label, without prompting the user
2050 @item s
2051 Shows the existing label, without prompting the user.
2052 @item n 
2053 Assigns a new (random) serial number to the disk
2054 @item N @var{serial}
2055 Sets the supplied serial number. The serial number should be supplied as
2056 an 8 digit hexadecimal number, without spaces
2057 @end table
2058
2059
2060 @node mmd, mmount, mlabel, Commands
2061 @section Mmd
2062 @pindex mmd
2063 @cindex Making a directory
2064 @cindex Creating a directory
2065 @cindex Directory creation
2066 @cindex Subdirectory creation
2067
2068 The @code{mmd} command is used to make an MS-DOS subdirectory. Its
2069 syntax is:
2070
2071 @code{mmd} [@code{-D} @var{clash_option}] @var{msdosdirectory} [
2072 @var{msdosdirectories}@dots{} ]
2073
2074 @code{Mmd} makes a new directory on an MS-DOS file system. An error occurs
2075 if the directory already exists.
2076
2077
2078 @node mmount, mmove, mmd, Commands
2079 @section Mmount
2080 @pindex mmount
2081 @cindex Linux enhancements (mmount)
2082 @cindex Mounting a disk
2083 @cindex High capacity formats, mounting
2084
2085 The @code{mmount} command is used to mount an MS-DOS disk. It is only
2086 available on Linux, as it is only useful if the OS kernel allows to
2087 configure the disk geometry. Its syntax is:
2088
2089 @code{mmount} @var{msdosdrive} [@var{mountargs}]
2090
2091 @code{Mmount}
2092 reads the boot sector of an MS-DOS disk, configures the drive geometry,
2093 and finally mounts it passing
2094 @code{mountargs} to @code{mount. }
2095 If no mount arguments are specified, the name of the device is
2096 used. If the disk is write protected, it is automatically mounted read
2097 only.
2098
2099
2100 @node mmove, mpartition, mmount, Commands
2101 @section Mmove
2102 @pindex mmove
2103 @cindex Moving files (mmove)
2104 @cindex Renaming files (mmove)
2105
2106 The @code{mmove} command is used to moves or renames an existing MS-DOS
2107 file or subdirectory.
2108 @display
2109 @code{mmove} [@code{-v}] [@code{-D} @var{clash_option}] @var{sourcefile} @var{targetfile}
2110 @code{mmove} [@code{-v}]  [@code{-D} @var{clash_option}] @var{sourcefile} [ @var{sourcefiles}@dots{} ] @var{targetdirectory}
2111 @end display
2112 @code{Mmove} moves or renames an existing MS-DOS file or
2113 subdirectory. Unlike the MS-DOS version of @code{MOVE}, @code{mmove} is
2114 able to move subdirectories.  Files or directories can only be moved
2115 within one file system. Data cannot be moved from MS-DOS to Unix or
2116 vice-versa.  If you omit the drive letter from the target file or
2117 directory, the same letter as for the source is assumed.  If you omit
2118 the drive letter from all parameters, drive a: is assumed by default.
2119
2120 @node mpartition, mrd, mmove, Commands
2121 @section Mpartition
2122 @pindex mpartition
2123 @cindex partitions (creating)
2124 @cindex Zip disks (partitioning them)
2125 @cindex Jaz disks (partitioning them)
2126
2127 The @code{mpartition} command is used to create MS-DOS file systems as
2128 partitions.  This is intended to be used on non-Linux systems,
2129 i.e. systems where fdisk and easy access to SCSI devices are not
2130 available.  This command only works on drives whose partition variable
2131 is set.
2132
2133 @display
2134 @code{mpartition} @code{-p} @var{drive}
2135 @code{mpartition} @code{-r} @var{drive}
2136 @code{mpartition} @code{-I} [@code{-B} @var{bootSector}] @var{drive} 
2137 @code{mpartition} @code{-a} @var{drive}
2138 @code{mpartition} @code{-d} @var{drive}
2139 @code{mpartition} @code{-c} [@code{-s} @var{sectors}] [@code{-h} @var{heads}]
2140 [@code{-t} @var{cylinders}] [@code{-v} [@code{-T} @var{type}] [@code{-b}
2141 @var{begin}] [@code{-l} length] [@code{-f}]
2142
2143 @end display
2144
2145 Mpartition supports the following operations:
2146
2147 @table @code
2148 @item p
2149 Prints a command line to recreate the partition for the drive.  Nothing
2150 is printed if the partition for the drive is not defined, or an
2151 inconsistency has been detected.  If verbose (@code{-v}) is also set,
2152 prints the current partition table.
2153 @item r
2154 Removes the partition described by @var{drive}.
2155 @item I
2156 Initializes the partition table, and removes all partitions.
2157 @item c
2158 Creates the partition described by @var{drive}.
2159 @item a
2160 "Activates" the partition, i.e. makes it bootable.  Only one partition
2161 can be bootable at a time.
2162 @item d
2163 "Deactivates" the partition, i.e. makes it unbootable.
2164 @end table
2165
2166 If no operation is given, the current settings are printed.
2167
2168 For partition creations, the following options are available:
2169 @table @code
2170 @item s @var{sectors}
2171 The number of sectors per track of the partition (which is also the
2172 number of sectors per track for the whole drive).
2173 @item h @var{heads}
2174 The number of heads of the partition (which is also the number of heads
2175 for the whole drive).  By default, the geometry information (number of
2176 sectors and heads) is figured out from neighboring partition table
2177 entries, or guessed from the size.
2178 @item t @var{cylinders}
2179 The number of cylinders of the partition (not the number of cylinders of
2180 the whole drive.
2181 @item b @var{begin}
2182 The starting offset of the partition, expressed in sectors. If begin is
2183 not given, mpartition lets the partition begin at the start of the disk
2184 (partition number 1), or immediately after the end of the previous
2185 partition.
2186 @item l @var{length}
2187 The size (length) of the partition, expressed in sectors.  If end is not
2188 given, mpartition figures out the size from the number of sectors, heads
2189 and cylinders.  If these are not given either, it gives the partition
2190 the biggest possible size, considering disk size and start of the next
2191 partition.
2192 @end table
2193
2194 The following option is available for all operation which modify the
2195 partition table:
2196 @table @code
2197 @item f
2198 Usually, before writing back any changes to the partition, mpartition
2199 performs certain consistency checks, such as checking for overlaps and
2200 proper alignment of the partitions.  If any of these checks fails, the
2201 partition table is not changes.  The @code{-f} allows you to override
2202 these safeguards.
2203 @end table
2204
2205 The following options are available for all operations:
2206 @table @code
2207 @item v
2208 Together with @code{-p} prints the partition table as it is now (no
2209 change operation), or as it is after it is modified.
2210 @item vv
2211 If the verbosity flag is given twice, mpartition will print out a
2212 hexdump of the partition table when reading it from and writing it to
2213 the device.
2214 @end table
2215
2216 The following option is available for partition table initialization:
2217 @table @code
2218 @item B @var{bootSector}
2219 Reads the template master boot record from file @var{bootSector}.
2220 @end table
2221
2222
2223 @node mrd, mren, mpartition, Commands
2224 @section Mrd
2225 @pindex mrd
2226 @cindex Removing a directory
2227 @cindex Erasing a directory
2228 @cindex Deleting a directory
2229 @cindex Directory removing
2230 @cindex Subdirectory removing
2231
2232 The @code{mrd} command is used to remove an MS-DOS subdirectory. Its
2233 syntax is:
2234
2235 @display
2236 @code{mrd} [@code{-v}] @var{msdosdirectory} [ @var{msdosdirectories}@dots{} ]
2237 @end display
2238
2239 @code{Mrd} removes a directory from an MS-DOS file system. An error occurs
2240 if the directory does not exist or is not empty.
2241
2242 @node mren, mshortname, mrd, Commands
2243 @section Mren
2244 @pindex mren
2245 @cindex Renaming files (mren)
2246 @cindex Moving files (mren)
2247
2248 The @code{mren} command is used to rename or move an existing MS-DOS
2249 file or subdirectory. Its syntax is:
2250
2251 @display
2252 @code{mren} [@code{-voOsSrRA}] @var{sourcefile} @var{targetfile}
2253 @end display
2254
2255 @code{Mren}
2256 renames an existing file on an MS-DOS file system.
2257
2258 In verbose mode, @code{Mren} displays the new filename if the name
2259 supplied is invalid.
2260
2261 If the first syntax is used (only one source file), and if the target
2262 name doesn't contain any slashes or colons, the file (or subdirectory)
2263 is renamed in the same directory, instead of being moved to the current
2264 @code{mcd} directory as would be the case with @code{mmove}. Unlike the
2265 MS-DOS version of @code{REN}, @code{mren} can be used to rename
2266 directories.
2267
2268 @node mshortname, mshowfat, mren, Commands
2269 @section Mshortname
2270 @pindex mshortname
2271
2272 The @code{mshortname} command is used to display the short name of a
2273 file.  Syntax:
2274
2275 @display
2276 @code{mshortname} @var{files}
2277 @end display
2278
2279 The shortname is displayed as it is stored in raw format on disk,
2280 without any character set conversion.
2281
2282 @node mshowfat, mtoolstest, mshortname, Commands
2283 @section Mshowfat
2284 @pindex mshowfat
2285 @cindex Clusters of a file
2286 @cindex Fat
2287
2288 The @code{mshowfat} command is used to display the FAT entries for a
2289 file.  Syntax:
2290
2291 @display
2292 @code{mshowfat} [@code{-o} @var{offset}] @var{files}
2293 @end display
2294
2295 If no offset is given, a list of all clusters occupied by the file is
2296 printed. If an offset is given, only the number of the cluster
2297 containing that offset is printed.
2298
2299 @node mtoolstest, mtype, mshowfat, Commands
2300 @section Mtoolstest
2301 @pindex mtoolstest
2302 @cindex Testing configuration file for correctness
2303 @cindex Checking configuration file
2304 @cindex Verifying configuration file
2305
2306 The @code{mtoolstest} command is used to tests the mtools configuration
2307 files. To invoke it, just type @code{mtoolstest} without any arguments.
2308 @code{Mtoolstest} reads the mtools configuration files, and prints the
2309 cumulative configuration to @code{stdout}. The output can be used as a
2310 configuration file itself (although you might want to remove redundant
2311 clauses).  You may use this program to convert old-style configuration
2312 files into new style configuration files.
2313
2314 @node mtype, mzip, mtoolstest, Commands
2315 @section Mtype
2316
2317 The @code{mtype} command is used to display contents of an MS-DOS
2318 file. Its syntax is:
2319
2320 @display
2321 @code{mtype} [@code{-ts}] @var{msdosfile} [ @var{msdosfiles}@dots{} ]
2322 @end display
2323
2324 @code{Mtype} displays the specified MS-DOS file on the screen.
2325
2326 In addition to the standard options, @code{Mtype} allows the following
2327 command line options:
2328
2329 @table @code
2330 @item t
2331 Text file viewing.  @code{Mtype} translates incoming carriage
2332 return/line feeds to line feeds.
2333 @item s
2334 @code{Mtype} strips the high bit from the data.
2335 @end table
2336
2337 The @code{mcd} command may be used to establish the device and the
2338 current working directory (relative to MS-DOS), otherwise the default is
2339 @code{A:/}.
2340
2341 @code{Mtype} returns 0 on success, 1 on utter failure, or 2 on partial
2342 failure.
2343
2344 Unlike the MS-DOS version of @code{TYPE}, @code{mtype} allows multiple
2345 arguments.
2346
2347
2348 @node mzip, , mtype, Commands
2349 @section Mzip
2350 @cindex Zip disk (utilities)
2351 @cindex Jaz disk (utilities)
2352 @cindex Ejecting a Zip/Jaz disk
2353 @cindex Write protecting a Zip/Jaz disk
2354 @pindex mzip
2355 @cindex ZipTools disk
2356 @cindex Tools disk (Zip and Jaz drives)
2357 @cindex APlaceForYourStuff
2358 @cindex password protected Zip disks
2359
2360 The @code{mzip} command is used to issue ZIP disk specific commands on
2361 Linux, Solaris or HP-UX. Its syntax is:
2362
2363 @display
2364 @code{mzip} [@code{-epqrwx}]
2365 @end display
2366
2367 @code{Mzip} allows the following
2368 command line options:
2369
2370 @table @code
2371 @item e
2372 Ejects the disk.
2373 @item f
2374 Force eject even if the disk is mounted (must be given in addition to
2375 @code{-e}).
2376 @item r
2377 Write protect the disk.
2378 @item w
2379 Remove write protection.
2380 @item p
2381 Password write protect.
2382 @item x
2383 Password protect
2384 @item u
2385 Temporarily unprotect the disk until it is ejected.  The disk becomes
2386 writable, and reverts back to its old state when ejected.
2387 @item q
2388 Queries the status
2389 @end table
2390
2391 To remove the password, set it to one of the password-less modes
2392 @code{-r} or @code{-w}: mzip will then ask you for the password, and
2393 unlock the disk.  If you have forgotten the password, you can get rid of
2394 it by low-level formatting the disk (using your SCSI adapter's BIOS
2395 setup).
2396
2397 The ZipTools disk shipped with the drive is also password protected.  On
2398 MS-DOS or on a Mac, this password is automatically removed once the
2399 ZipTools have been installed.  From various articles posted to Usenet, I
2400 learned that the password for the tools disk is
2401 @code{APlaceForYourStuff}@footnote{To see the articles, search for
2402 @code{APlaceForYourStuff} using Google Groups}.  Mzip knows about this
2403 password, and tries it first, before prompting you for a password.  Thus
2404 @code{mzip -w z:} unlocks the tools disk@footnote{I didn't know about
2405 this yet when I bought my own Zip drive.  Thus I ended up reformatting
2406 my tools disk, and hence I haven't had the opportunity to test the
2407 password yet.  If anybody still has their tools disk with the original
2408 password, could you try it out? Thanks in advance}.  The tools disk is
2409 formatted in a special way so as to be usable both in a PC and in a Mac.
2410 On a PC, the Mac file system appears as a hidden file named
2411 @file{partishn.mac}.  You may erase it to reclaim the 50 Megs of space
2412 taken up by the Mac file system.
2413
2414
2415 @subsection Bugs
2416
2417 This command is a big kludge.  A proper implementation would take a
2418 rework of significant parts of mtools, but unfortunately I don't have
2419 the time for this right now. The main downside of this implementation is
2420 that it is inefficient on some architectures (several successive calls
2421 to mtools, which defeats mtools' caching).
2422
2423 @node Compiling mtools, Porting mtools, Commands, Top
2424 @chapter Architecture specific compilation flags
2425 @cindex XDF disks (compile time configuration)
2426 @cindex Solaris (compile time configuration of vold)
2427 @cindex Vold (compile time configuration)
2428 @cindex Compile time configuration
2429
2430 To compile mtools, first invoke @code{./configure} before
2431 @code{make}. In addition to the standard @code{autoconfigure} flags,
2432 there are two architecture specific flags available.
2433
2434 @table @code
2435 @item ./configure --enable-xdf
2436 @itemx ./configure --disable-xdf
2437 Enables support for XDF disks. This is on by default. @xref{XDF},
2438 for details.
2439 @item ./configure --enable-vold
2440 @itemx ./configure --disable-vold
2441 Enables support for vold on Solaris. When used in conjunction with vold,
2442 mtools should use different device nodes than for direct access.
2443
2444 @item ./configure --enable-new-vold
2445 @itemx ./configure --disable-new-vold
2446 Enables new support for vold on Solaris. This is supposed to work more
2447 smoothly than the old support.
2448
2449 @item ./configure --enable-floppyd
2450 @itemx ./configure --disable-floppyd
2451 Enables support for floppyd.  By default, floppyd support is enabled as
2452 long as the necessary X includes and libraries are available.
2453 @end table
2454
2455 @node Porting mtools, Command Index, Compiling mtools, Top
2456 @chapter Porting mtools to architectures which are not supported yet
2457 @cindex Porting
2458 @cindex Compiled-in defaults
2459
2460  This chapter is only interesting for those who want to port mtools to
2461 an architecture which is not yet supported. For most common systems,
2462 default drives are already defined. If you want to add default drives
2463 for a still unsupported system, run configuration.guess, to see which
2464 identification autoconf uses for that system. This identification is
2465 of the form cpu-vendor-os (for example sparc-sun-sunos). The cpu and
2466 the OS parts are passed to the compiler as preprocessor flags.
2467  The OS part is passed to the compiler in three forms.
2468 @enumerate
2469 @item
2470 The complete OS name, with dots replaced by underscores.  SCO3.2v2 would
2471 yield sco3_2v2
2472 @item
2473 The base OS name. SCO3.2v2 would yield Sco
2474 @item
2475 The base OS name plus its major version. SCO3.2v2 would yield Sco3
2476 @end enumerate
2477
2478  All three versions are passed, if they are different.
2479
2480  To define the devices, use the entries for the systems that are already
2481 present as templates. In general, they have the following form:
2482
2483 @example
2484 #if (defined (my_cpu) && defined(my_os))
2485 #define predefined_devices
2486 struct device devices[] = @{
2487         @{ "/dev/first_drive", 'drive_letter', drive_description@},
2488         @dots{} 
2489         @{ "/dev/last_drive", 'drive_letter', drive_description@}
2490 @}
2491 #define INIT_NOOP
2492 #endif
2493 @end example
2494
2495  "/dev/first_drive" is the name of the device or image file
2496 representing the drive. Drive_letter is a letter ranging from a to z
2497 giving access to the drive. Drive_description describes the type of the
2498 drive:
2499 @table @code
2500 @item ED312
2501 extra density (2.88M) 3 1/2 disk
2502 @item HD312
2503 high density 3 1/2 disk
2504 @item DD312
2505 double density 3 1/2 disk
2506 @item HD514
2507 high density 5 1/4 disk
2508 @item DD514
2509 double density 5 1/4 disk
2510 @item DDsmall
2511 8 sector double density 5 1/4 disk
2512 @item SS514
2513 single sided double density 5 1/4 disk
2514 @item SSsmall
2515 single sided 8 sector double density 5 1/4 disk
2516 @item GENFD
2517 generic floppy drive (12 bit FAT)
2518 @item GENHD
2519 generic hard disk (16 bit FAT)
2520 @item GEN
2521 generic device (all parameters match)
2522 @item ZIPJAZ(flags)
2523 generic ZIP drive using normal access. This uses partition 4.
2524 @code{Flags} are any special flags to be passed to open.
2525 @item RZIPJAZ(flags)
2526 generic ZIP drive using raw SCSI access. This uses partition 4.
2527 @code{Flags} are any special flags to be passed to open.
2528 @item REMOTE
2529 the remote drive used for floppyd.  Unlike the other items, this macro
2530 also includes the file name ($DISPLAY) and the drive letter (X)
2531 @end table
2532
2533  Entries may be described in more detail:
2534 @example
2535  fat_bits,open_flags,cylinders,heads,sectors,DEF_ARG
2536 @end example
2537  or, if you need to describe an offset (file system doesn't start at
2538 beginning of file system)
2539 @example
2540  fat_bits, open_flags, cylinders, heads, sectors, offset, DEF_ARG0
2541 @end example
2542
2543 @table @code
2544 @item fat_bits
2545 is either 12, 16 or 0. 0 means that the device accepts both types of
2546 FAT.
2547 @item open_flags
2548 may include flags such as O_NDELAY, or O_RDONLY, which might be
2549 necessary to open the device. 0 means no special flags are needed.
2550 @item cylinders,heads,sectors
2551 describe the geometry of the disk. If cylinders is 0, the heads and sectors
2552 parameters are ignored, and the drive accepts any geometry.
2553 @item offset 
2554 is used if the DOS file system doesn't begin at the start of the device
2555 or image file. This is mostly useful for Atari Ram disks (which contain
2556 their device driver at the beginning of the file) or for DOS emulator
2557 images (which may represent a partitioned device.
2558 @end table
2559
2560  Definition of defaults in the devices file should only be done if these
2561 same devices are found on a large number of hosts of this type. In that
2562 case, could you also let me know about your new definitions, so that I
2563 can include them into the next release.  For purely local file, I
2564 recommend that you use the @code{@value{SYSCONFDIR}mtools.conf} and
2565 @code{~/.mtoolsrc} configuration files.
2566
2567  However, the devices files also allows to supply geometry setting
2568 routines. These are necessary if you want to access high capacity
2569 disks.
2570
2571  Two routines should be supplied:
2572
2573 @enumerate
2574 @item
2575 Reading the current parameters
2576 @example
2577 static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
2578 @end example
2579
2580  This probes the current configured geometry, and return it in
2581 the structure generic_floppy_struct (which must also be declared).
2582  Fd is an open file descriptor for the device, and buf is an already
2583 filled in stat structure, which may be useful.
2584  This routine should return 1 if the probing fails, and 0 otherwise.
2585
2586 @item
2587 Setting new parameters
2588 @example
2589 static inline int set_parameters(int fd, struct generic_floppy_struct *floppy)
2590                                  struct stat *buf)
2591 @end example
2592  This configures the geometry contained in floppy on the file descriptor
2593 fd. Buf is the result of a stat call (already filled in).  This should
2594 return 1 if the new geometry cannot be configured, and 0 otherwise.
2595 @end enumerate
2596
2597  A certain number of preprocessor macros should also be supplied:
2598
2599 @table @code
2600 @item TRACKS(floppy)
2601 refers to the track field in the floppy structure
2602 @item HEADS(floppy)
2603 refers to the heads field in the floppy structure
2604 @item SECTORS(floppy)
2605 refers to the sectors per track field in the floppy structure
2606 @item SECTORS_PER_DISK(floppy)
2607 refers to the sectors per disk field in the floppy structure (if
2608 applicable, otherwise leave undefined)
2609
2610 @item BLOCK_MAJOR
2611 major number of the floppy device, when viewed as a block device
2612
2613 @item CHAR_MAJOR
2614 major number of the floppy device, when viewed as a character device
2615 (a.k.a. "raw" device, used for fsck) (leave this undefined, if your OS
2616 doesn't have raw devices)
2617 @end table
2618
2619  For the truly high capacity formats (XDF, 2m, etc), there is no clean
2620 and documented interface yet.
2621
2622 @comment MANskip 1
2623
2624 @node Command Index, Variable Index,  Porting mtools, Top
2625 @unnumbered Command Index
2626 @printindex pg
2627
2628 @node Variable Index, Concept Index, Command Index, Top
2629 @unnumbered Variable index
2630 @printindex vr
2631
2632 @node Concept Index, , Variable Index, Top
2633 @unnumbered Concept index
2634 @printindex cp
2635
2636 @comment MANend-skip 1
2637 @comment MANend-skip 5
2638 @bye