MTIO(4) — DEVICES AND NETWORK INTERFACES
NAME
mtio − general magnetic tape interface
SYNOPSIS
#include <sys/ioctl.h>
#include <sys/mtio.h>
DESCRIPTION
All magnetic tape drives share the same general interface regardless of the hardware involved. The remainder of this section discusses the common features of that interface.
The “cooked” magnetic tape device files read and write magnetic tape in 2048 byte blocks (the 2048 is actually BLKDEV_IOSIZE in /usr/include/sys/param.h). The name of such a device file might be /dev/mt0. The final component of the device name is the type of device the file refers to, and the unit number of that device.
These files are rewound when closed, except for “no-rewind” versions. The names of no-rewind device files use the letter n as the beginning of the final component. The no-rewind version of /dev/mt0 would be /dev/nmt0. When a 1/2” tape file, opened for writing or just written, is closed, two tape marks are written. If the tape is not to be rewound, it is positioned with the head between the two tapemarks.
The files discussed above are useful for making taped files consistent with ordinary files. This interface requires that all blocks be 2048 bytes long, and does not permit special operations (such as spacing the tape forward or backward) to be performed. The “raw” interface is appropriate when reading or writing long records or using foreign tapes. Raw device files are indicated by the letter r before the device type in the device name: the raw version of /dev/mt0 would be /dev/rmt0, and the raw version of /dev/nmt0 would be /dev/nrmt0.
read(2V) or write(2V) calls read or write the next record on the tape. When the call is to write, the record has the same length as the given buffer. During a read call, the record size is passed back as the number of bytes read, provided it is no greater than the buffer size. In raw tape I/O, seeks are ignored (except st). When a tape mark is read, a zero byte count is returned; another read will fetch the first record of the next tape file. Two successive reads returning zero byte counts indicate the end of recorded media.
1/2” Reel Tape
Data bytes are recorded in parallel onto the 9−track tape. The number of bytes in a physical record varies between 1 to 65535 bytes. Files end with one file mark except for the last, which signals the end of recorded media with two file marks. Care should be taken when overwriting records; the erase head is just forward of the write head and any following records will also be erased.
The recording formats available (check specific tape drive) are 800 BPI, 1600 BPI, and 6250 BPI, and data compression. Actual storage capacity is a function of the recording format and the length of the tape reel. For example, using a 2400 foot tape, 20 MB can be stored using 800 BPI, 40 MB using 1600 BPI, 140 MB using 6250 BPI, or up to 700 MB using data compression.
1/4” Cartridge Tape
Data is recorded serially onto 1/4−inch cartridge tape. The number of bytes per record is determined by the physical record size of the device. The I/O request size must be a multiple of the physical record size of the device. For QIC−11, QIC−24, and QIC−150 tape drives the block size is 512 bytes.
The records are recorded on tracks in a serpentine motion. As one track is completed, the drive switches to the next and begins writing in the opposite direction, eliminating the wasted motion of rewinding. Each file, including the last, ends with one file mark.
Files may be written only at the beginning of the tape or after the last written file. This prevents corrupting data by overwriting files.
Storage capacity is based on the number of tracks the drive is capable of recording. For example, 4−track drives can only record 20 MB of data on a 450 foot tape; 9−track drives can record up to 45 MB of data on a tape of the same length.. QIC−11 is the only tape format available for 4−track tape drives. In contrast, 9−track tape drives can use either QIC−24 or QIC−11. Storage capacity is not appreciably affected by using either format. QIC−24 is preferable to QIC−11 because it records a reference signal to mark the position of the first track on the tape, and each block has a unique block number.
The QIC−150 tape drives require DC−6150 (or equivalent) tape cartridges for writing. However, they can read other tape cartridges in QIC−11, QIC−24, QIC−120, or QIC−150 tape formats.
8 mm ” Cartridge Tape
Data is recorded serially onto 8 mm helical scan cartridge tape. The number of bytes in a physical record varies between 1 and 65535 bytes. Each file, including the last, ends with one file mark. Currently one density is available.
A number of additional ioctl operations are available on “raw” devices. The following definitions are from /usr/include/sys/mtio.h:
/∗
∗ Copyright 1988 Solbourne Computer, Inc.
∗ All rights reserved.
∗/
/∗ @(#)mtio.h 2.11 89/02/13 SMI; from UCB 4.10 83/01/17 ∗/
/∗
∗ Structures and definitions for mag tape io control commands
∗/
/∗ structure for MTIOCTOP - mag tape op command ∗/
struct mtop {
short mt_op; /∗ operations defined below ∗/
daddr_t mt_count; /∗ how many of them ∗/
};
/∗ operations ∗/
#define MTWEOF 0 /∗ write an end-of-file record ∗/
#define MTFSF 1 /∗ forward space file ∗/
#define MTBSF 2 /∗ backward space file ∗/
#define MTFSR 3 /∗ forward space record ∗/
#define MTBSR 4 /∗ backward space record ∗/
#define MTREW 5 /∗ rewind ∗/
#define MTOFFL 6 /∗ rewind and put the drive offline ∗/
#define MTNOP 7 /∗ no operation, sets status only ∗/
#define MTRETEN 8 /∗ retension the tape ∗/
#define MTERASE 9 /∗ erase the entire tape ∗/
#define MTEOM 10 /∗ position to end of media (SCSI only) ∗/
#define MTBSFM 11 /∗ backspace filemark ∗/
/∗ structure for MTIOCGET - mag tape get status command ∗/
struct mtget {
short mt_type; /∗ type of magtape device ∗/
/∗ the following two registers are grossly device dependent ∗/
short mt_dsreg; /∗ “drive status” register ∗/
short mt_erreg; /∗ “error” register ∗/
/∗ optional error info. ∗/
daddr_t mt_resid; /∗ residual count ∗/
daddr_t mt_fileno; /∗ file number of current position ∗/
daddr_t mt_blkno; /∗ block number of current position ∗/
};
/∗
∗ Constants for mt_type byte
∗/
#define MT_ISTS 0x01 /∗ vax: unibus ts-11 ∗/
#define MT_ISHT 0x02 /∗ vax: massbus tu77, etc ∗/
#define MT_ISTM 0x03 /∗ vax: unibus tm-11 ∗/
#define MT_ISMT 0x04 /∗ vax: massbus tu78 ∗/
#define MT_ISUT 0x05 /∗ vax: unibus gcr ∗/
#define MT_ISCPC 0x06 /∗ sun: multibus cpc ∗/
#define MT_ISAR 0x07 /∗ sun: multibus archive ∗/
#define MT_ISSC 0x08 /∗ sun: SCSI archive ∗/
#define MT_ISXY 0x09 /∗ sun: Xylogics 472/772 ∗/
#define MT_ISSYSGEN11 0x10 /∗ sun: SCSI Sysgen, QIC-11 only ∗/
#define MT_ISSYSGEN 0x11 /∗ sun: SCSI Sysgen QIC-24/11 ∗/
#define MT_ISDEFAULT 0x12 /∗ sun: SCSI default CCS ∗/
#define MT_ISCCS3 0x13 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISMT02 0x14 /∗ sun: SCSI Emulex MT02 ∗/
#define MT_ISVIPER1 0x15 /∗ sun: SCSI Archive QIC-150 Viper ∗/
#define MT_ISWANGTEK1 0x16 /∗ sun: SCSI Wangtek QIC-150 ∗/
#define MT_ISCCS7 0x17 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS8 0x18 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS9 0x19 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS11 0x1a /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS12 0x1b /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS13 0x1c /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS14 0x1d /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS15 0x1e /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS16 0x1f /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISVIPER2 0x1f /∗ sun: SCSI Archive Viper60 Q11/Q24 ∗/
#define MT_ISCDC 0x20 /∗ sun: SCSI CDC 1/2" cartridge ∗/
#define MT_ISFUJI 0x21 /∗ sun: SCSI Fujitsu 1/2" cartridge ∗/
#define MT_ISKENNEDY 0x22 /∗ sun: SCSI Kennedy 1/2" reel ∗/
#define MT_ISHP 0x23 /∗ sun: SCSI HP 1/2" reel ∗/
#define MT_ISCCS21 0x24 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS22 0x25 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS23 0x26 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS24 0x27 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISEXABYTE 0x28 /∗ sun: SCSI Exabyte 8mm cartridge ∗/
#define MT_ISCCS26 0x29 /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS27 0x2a /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS28 0x2b /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS29 0x2c /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS30 0x2d /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS31 0x2e /∗ sun: SCSI generic (unknown) CCS ∗/
#define MT_ISCCS32 0x2f /∗ sun: SCSI generic (unknown) CCS ∗/
/∗
∗ Device table structure and data for looking tape name from
∗ tape id number. Used by mt.c.
∗/
struct mt_tape_info {
short t_type; /∗ type of magtape device ∗/
char ∗t_name; /∗ printing name ∗/
char ∗t_dsbits; /∗ "drive status" register ∗/
char ∗t_erbits; /∗ "error" register ∗/
};
#define MT_TAPE_INFO {\
{ MT_ISCPC, "TapeMaster", TMS_BITS, 0 }, \
{ MT_ISXY, "Xylogics 472/772", XTS_BITS, 0 }, \
{ MT_ISAR, "Archive", ARCH_CTRL_BITS, ARCH_BITS }, \
{ MT_ISSYSGEN11, "Sysgen QIC-11", 0, 0 }, \
{ MT_ISSYSGEN, "Sysgen", 0, 0 }, \
{ MT_ISMT02, "Emulex MT-02", 0, 0 }, \
{ MT_ISVIPER1, "Archive QIC-150", 0, 0 }, \
{ MT_ISVIPER2, "Archive QIC-11/24", 0, 0 }, \
{ MT_ISWANGTEK1, "Wangtek QIC-150", 0, 0 }, \
{ MT_ISCDC, "CDC", 0, 0 }, \
{ MT_ISKENNEDY, "Kennedy", 0, 0 }, \
{ MT_ISHP, "HP-88780", 0, 0 }, \
{ MT_ISEXABYTE, "Exabyte", 0, 0 }, \
{ 0 } \
}
/∗
∗ Constants for mt_type byte
∗/
/∗
∗ Check if mt_type is one of the SCSI tape devices.
∗/
#define MT_TYPE_SCSI(mt_type) \
((mt_type >= MT_ISSYSGEN11) && (mt_type <= MT_ISCCS32))
/∗
∗ Older 1/4-inch cartridge tapes devices.
∗ A blocking factor of 126 is recommended for compatibility.
∗ A larger blocking factor may be used for improved streaming
∗ performance.
∗/
#define MT_TYPE_OLD_CARTRIDGE(mt_type) \
((mt_type == MT_ISSYSGEN11) || (mt_type == MT_ISSYSGEN) || \
(mt_type == MT_ISAR))
/∗
∗ Current 1/4-inch cartridge tape devices.
∗ A blocking factor of 40 (to 60) is recommended for
∗ optimal streaming performance.
∗/
#define MT_TYPE_NEW_CARTRIDGE(mt_type) \
(mt_type >= MT_ISDEFAULT && mt_type <= MT_ISCCS16)
/∗
∗ All 1/4-inch cartridge tape devices.
∗ A blocking factor of 126 is recommended for compatibility
∗ (during writes). See above for specific recommendations for
∗ reading.
∗/
#define MT_TYPE_CARTRIDGE(mt_type) \
((mt_type >= MT_ISSYSGEN11 && mt_type <= MT_ISCCS16) || \
(mt_type == MT_ISAR))
/∗
∗ All 1/2-inch reel tape devices.
∗ A blocking factor of 20 is recommended for compatibility.
∗/
#define MT_TYPE_REEL(mt_type) \
((mt_type >= MT_ISCDC && mt_type <= MT_ISCCS32) || \
(mt_type >= MT_ISTS && mt_type <= MT_ISCPC) || \
(mt_type == MT_ISXY))
/∗ mag tape io control commands ∗/
#define MTIOCTOP _IOW(m, 1, struct mtop) /∗ do a mag tape op ∗/
#define MTIOCGET _IOR(m, 2, struct mtget) /∗ get tape status ∗/
#ifndef KERNEL
#define DEFTAPE "/dev/rmt12"
#endif
SEE ALSO
mt(1), tar(1), read(2V), write(2V), st(4S)
Solbourne Computer, Inc. — 11 Jan 1994