Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mtio(4) — SunOS 4.0.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mt(1)

tar(1)

read(2V)

write(2V)

ar(4S)

st(4S)

tm(4S)

xt(4S)

MTIO(4)  —  DEVICES AND NETWORK INTERFACES

NAME

mtio − general magnetic tape interface

SYNOPSIS

#include <sys/ioctl.h>
#include <sys/mtio.h>

DESCRIPTION

Both 1/2” and 1/4” 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. 

A number of additional ioctl operations are available on “raw” devices.  The following definitions are from /usr/include/sys/mtio.h:

/∗
 ∗ Structures and definitions for mag tape io control commands
 ∗/
 /∗ structure for MTIOCTOP - mag tape op command ∗/
structmtop{
shortmt_op;   /∗ operations defined below ∗/
daddr_tmt_count;/∗ how many of them ∗/
};
 #defineMTWEOF0/∗ write an end-of-file record ∗/
#defineMTFSF1/∗ forward space file ∗/
#defineMTBSF2/∗ backward space file ∗/
#defineMTFSR3/∗ forward space record ∗/
#defineMTBSR4/∗ backward space record ∗/
#defineMTREW5/∗ rewind ∗/
#defineMTOFFL6/∗ rewind and put the drive offline ∗/
#defineMTNOP7/∗ no operation, sets status only ∗/
#defineMTRETEN8/∗ retension the tape ∗/
#defineMTERASE   9/∗ erase the entire tape ∗/
#defineMTEOM10/∗ position to end of media (SCSI only) ∗/
#defineMTBSFM11/∗ backward space file mark ∗/
 /∗ structure for MTIOCGET - mag tape get status command ∗/
structmtget {
shortmt_type;  /∗ type of magtape device ∗/
/∗ the following two registers are grossly device dependent ∗/
shortmt_dsreg;  /∗ “drive status” register ∗/
shortmt_erreg;  /∗ “error” register ∗/
/∗ optional error info. ∗/
daddr_tmt_resid;  /∗ residual count ∗/
daddr_tmt_fileno;  /∗ file number of current position ∗/
daddr_tmt_blkno;  /∗ block number of current position ∗/
};
 /∗
 ∗ Constants for mt_type byte
 ∗/
#defineMT_ISTS0x01/∗ vax: unibus ts-11 ∗/
#defineMT_ISHT0x02/∗ vax: massbus tu77, etc ∗/
#defineMT_ISTM0x03/∗ vax: unibus tm-11 ∗/
#defineMT_ISMT0x04/∗ vax: massbus tu78 ∗/
#defineMT_ISUT0x05/∗ vax: unibus gcr ∗/
#defineMT_ISCPC0x06/∗ sun: Multibus tapemaster ∗/
#defineMT_ISAR0x07/∗ sun: Multibus archive ∗/
#defineMT_ISSC0x08/∗ sun: SCSI archive ∗/
#defineMT_ISXY0x09/∗ sun: Xylogics 472 ∗/
 #defineMT_ISSYSGEN110x10/∗ sun: SCSI Sysgen, QIC-11 only ∗/
#defineMT_ISSYSGEN0x11/∗ sun: SCSI Sysgen QIC-24/11 ∗/
#defineMT_ISDEFAULT0x12/∗ sun: SCSI default CCS ∗/
#defineMT_ISCCS3  0x13/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISMT02  0x14/∗ sun: SCSI Emulex MT02 ∗/
#defineMT_ISVIPER10x15/∗ sun: SCSI Archive QIC-150 Viper ∗/
#defineMT_ISWANGTEK10x16/∗ sun: SCSI Wangtek QIC-150 ∗/
#defineMT_ISCCS7  0x17/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS8  0x18/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS9  0x19/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS110x1a/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS120x1b/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS130x1c/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS140x1d/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS150x1e/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS160x1f/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCDC  0x20/∗ sun: SCSI CDC 1/2” cartridge ∗/
#defineMT_ISFUJI 0x21/∗ sun: SCSI Fujitsu 1/2” cartridge ∗/
#defineMT_ISKENNEDY0x22/∗ sun: SCSI Kennedy 1/2” reel ∗/
#defineMT_ISHP   0x23/∗ sun: SCSI HP 1/2” reel ∗/
#defineMT_ISCCS210x24/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS220x25/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS230x26/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS240x27/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISEXABYTE0x28/∗ sun: SCSI Exabyte 8mm cartridge ∗/
#defineMT_ISCCS260x29/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS270x2a/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS280x2b/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS290x2c/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS300x2d/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS310x2e/∗ sun: SCSI generic (unknown) CCS ∗/
#defineMT_ISCCS320x2f/∗ 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 {
shortt_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",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_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 ∗/
#defineMTIOCTOP_IOW(m, 1, struct mtop)/∗ do a mag tape op ∗/
#defineMTIOCGET_IOR(m, 2, struct mtget)/∗ get tape status ∗/
#ifndefKERNEL
#defineDEFTAPE“/dev/rmt12”
#endif

SEE ALSO

mt(1), tar(1), read(2V), write(2V), ar(4S), st(4S), tm(4S), xt(4S)

BUGS

“Cooked” mode does not work for all magnetic tape devices (st, tm, and xt for example). 
 

Sun Release 4.0  —  Last change: 22 March 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026