TAPE(4,F) AIX Technical Reference TAPE(4,F)
-------------------------------------------------------------------------------
tape
PURPOSE
Supports the AIX PS/2 sequential access bulk storage medium device driver.
DESCRIPTION
Magnetic tapes are used primarily for backups, file archives, and other
off-line storage. Tapes are accessed through the special files mt0 and rmt0,
which are unique to AIX PS/2. The r indicates "raw" which means access through
the character special interface. Although streaming tape does not lend itself
well to the category of a block device, a block device interface is provided to
buffer I/O through the system buffer cache. This provides improved throughput
when doing only sequential writes or only sequential reads, as in
backup/restore. The number following the mt or rmt is the minor device number.
The two low-order bits of the minor device number select the transport. If the
third bit (04 octal or 0x04) is set, the driver does not rewind the tape after
it is closed. If the fourth bit (010 octal or 0x08) is set, the tape is
retensioned (wound completely forward and then rewound) after it is opened and
before any other operations.
On a system with a single tape drive, /dev/rmt0 does not retension the tape,
but does rewind it on close. /dev/rmt4 (bits = 0100) does not perform any
special actions on open or close. /dev/rmt8 (bits = 1000) retensions the tape
and rewinds it on close; and /dev/rmt12 (bits = 1100) retensions the tape on
open, but does not rewind.
When opened for reading or writing, the tape is assumed to be positioned as
desired. When the tape opens and writes to a file, a single tape mark is
written if the file is no rewind on close, while a double tape mark is written
if the tape is to be rewound. If the file is no rewind and opened read only,
the tape is positioned after the end of file (EOF) following the data just
read. Once opened, reading is restricted to between the position when opened
and the next EOF. By specifically choosing rmt files, it is possible to read
and write multiple-file tapes.
Each read or write call reads or writes the next record on the tape. The
record written by write is the same length as the buffer given. During a read,
the record size is returned as the number of bytes read, up to the buffer size
specified. Seeks are ignored. An EOF is returned as a zero-length read, with
the tape positioned before the EOF.
A number of ioctl operations are available. In addition to IOCTYPE and IOCINFO
types, the following ioctl calls are defined.
The parameter to the ioctl system call using the STIOCTOP command is the
address of a stop structure, which contains the following members:
Processed November 7, 1990 TAPE(4,F) 1
TAPE(4,F) AIX Technical Reference TAPE(4,F)
short st_op; /* Streaming tape operation */
daddr_t st_count; /* Number of times to perform */
The st_op operation is performed st_count times, except where it is not logical
to do so, rewind, as an example. The operations available are:
#define STRESET 5 /* reset device */
#define STREW 6 /* rewind */
#define STERASE 7 /* erase tape, retension, leave at load point */
#define STRETEN 8 /* erase tape, retension, leave at load point */
#define STWEOF 10 /* write an end-of-file record */
#define STFSF 11 /* forward space file */
#define STFSR 13 /* forward space record */
#define STRAS1 15 /* drive self test 1 */
#define STRAS2 16 /* drive self test 2 */
#define STRAS3 17 /* drive self test 3 */
/* this test needs an */
/* erased write-protected tape */
The status of a tape drive can be determined by issuing the following STIOCGET
type ioctl system call:
/* structure for STIOCGET - streaming tape get status command */
struct stget {
short st_type; /* type of device */
struct dsreg {
unsigned short ds_dstat: /* drive status */
unsigned short ds_soft; /* soft error count */
unsigned short ds_under; /* underrun count */
unsigned char ds_rcom; /* command received by adapter */
unsigned char ds_blk; /* adapter block count */
unsigned char ds_rstat; /* status register */
unsigned char ds_code; /* adapter completion code */
unsigned char ds_lcom; /* last command given to adapter */
unsigned char ds_lstcom; /* last streaming tape device */
/* drive command */
unsigned char ds_res[4] /* reserved */
} st_dsreg;
};
/*
* Constants for st_type byte - ST_SST streaming tape
*/
In addition to those errors listed in ioctl; open, read, and write, system
calls against this device fail in the following circumstances:
EINVAL O_APPEND is supplied as a mode in which to open.
EINVAL A write attempt while the tape is in read mode, or a read attempt while
the tape is in write mode.
Processed November 7, 1990 TAPE(4,F) 2
TAPE(4,F) AIX Technical Reference TAPE(4,F)
EINVAL A count parameter to read or write is not 0, module 512.
EIO A parameter to ioctl is not allowed in the current streaming mode.
ENXIO The tape is write-protected or there is no tape in the drive.
Note: The streaming tape device driver has a concept of current "streaming
mode". Therefore, many operations are invalid most of the time. In
particular, no reads are allowed after an initial write or writes
allowed after an initial read. You must wait until the device is reset
either by closing a rewind-on-close special file, or by the tctl
command.
FILE
/dev/rmt*
RELATED INFORMATION
In this book: "ioctlx, ioctl, gtty, stty," "open, openx, creat," "read,
readv, readx," "write, writex," and "mt."
The tctl command in AIX Operating System Commands Reference.
Processed November 7, 1990 TAPE(4,F) 3