MT(7) — HP-UX
NAME
mt − magnetic tape interface and controls
DESCRIPTION
This page describes the behavior of HP magnetic tape interfaces and controls. The files /dev/mt/∗ and /dev/rmt/∗ refer to specific tape drives; the behavior of the specific unit is specified in the major and minor numbers of the device special file that describes the tape unit.
The following naming convention is recommended for tape devices because it connects most of the mode flags with the device name:
/dev/{r}mt/(c#d)#[hml]{n}
In this format, r indicates a raw device, c#d indicates the controller number (optionally specified by the system administrator), # is the device number, hml indicates the density (h (high) for 6250 bpi, m (medium) for 1600 bpi, and l (low) for 800 bpi), and n indicates no rewind on close. For example, /dev/rmt/2mn is raw device 2 at 1600 bpi with no rewind. Blocked magnetic tapes are used only for special situations and are supported only in some implementations. See DEPENDENCIES below for details. The selection of controller and unit numbers is system dependent, and is discussed in the appropriate system administrator’s manual.
The operation of a tape drive is controlled by mode flags, which are usually encoded as bits in the minor number of the device special file.
no-rewind Unless this mode is requested, the tape is automatically rewound upon close. When a rewind on close is not desired, the n flag should be used in the device name.
style When this mode is requested, the tape drive behaves as on Berkeley systems; when not requested, the drive behaves as on AT&T UNIX operating systems. The details are described below. The ioctl(2) operations described below work in both modes on raw tapes only. The mt(1) tape movement utility requires that the Berkeley mode be specified.
density This may be used to select the density of the tape being written. Values that may be selected include 6250, 1600, and 800 bpi, depending on the capabilities of the specific tape drive. This corresponds to the h, m and l flags in the recommended device name.
Refer to the system administrator manual for your computer for more specific details of how to select the modes for a given device.
The special files associated with a raw tape interface are named rmt/∗. Unless otherwise stated, the following discussion refers to raw magnetic tapes.
When opened for reading or writing, the tape is assumed to be positioned as desired.
When a file opened for writing is closed, two consecutive EOF marks are written if, and only if, one or more writes to the file have occurred. The tape is rewound unless the no-rewind mode has been specified, in which case the tape is positioned before the second EOF just written.
When a file open for reading only is closed and the no-rewind bit is not set, the tape is rewound. If the no-rewind bit is set, the behavior depends on the style mode. For AT&T-style devices, the tape is positioned after the EOF following the data just read. For Berkeley-style devices, the tape is not repositioned in any way.
Each read(2) or write(2) call reads or writes the next record on the tape. For writes, the record has the same length as the buffer given (within the limits of the hardware).
During a read, the record size is passed back as the number of bytes read, up to the buffer size specified. The number of bytes ignored (for records longer than the buffer size specified) is available in the mt_resid field of the mtget structure via the MTIOCGET call of ioctl(2). The buffer and size might have implementation-dependent alignment restrictions.
Reading an EOF mark is returned as a successful zero-length read; that is, the data count returned is zero and the tape is positioned after the EOF, enabling the next read to return the next record.
Seeks on a raw magnetic tape device are ignored. Instead, the ioctl(2) operations below can be used to position the tape and determine its status.
The following is included from <sys/mtio.h> and describes the possible operations:
/* mag tape I/O control requests */
| #define MTIOCTOP | _IOW(m,1,struct mtop) | /* do mag tape op */ |
| #define MTIOCGET | _IOR(m,2,struct mtget) | /* get tape status */ |
/* structure for MTIOCTOP - mag tape op request */
structmtop {
| short | mt_op; | /* operations defined below */ | ||
| daddr_t | mt_count; | /* how many of them */ |
};
/* operations */
| #define MTWEOF | 0 | /* write 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, put drive offline */ |
| #define MTNOP | 7 | /* no-op, may set status */ |
/* structure for MTIOCGET - mag tape get status command */
structmtget {
| long | mt_type; | ||
| long | mt_resid; |
/* The following two registers are device dependent */
| long | mt_dsreg1; | ||
| long | mt_dsreg2; |
/* The following is a device-independent status word */
| long | mt_gstat; | ||
| long | mt_erreg; |
/* The following are used only when block devices are supported */
| daddr_t | mt_fileno; | ||
| daddr_t | mt_blkno; |
};
/*
* Constants for mt_type; the first three are historical
*/
| #define MT_ISTS | 01 |
| #define MT_ISHT | 02 |
| #define MT_ISTM | 03 |
| #define MT_IS7970E | 04 |
| #define MT_ISSTREAM | 05 |
WARNINGS
It is impossible to write a program that leaves a tape positioned at the beginning on an AT&T−style raw device with the no-rewind bit set, because closing the device file upon the program’s termination repositions the tape after the first EOF mark.
DEPENDENCIES
Series 300
Block magnetic tape is not supported.
Series 800
The MTNOP operation does not set the device independent status word.
The files /dev/mt/∗ refer to block magnetic tapes. They should be used only for system installation or for treating a previously written magnetic tape as a read-only block file system. A read-only block tape should be created with dd(1) using raw mode and a record size of 512 bytes.
Although the size of records on a block tape is always 512 bytes, the block I/O system deals with block sizes as a multiple of DEV_BSIZE (defined in <sys/param.h>), with the tape driver making the translation. For this reason, if a user writes 512 bytes in block mode, the block I/O system attempts to read from the block tape prior to incorporating the new data and writing it to the tape. Since reading a blank tape or a tape of unknown format terminates in an error, it is advised that dd(1) be used to create the tape as described above, and that block magnetic tape be used only for seeking and reading. Alternatively, always write a byte count that is a multiple of BLKDEV_IOSIZE (defined in <sys/param.h>) bytes to avoid the hazards of a erroneous prior block read.
A tape treated as a block-special device consists of several 512-byte records terminated by an EOF.
The system enables a previously written block tape to be treated as an ordinary file, except that writing in the middle of a file truncates the file at that point. Seeks have their usual meaning and it is possible to read or write a byte at a time.
The efficient use of streaming tape drives with large internal buffers and immediate-reporting require the following end-of-tape procedures:
All writes near the EOT foil (which is not on the recording surface) complete without error if actually written to the tape. Once the tape drive determines that the foil has been passed, subsequent writes do not occur and an error message is returned.
Since some applications require that a trailer be written for multiple tape operations, a user request for magnetic tape status that reflects the EOT condition signals the driver to drop all write barriers. Caution must be exercised to keep the tape on the reel.
When reading near the end-of-tape, the user is not informed of the EOT foil marker. Instead, the typical double EOF marks or a pre-arranged trailer signals the logical end-of-tape.
The EOT description above applies in the default case when immediate-reporting mode is allowed by a value encoded in the minor number. When not permitted by the minor number, the EOT operation attempts to emulate compatibility-mode on other HP-UX machines. In this mode, the write encountering the EOT foil returns an error with the tape automatically backing up over that record. The read encountering the EOT foil returns an error.
Since magnetic tape drives vary in EOT sensing due to differences in the physical placement of sensors, any application (such as multiple tape cpio(1) backups) requiring that data be continued from the EOT area of one tape to another tape must be restricted. Therefore, the tape drive type and mode should be identical for the creation and reading of the tapes.
The following macros are defined in <sys/mtio.h> for decoding the generic status of the tape drive (returned in the mt_gstat field):
| GMT_EOF(x) | /* At an EOF mark */ |
| GMT_BOT(x) | /* At beginning of tape */ |
| GMT_EOT(x) | /* At end of tape */ |
| GMT_WR_PROT(x) | /* Tape is write protected */ |
| GMT_ONLINE(x) | /* Drive is online */ |
| GMT_D_6250(x) | /* Density is 6520 bpi */ |
| GMT_D_1600(x) | /* Density is 1600 bpi */ |
| GMT_D_800(x) | /* Density is 800 bpi */ |
| GMT_DR_OPEN(x) | /* Drive door is open */ |
| GMT_IM_REP_EN(x) | /* Immediate reporting mode enabled */ |
If GMT_IM_REP_EN(x) is true, the drive reports completion of each operation immediately after receiving it.
AUTHOR
Mt was developed by HP and the University of California, Berkeley.
FILES
/dev/mt/∗
/dev/rmt/∗
SEE ALSO
dd(1), mt(1), ioctl(2), ct(7).
Hewlett-Packard Company — May 11, 2021