MT(4,F) AIX Technical Reference MT(4,F) ------------------------------------------------------------------------------- mt PURPOSE Supports the IBM System/370 tape storage device driver. # include # include # include # include DESCRIPTION Magnetic tapes are used primarily for backups, file archives, and other off-line storage. System/370 tapes are accessed though the raw interface only. The particular magnetic tape interface used depends on the desired operating characteristics. The general form of the device name is /dev/rmt#xy, where: # is the device unit number x indicates rewind (r), no-rewind (n), or rewind-unload (u) after the last close of the device. (f) indicates FORWARD-SPACE-FILE on open/rewind of the device. y indicates the tape density, high (h) or medium (m). Hence, /dev/rmt0rh and /dev/rmt0rm refer to the same drive, but differ in the density written. The mt special file is unique to AIX/370. New devices /dev/rmt0wh and /dev/rmt1wh: These devices (3480 high-density) wait 40 seconds after winding the tape so that the next tape in the stacker can be loaded and ready. The only difference between /dev/rmt?uh and /dev/rmt?wh is that the latter waits 40 seconds before returning from the close() system call. The user process safely assumes that the stacker is loaded with the next tape if available on completion of close(). When opened for reading or writing, the tape is assumed to be positioned as desired. When the tape opens and writes to a tape 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, record size is returned as the number of bytes read, up to the buffer size Processed August 5, 1991 MT(4,F) 1 MT(4,F) AIX Technical Reference MT(4,F) 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, the following calls are defined: The STIOCTOP command issues a tape command to the appropriate device a specific number of times. The communication uses the stop structure: struct stop { short st_op; /* tape operation */ daddr_t st_count; /* times to perform */ }; The st_op operation is performed st_count times, except for commands where it is not logical to do so (rewind, for example). The operations available are: #define STWEOF 0 /* write an end-of-file record */ #define STFSF 1 /* forward space file */ #define STBSF 2 /* backward space file */ #define STFSB 3 /* Forward space block */ #define STBSB 4 /* Back space block */ #define STREW 5 /* Rewind */ #define STOFFL 6 /* Rewind and unload */ #define STNOP 7 /* NOP */ The status of a tape drive can be determined by issuing the MTIOCGET type ioctl system call. /* structure for MTIOCGET - mag tape get status command */ struct mtget { short mt_type; /* type of magtape device */ short mt_dsreg; /* "drive status" register */ short mt_erreg; /* "error" register */ u_short mt_resid; /* residual count */ daddr_t mt_fileno; /* file num current position */ daddr_t mt_blkno; /* block number current position */ }; /* * Constants for mt_type byte */ #define MT_ISTS 01 #define MT_ISHT 02 The mt_dsreg variable contains the upper 16 bits of the channel status word (CSW). If the unit check bit is not set in mt_dsreg, the mt_erreg variable will be 0. If the unit check bit (0x0200) is set in mt_dsreg, the mt_erreg variable will contain the first two bytes of sense information from the tape Processed August 5, 1991 MT(4,F) 2 MT(4,F) AIX Technical Reference MT(4,F) drive. This information can be different for different tape drive models. To find out what information is contained in these two bytes for your tape drive, see your tape drive documentation. For example, if you have an IBM 3410 or 3411 tape drive, see "IBM 3410/3411 Magnetic Tape Subsystems Component Description" (GA32-0022). If you have an IBM 3420 tape drive, see "IBM 3803 Model 2 IBM 3420 Models 4, 6 and 8 Magnetic Subsystems Description" (GA32-0021). If you have an IBM 3422 tape drive, see "IBM 3422 Magnetic Tape Subsystem Reference: Channel Commands, Sense Data, ERPs" (GA32-0089). The MTIOCLD command issues a tape "Load Display" command (for use by IBM 3480 tape drives). The structure passed to the MTIOCLD command is: struct ldcmd { char ld_func; /* Function code */ char ld_msg1mLDMAXMSGLNy; /* Message 1 */ char ld_msg2mLDMAXMSGLNy; /* Message 2 */ }; The message fields contain ASCII characters to be displayed as directed by the function code. Possible function codes are: LDMOTION (Default) Maintain the message in message fields 1 and 2 until the tape drive is in motion, or the message is updated. LDREMOVE Maintain the message in message field 1 until the tape cartridge is physically removed from the tape drive, or until the next unload/load cycle. LDLOAD Maintain the message in message field 1 until the drive is next loaded. LDNOOP Physically access a drive without changing the message display. This option can be used to test whether a control unit can physically communicate with a drive. LDALL Display the message in message field 1 until a tape cartridge is physically removed from the tape drive or until the drive is next loaded. Display the message in message field 2 until the drive is next loaded. LDSINGLE (Default) Only one of the two messages is displayed. The one which is displayed is determined by the LDHIGH and LDLOW flags. LDDOUBLE Both messages are displayed, alternating them on the message display. LDBLINK The single message blinks. LDNOBLINK (Default) The single message does not blink. LDLOW (Default) The message in only message field 1 is displayed. Processed August 5, 1991 MT(4,F) 3 MT(4,F) AIX Technical Reference MT(4,F) LDHIGH The message in only message field 2 is displayed (8, 9, 10, and 11 are used with LDSINGLE). LDAUTOLD An automatic load request is passed from the system to the automatic load controller. LDNOAUTOLD (Default) No automatic load request is passed. If an STIOCLD ioctl is to be issued and there is no tape ready in the drive, use the O_NDELAY flag in the OPEN call. This will cause the device driver to bypass checking for drive ready, and allow only IOCTLs through the file descriptor. ERROR CONDITIONS In addition to the errors listed in the "ioctlx, ioctl, gtty, stty," "open, openx, creat," "read, readv, readx," and "write, writex," system calls to this device can fail in the following circumstances: ENXIO The tape device is not configured. ENXIO The tape is not attached to the virtual machine. ENXIO The tape is not loaded. ENXIO The tape is write-protected when trying to write. EINVAL The count is more than the architecture imposed maximum, or a read or write on a device open with O_NDELAY was attempted. EIO The I/O to the tape failed during the operation. RELATED INFORMATION In this book: "ioctlx, ioctl, gtty, stty," "open, openx, creat," "read, readv, readx," "write, writex," and "tape." See "backup" in the AIX Commands Reference. See "Hardware Requirements" in the AIX/370 Planning Guide. Processed August 5, 1991 MT(4,F) 4