Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

tar(1)

cy(7)

gt(7)

hsa(7)

mt(7)

NAME

mt − UNIX magtape interface

DESCRIPTION

Three notations are used in the format descriptions of device names. Braces {} are used to indicate an optional field. Brackets [] are used to indicate a non-optional field where the user has a few alternatives. Parentheses () are used to indicate a field (extra information that the system could run without) that the system administrator may choose to include in the naming conventions. 
 
The standard format for tape special file names is
 
    dev/{r}mt/#[himl]{[fs]}{n}
 
where

r indicates a raw device. Blocked is the default. 

mt indicates a magnetic tape device. 

# indicates the unit number. 

himl indicates the density. The h (high) specifies 6250 bpi, i (intermediate) specifies 3200 bpi, m (medium) specifies 1600 bpi, and l (low) specifies 800 bpi.  Higher density drives that are developed in the future will be represented by v (very high) and u (ultra). 

fs indicates fast or slow rotation speed.  Tape jobs may complete sooner if the slow speed interface is used, since moving at the slower speed may permit streaming (moving at the faster speed may require frequent repositioning). 

n indicates no rewind on close. The default is rewind. 

CX/UX supports several other names for its tape drives.  These names are provided for compatibility reasons only.  Future tape drivers will not support these names.  The files cy0s, ..., cy15s and cy0f, ..., cy15f refer to the UNIX magtape drives, which may be on the VERSABUS using the CYPHER tapemaster formatter cy(7). 

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, except in conditions noted in the gt(7) man page. 

Blocked Tape

A standard blocked 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 blocked 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. 

Raw Tape

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. 

Operations

Structures and definitions for mag tape io control commands

A number of other ioctl operations are available on raw magnetic tape.  The following definitions are from <sys/mtio.h>, <sys/cipher.h>, <sys/xymacro.h>, <sys/qt.h>, <sys/im.h> and <sys/gt.h>:

The structure for MTIOCTOP, the mag tape op command is called mtop.  The fields in mtop are:

       shortmt_op;/∗ operations defined below ∗/
       daddr_tmt_count;/∗ how many of them ∗/
 Operations:
 MTWEOFwrite an end-of-file record
MTFSFforward space file
MTBSFbackward space file
MTFSRforward space record
MTBSRbackward space record
MTREWrewind
MTOFFLrewind and put the drive offline
MTNOPno operation, sets status only
MTTEN Cartridge tape unit retension command
MTERA gt(7) - Erase tape
MTEND  gt(7) - Wind tape to End Of valid Data (EOD)
MTSETLUNModel TC4980 drives only - sets Logical Unit Number
 MTSETTYPEset drive type (configuration only)
 /∗ 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 ∗/
/∗ end device-dependent registers ∗/
shortmt_resid;/∗ residual count ∗/
/∗ the following two are only implemented for gt(7) drives ∗/
daddr_tmt_fileno;/∗ file number of current position ∗/
daddr_tmt_blkno;/∗ block number of current position ∗/
/∗ end gt(7) only drives ∗/
};
 /∗
 ∗ Constants for mt_type byte
 ∗
#define MT_ISCY0x08
#define MT_ISXYLOGICS0x09
#define MT_ISQT0x0a
#define MT_ISGT0x0b
 #define MT_CTLR_MASK0x00ff
#define MT_DRIVE_MASK0xff00
 /∗ 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 ∗/
 /∗ ====FOR GT(7) and HSA(7) CONTROLLER ONLY==== ∗/
/∗
 ∗ Constants for mt_erreg field on MTIOCGET.
 ∗/
 /∗
 ∗ gt(7) "status register" - used by mt(7) MTIOCGET
 ∗/
