HP-UX Reference (11i v2 04/09) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

m
mt(7) mt(7)
#define MTRES 14 /* Reserve Device */
#define MTREL 15 /* Release Device */
#define MTERASE 16 /* Erase media */
/* structure for MTIOCGET - mag tape get status command */
struct mtget {
long mt_type; /* type of magtape device */
long mt_resid; /* residual count */
/* The following two registers are device dependent */
long mt_dsreg1; /* status register (msb) */
long mt_dsreg2; /* status register (lsb) */
/* The following are device-independent status words */
long mt_gstat; /* generic status */
long mt_erreg; /* error register */
int32_t mt_fileno; /* No longer used - always set to -1 */
int32_t mt_blkno; /* No longer used - always set to -1 */
Information for decoding the mt_type field can be found in
<sys/mtio.h>.
Other Tape Status Characteristics
Efficient use of streaming tape drives with large internal buffers and immediate-reporting require the fol-
lowing end-of-tape procedures:
All writes near LEOT (Logical End of Tape) complete without error if actually written to the tape.
Once the tape driver determines that LEOT has been passed, subsequent writes do not occur and an
error message is returned.
To write beyond this point (keep in mind that streaming drives have already written well past
LEOT), simply ask for status using the
MTIOCGET ioctl. If status reflects the EOT condition, the
driver drops all write barriers. For reel-to-reel devices, caution must be exercised to keep the tape
on the reel.
When immediate-reporting is enabled, the
tape2 driver will drop out of immediate mode and flush the
device buffer with every write filemark or write setmark. The stape driver will flush the device buffers
when a write filemark or write setmark command is given with the count set to zero.
When immediate-reporting is disabled, the write encountering LEOT returns an error with the tape
driver automatically backing up over that record.
When reading near the end-of-tape, the user is not informed of LEOT. Instead, the typical double EOF
marks or a pre-arranged data pattern signals the logical end-of-tape.
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 status field mt_gstat returned from
MTIOCGET.
For each macro, the input parameter x is the mt_gstat field.
GMT_BOT(x) Returns TRUE at beginning of tape.
GMT_EOD(x) Returns TRUE if End-of-Data is encountered for DDS, QIC or
8MM.
GMT_EOF(x) Returns TRUE at an End-of-File mark.
GMT_EOT(x) Returns TRUE at end of tape.
GMT_IM_REP_EN(x) Returns TRUE if immediate reporting mode is enabled.
GMT_ONLINE(x) Returns TRUE if drive is on line.
GMT_SM(x) Returns TRUE if setmark is encountered.
GMT_WR_PROT(x) Returns TRUE if tape is write protected.
HP-UX 11i Version 2: September 2004 4 Hewlett-Packard Company Section 781