Technical data
SunOS 5.5 Ioctl Requests mtio(7I)
MTBSR and MTFSR operations perform much like space file operations, except that they
move by records instead of files. Variable-length I/O devices (1/2” reel, for example)
space actual records; fixed-length I/O devices space physical records (blocks). 1/4” car-
tridge tape, for example, spaces 512 byte physical records. The status ioctl residual count
contains the number of files or records not skipped.
MTOFFL rewinds and, if appropriate, takes the device off-line by unloadingthe tape. It is
recommended that the device be closed after offlining and then re-opened after a tape has
been inserted to facilitate portability to other platforms and other operating systems.
Attempting to re-open the device with no tape will result in an error unless the O_DELAY
flag is used. (See open(2).)
The MTRETEN retension ioctl applies only to 1/4” cartridge tape devices. It is used to
restore tape tension, improving the tape’s soft error rate after extensive start-stop opera-
tions or long-term storage.
MTERASE rewinds the tape, erases it completely, and returns to the beginning of tape.
MTEOM positions the tape at a location just after the last file written on the tape. For
1/4” cartridge and 8mm tape, this is after the last file mark on the tape. For 1/2” reel
tape, this is just after the first file mark but before the second (and last) file mark on the
tape. Additional files can then be appended onto the tape from that point.
Note the difference betweenMTBSF (backspace over file mark) and MTNBSF (backspace
file to beginning of file). The former moves the tape backward until it crosses an EOF
mark, leaving the tape positioned before the file mark. The latter leaves the tape posi-
tioned after the file mark. Hence, "MTNBSF n" is equivalent to "MTBSF (n+1)" followed by
"MTFSF 1". The 1/4 ” cartridge tape devices do not supportMTBSF.
MTSRSZ
and MTGRSZ are used to set and get fixed record lengths. TheMTSRSZ ioctl
allows variable length and fixed length tape drives that support multiple record sizes to
set the record length. The mt_count field of the mtop struct is used to pass the record
size to/from the st driver. A value of 0 indicates variable record size. TheMTSRSZ ioctl
makes a variable-lengthtape device behave likea fixed-length tape device. Refer to the
specific tape driver man page for details.
The MTIOCGET get status ioctl call returns the drive ID (mt_type), sense key error
(mt_erreg), file number (mt_fileno), optimum blocking factor (mt_bf) and record number
(mt_blkno) of the last error. The residual count (mt_resid) is set to the number of bytes not
transferred or files/records not spaced. The flags word (mt_flags) contains information
such as whether the device is SCSI, whether it is a reel device and whether the device
supports absolute file positioning.
MTLOAD loads the next tape cartridge into the tape drive. This is generally only used
with stacker and tower type tape drives which handle multiple tapes per tape drive. A
tape device without a tape inserted can be opened with theO_DELAY flag, in order to
execute this operation.
EXAMPLES Suppose you have written three files to the non-rewinding1/2” tape device,
/dev/rmt/0ln, and that you want to go back and dd(1M) the second file off the tape. The
commands to do this are:
modified 30 Aug 1995 7I-221