#define GT_STAT_ONLINE0/∗ Drive online∗/
#define GT_STAT_WRITE_PROT1 /∗ Write Protected∗/
#define GT_STAT_HIT_FM2/∗ Drive encountered a filemark∗/
#define GT_STAT_EOT3/∗ End Of Tape∗/
#define GT_STAT_NEED_FM4/∗ Filemark Needed∗/
#define GT_STAT_NEED_EOV5 /∗ End Of Volume mark Needed∗/
#define GT_STAT_NOT_LOADED6 /∗ Tape Not loaded∗/
#define GT_STAT_BOT7/∗ Beginning Of Tape∗/
#define GT_STAT_EOD8/∗ End of Valid Data∗/
 /∗
 ∗ hsa(7) interface module errors
 ∗/
#define IMERR_NO_ERROR0/∗ No error ∗/
#define IMERR_UNSUPPORTED_CMD1 /∗ Unsupported command ∗/
#define IMERR_DEV_NOT_FOUND2/∗ Device not found ∗/
#define IMERR_DEV_NOT_READY3/∗ Device not ready ∗/
#define IMERR_CTLR_TIMEOUT4/∗ Ctlr timed out ∗/
#define IMERR_DEV_TYPE_MISMATCH5 /∗ Device type mismatch ∗/
#define IMERR_INV_CMD6/∗ Invalid command ∗/
#define IMERR_XFER_TOO_LONG7/∗ Transfer too long ∗/
#define IMERR_BAD_XFER_SIZE8/∗ Bad transfer size ∗/
#define IMERR_ZERO_XFER_SIZE9/∗ Transfer size of zero rejected ∗/
#define IMERR_DRIVE_NOT_ONLINE10 /∗ Drive not on-line ∗/
#define IMERR_DRIVE_WRITE_PROTECT 11 /∗ Drive write protected ∗/
#define IMERR_FAULT12/∗ Bad user supplied buffer ∗/
#define IMERR_BLOCK_ADDR13/∗ Invalid block address ∗/
#define IMERR_DRIVE_NOT_READY14 /∗ Drive not ready ∗/
#define IMERR_DRIVE_SEEK_ERROR15 /∗ Drive seek error ∗/
#define IMERR_DRIVE_FAULT16/∗ Drive faulted ∗/
#define IMERR_MEDIUM_ERROR17/∗ Media error ∗/
#define IMERR_INV_MODEL18/∗ Invalid model number ∗/
#define IMERR_MAX_LOG_CYL19/∗ Max logical cylinder address
exceeded ∗/
#define IMERR_MAX_LOG_HEAD20/∗ Max logical head address
exceeded ∗/
#define IMERR_MAX_LOG_SECTOR21/∗ Max logical sector address
exceeded ∗/
#define IMERR_MAX_PHYS_CYL22/∗ Max physical cylinder address
exceeded ∗/
#define IMERR_MAX_PHYS_HEAD23/∗ Max physical head address
exceeded ∗/
#define IMERR_MAX_PHYS_SECTOR24 /∗ Max physical sector address
exceeded ∗/
#define IMERR_READ_ERROR25/∗ Read error ∗/
#define IMERR_NO_MEDIA26/∗ Media not installed ∗/
#define IMERR_FAILED_DIAGS27/∗ Diagnostic failed ∗/
#define IMERR_INTERNAL_ERROR28/∗ Internal error ∗/
#define IMERR_NO_CONFIG29/∗ Interface not configured ∗/
#define IMERR_TAPE_HIT_FM30/∗ Tape hit a filemark ∗/
#define IMERR_TAPE_EOT31/∗ Tape has reached EOT ∗/
#define IMERR_TAPE_NOT_AT_EOD32 /∗ Tape not at end valid data ∗/
#define IMERR_TAPE_AT_EOD33/∗ Tape at end of valid data ∗/
#define IMERR_TAPE_RECOVERED34/∗ Device recovered from error∗/
#define IMERR_TAPE_AT_BOT35/∗ Tape at beginning of tape ∗/
#define IMERR_MEDIA_CHANGED36/∗ Tape media may have changed since
last command ∗/
#define IMERR_DEVICE_BUSY37/∗ Device returned SCSI busy status ∗/
#define IMERR_BAD_ARG38/∗ Bad argument supplied ∗/
 #define IMERR_DEVICE_SPECIFIC39/∗ Device specific error ∗/
