MTIO(4)

NAME
mtio - UNIX magtape interface

DESCRIPTION
The files /dev/rct* conventionally refer to magtape drives, interfaced through the SCSI driver (see sd(4)). Files whose minor device number is odd are rewound when closed; the others are not. When a file open for writing is closed, a file mark is written. If the tape is not to be rewound, it is positioned with the head after the file mark.

The record size is fixed at 512 bytes on most cartridge tape controllers, although some tape drives may be more flexible. A standard tape then consists of a series of 512 byte records terminated by end-of-file (i.e. a filemark).

A number of ioctl(2) operations are available on raw magnetic tapes; the following definitions are from <sys/mtio.h>:

/*
 * Structures and definitions for mag tape io control commands
 */
/* structure for MTIOCTOP - mag tape op command */
struct  mtop    {
        short   mt_op;          /* operations defined below */
        daddr_t mt_count;       /* how many of them */
};
/* operations */
#define MTWEOF          0       /* write a file mark */
#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, sets status only */
#define MTCACHE         8       /* enable controller cache */
#define MTNOCACHE       9       /* disable controller cache */
/* structure for MTIOCGET - mag tape get status command */
struct  mtget   {
        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 */
/* end not yet implemented */
};
/*
 * Constants for mt_type byte.  These are the same
 * for other controllers compatible with the types listed.
 */
#define MT_ISTS         0x01   /* TS-11 */
#define MT_ISHT         0x02   /* TM03 Massbus: TE16, TU45, TU77 */
#define MT_ISTM         0x03   /* TM11/TE10 Unibus */
#define MT_ISMT         0x04   /* TM78/TU78 Massbus */
#define MT_ISUT         0x05   /* SI TU-45 emulation on Unibus */
#define MT_ISCPC        0x06   /* SUN */
#define MT_ISAR         0x07   /* SUN */
#define MT_ISTMSCP      0x08   /* DEC TMSCP protocol (TU81, TK50) */
#define MT_ISPSCT       0x09   /* Generic Acorn SCSI tape */
/* 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 */
#define MTIOCIEOT  _IO(m, 3)                 /* ignore EOT error */
#define MTIOCEEOT  _IO(m, 4)                 /* enable EOT error */
#ifndef KERNEL
#define DEFTAPE "/dev/rct4n"
#endif

For tape I/O each read or write call reads or writes a whole number of records on the tape (the size requested must be multiple of the tape record size), and I/O seeks are ignored. A zero byte count is returned and the tape stops when a file mark is seen, and a MTFSF operation is then required to move past the mark. A subsequent read will fetch the first record of the new tape file if there is one, or an error for end-of-medium.

FILES
/dev/rct*

SEE ALSO
mt(1), tar(1), sd(4)

BUGS
The status should be returned in a device independent format. Some of the ioctl(2) definitions in <sys/mtio.h> are not appropriate to the SCSI tape interface.