mtio(4)
NAME
mtio − UNIX magtape interface
DESCRIPTION
The UNIX magtape drives may be on the MASSBUS, using the TM03 formatter ht(4), on the UNIBUS, using either the TM11 or TS11 formatter, tm(4) or ts(4). The following description applies to any of the transport/controller pairs. The files /dev/mt? are 800bpi; /dev/ht? are 1600bpi; /dev/gt? are 6250bpi. The file /dev/tk? is for TMSCP.
The files /dev/ht?, /dev/tk?, /dev/tm?, and /dev/gt? are normally rewound when closed, files beginning with the ’n’ prefix are not rewound when closed (for example, /dev/nrht0). 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.
A standard 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 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.
The 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. The associated files are named /dev/rht?, /dev/rtk?, /dev/rmt?, and /dev/rgt?, but the same minor-device considerations as for the regular files still apply. A number of other ioctl operations are available on raw magnetic tape. The following definitions are from < 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 */
};
/* 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 MTCACHE 010 /* write cache */
#define MTNOCACHE 011 /* no write cache */
#define MTCSE 012 /* clear serious exception */
#define MTCLX 013 /* clear hardware/software problem */
#define MTCLS 014 /* clear subsystem */
#define MTASYNC 015 /* enable default async buffering */
#define MTNOASYNC 016 /* disable async buffering */
#define MTENAEOT 017 /* enable default EOT driver code */
#define MTDISEOT 020 /* disable EOT driver code */
/* structure for MTIOCGET - mag tape get status command */
structmtget{
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 */
/* end device-dependent registers */
short mt_resid; /* residual count */
/* the following two are not yet implemented */
daddr_t mt_fileno; /* file number of current position */
daddr_t mt_blkno; /* block number of current position */
short mt_softstat /* status */
/* end not yet implemented */
};
/* Status for mt_softstat
*
*/
#define MT_EOT 01 /* EOT encountered */
#define MT_DISEOT 02 /* EOT handling is disabled */
#define MT_CACHE 04 /* Caching is enabled */
/*
* Constants for mt_type byte
*/
#define MT_ISTS 1
#define MT_ISHT 2
#define MT_ISTM 3
#define MT_ISMT 4
#define MT_ISUT 5
#define MT_ISTK 6 .
/* mag tape io control commands */
#define MTIOCTOP ((’m’<<8)|1) /* do a mag tape op */
#define MTIOCGET ((’m’<<8)|2) /* get tape status */
#ifndef KERNEL
#defineDEFTAPE"/dev/nrht0"
#endif
To issue these Magtape calls, use the ioctl calls:
ioctl(fd, MTIOCOP, arg);
ioctl(fd, MTIOGET, arg);
Where, fd is a tape open file descriptor, the second argument specifies the operation type, and arg is a structure pointer to either an mtop or an mtget structure.
RESTRICTIONS
Do not issue MTCLS operation on any controller that has a drive on it is still running. MTCLS will reinitialize both controller and unit.
MTCLX operation is not available for those magtape drive on tm(4).
CACHE and NOCACHE are to be issued at the beginning of the tape.
ENAEOT, DISEOT, CACHE, and NOCACHE are set globally per unit which means when set they will stay in that mode until reset.
MTCSE operation will be clear when tape is no longer at or beyond the EOT.
FILES
/dev/mt?
/dev/rmt?
/dev/nrmt?
/dev/ht?
/dev/rht?
/dev/nrht?
/dev/gt?
/dev/rgt?
/dev/nrgt?
/dev/tk?
/dev/rtk?
/dev/nrtk?