#define IMERR_IOCTL_EINVAL      40      /∗ Invalid ioctl() argument ∗/
#define IMERR_REQ_ALREADY_DONE  41      /∗ Request has already completed ∗/
#define IMERR_REQ_CANCELLED     42      /∗ Request cancelled before being sent
to device ∗/
#define IMERR_ERROR_LOST        43      /∗ Error lost due to error tables
already in use ∗/
#define IMERR_MAX_ERRORIMERR_ERROR_LOST
  /∗ ====END OF GT(7) and HSA(7) ONLY==== ∗/
/∗ ====FOR TAPEMASTER CONTROLLER ONLY==== ∗/
/∗
 ∗ Constants for mt_erreg field on MTIOCGET.
 ∗/
 #defineCS_P(0x0002<<8)/∗ Protected, no write ring ∗/
#defineCS_FB(0x0004<<8)/∗ formatter busy ∗/
#defineCS_RDY(0x0008<<8) /∗ drive ready ∗/
#defineCS_EOT(0x0010<<8) /∗ end of tape detected ∗/
#defineCS_LP(0x0020<<8)/∗ tape is at load point ∗/
#defineCS_OL(0x0040<<8)/∗ drive on_line ∗/
#defineCS_FM(0x0080<<8)/∗ Filemark detected ∗/
#defineCS_ERm(0x1F00>>8) /∗ Error value mask ∗/
#defineCS_CR(0x2000>>8)/∗ Controller executed retries ∗/
#defineCS_CC(0x4000>>8)/∗ Command Completed successfully ∗/
#defineCS_CE(0x8000>>8)/∗ Command execution has begun ∗/
  /∗ Error value definitions for erreg field on MTIOCGET. ∗/
#defineER_TIMOUT(0x01) /∗ timed out data busy false ∗/
#defineER_TIMOUT1(0x02) /∗ data busy false,formatter,ready ∗/
#defineER_TIMOUT2(0x03) /∗ time out ready busy false ∗/
#defineER_TIMOUT3(0x04) /∗ time out ready busy true ∗/
#defineER_TIMOUT4(0x05) /∗ time out data busy true ∗/
#defineER_NEX(0x06) /∗ time out memory ∗/
#defineER_BLANK(0X07) /∗ blank tape ∗/
#defineER_DIAG(0x08) /∗ micro-diagnostic ∗/
#defineER_EOT(0x09) /∗ EOT forward, BOT rev. ∗/
#defineER_HARD(0x0A) /∗ retry unsuccessful ∗/
#defineER_FIFO(0x0B) /∗ FIFO over/under flow ∗/
#defineER_PARITY(0x0D) /∗ drive to tapemaster parity error ∗/
#defineER_CHKSUM(0x0E) /∗ prom checksum ∗/
#defineER_STROBE(0x0F) /∗ time out tape strobe ∗/
#defineER_NOTRDY(0x10) /∗ tape not ready ∗/
#defineER_PROT(0x11) /∗ write, no enable ring ∗/
#defineER_JUMPER(0x13) /∗ missing diagnostic jumper ∗/
#defineER_LINK(0x14) /∗ bad link, link inappropriate ∗/
#defineER_FM(0x15) /∗ unexpected filemark ∗/
#defineER_PARAM(0x16) /∗ bad parameter, byte count ? ∗/
#defineER_HDWERR(0x18) /∗ unidentified hardware error ∗/
#defineER_NOSTRM(0x19) /∗ streaming terminated ∗/
 /∗ ====END OF TAPEMASTER ONLY==== ∗/
/∗ ====FOR XYLOGICS CONTROLLER ONLY==== ∗/
 /∗ ----CURRENT STATE (IOPB BYTE2) BITS---- ∗/
