term% cat index.txt MT(4) Kernel Interfaces Manual MT(4)
NAME
mt - magtape interface
SYNOPSIS
#include <sys/mtio.h>
DESCRIPTION
The files mt∗ refer to magnetic tape drives. Filenames beginning with
mt are rewound when closed; those beginning with nmt are not. When a
file open for writing is closed, two end-of-files are written. If the
tape is not to be rewound, it is positioned with the head between the
two tapemarks.
The remainder of the filename is made up of the tape drive unit number,
and one of lmh indicating a density of 800, 1600, or 6250 bpi. Hence
mt0l is unit 0 at 800 bpi, mt2h is unit 2 at 6250.
A standard tape consists of a series of 1024 byte records terminated by
an end-of-file. To the extent possible, the system makes it possible,
if inefficient, to treat the tape like any other file. Seeks have
their usual meaning and it is possible to read or write a byte at a
time. Writing in very small units is inadvisable, however, because it
tends to create monstrous record gaps.
The mt files discussed above are useful when it is desired to access
the tape in a way compatible with ordinary files. When foreign tapes
are to be dealt with, and especially when long records are to be read
or written, the ‘raw' interface is appropriate. The associated files
have names beginning with rmt or nrmt.
Each read or write call reads or writes the next record on the tape.
In the write case the record has the same length as the buffer given.
During a read, the record size is passed back as the number of bytes
read, provided it is no greater than the buffer size; if the record is
long, an error is indicated. In raw tape I/O, the buffer must begin on
a word boundary and the count must be even. Seeks are ignored. A zero
byte count is returned when a tape mark is read, but another read will
fetch the first record of the new tape file.
Ioctl(2) calls perform special operations. The major operations are
MTIOCTOP do a mag tape operation from the following list, expressed
in the structure
struct mtop {
short mt_op; /* operation */
daddr_t mt_count; /* repeat count */
};
MTWEO write an end-of-file record
MTFS forward space file
MTBSF backward space file
MTFSR forward space record
MTBSR backward space record
MTREW rewind
MTOFFL rewind and put the drive offline
MTNOP no operation, sets status only
MTIOCGET get mag tape status; see <sys/mtio.h> for details
MTIOCIEOT ignore EOT error
MTIOCEEOT enable EOT error
FILES
/dev/mt?, /dev/rmt?
SEE ALSO
tape(1)
BUGS
If any non-data error is encountered, it refuses to do anything more
until closed.
In raw I/O, there should be a way to perform forward and backward
record and file spacing and to write an EOF mark.
Files with names like rmt2 may exist as well; their meaning is non-ob‐
vious, and their use is discouraged.
MT(4)