/∗ These bits are located in the upper word of the dsreg field on MTIOCGET. ∗/
#define STATE_WRITE_PROTECT0x1
#define STATE_HIT_EOT0x2
#define STATE_HIT_FM0x8
#define STATE_LONG_RECORD0x10
#define STATE_SHORT_RECORD0x20
#define STATE_CORRECTED_ERROR 0x40
#define STATE_HARD_TAPE_ERROR 0x80
 /∗ ----CURRENT STATE (IOPB BYTE3) BITS---- ∗/
/∗ These bits are located in the lower word of the dsreg field on MTIOCGET. ∗/
#define STATE_ONLINE0x1
#define STATE_READY0x2
#define STATE_ONLINEANDREADY0x3
#define STATE_FORMATTER_BUSY0x4
#define STATE_TRANSFERING0x8
#define STATE_REWINDING0x10
#define STATE_HIT_BOT0x20
#define STATE_HIGH_SPEED0x40
 /∗ ----ERRORS---- ∗/
/∗ These codes are located in the erreg field on MTIOCGET. ∗/
#define SUCCESS0x00
#define ILL_DENSITY_CHG0x10
#define ILL_PARM_COMBO0x11
#define BYTE_COUNT_ERROR0x12
#define COUNT_ZERO0x13
#define ILL_COMMAND0x14
#define ILL_SG_LENGTH0x1c
#define NEXT_IOPB_ALIGN_ERR0x1e
#define CORRECTED_DATA0x30
#define HARD_TAPE_ERROR0x40
#define EOT_DETECTED0x41
#define FM_WRITE_FAULT0x42
#define OPERATION_TIMEOUT0x43
#define DMAC_TIMEOUT0x44
#define TAPE_PAR_ERR0x45
#define BUFFER_PAR_ERR0x46
#define LONG_RECORD0x47
#define SHORT_RECORD0x48
#define DATA_LATE0x49
#define FATAL_DMAC_ERR0x4a
#define VME_BUS_ERR0x4b
#define DRIVE_FAULT0x60
#define DRIVE_NOT_READY0x61
#define FIRMWARE_FAILURE0x71
#define IRAM_CKSUM_ERR0x81
#define IOPB_ABORT_CMD0x82
#define IOPB_ABORT_ERR0x83
#define REEL_WRITE_PROTECTED0x90
#define DRIVE_OFF_LINE0x91
#define REVERSE_INTO_BOT0xa0
#define FM_ON_READ0xa1
#define XYTOOLARGE0xb0
#define XYNOTREADY0xb1
#define XYNOERROR0xb2
 /∗ ====END XYLOGICS ONLY==== ∗/
  /∗ === FOR SCSI CONTROLLER ONLY === ∗/
#define  SCSI_OK0x00/∗ OK status ∗/
#define  SCSI_CHECK0x01/∗ Check condition status ∗/
#define  SCSI_BUSY0x02/∗ BUSY status ∗/
#define  SCSI_INTER0x0a/∗ Intermediate status ∗/
#define  SCSI_CONFLICT0x0c/∗ Reservation conflict ∗/
#define  SCSI_O0x00/∗ OK status ∗/
#define  SCSI_CHECK0x01/∗ Check condition status ∗/
#define  SCSI_BUSY0x02/∗ BUSY status ∗/
#define  SCSI_INTER0x0a/∗ Intermediate status ∗/
#define  SCSI_CONFLICT0x0c/∗ Reservation conflict ∗/
 /∗ === END SCSI CONTROLLER === ∗/
 

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 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. 

End-Of-Tape Handling (on Xylogics and gt(7) only)

When EOT is encountered and the user is writing via an asynchronous (fast) interface, records already queued are permitted to be written past the EOT marker; however, no further writes are allowed.  When reading, double filemarks are used to indicate EOT; the physical EOT marker is ignored.  While this strategy permits asynchronous write mechanism to work properly at end-of-tape, the user must exercise caution:  By reading past filemarks, and ignoring their significance as logical end-of-tape markers, it is possible to run the tape entirely off the reel. 

FILES

/dev/mt/?, /dev/rmt/?

SEE ALSO

tar(1), cy(7), gt(7), hsa(7)

CX/UX Administrator’s Reference

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