xref: /netbsd/share/man/man4/mtio.4 (revision bf9ec67e)
1.\"	$NetBSD: mtio.4,v 1.14 2002/04/16 02:53:16 gmcgarry Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     from: @(#)mtio.4	8.1 (Berkeley) 6/5/93
35.\"
36.Dd January 14, 1999
37.Dt MTIO 4
38.Os
39.Sh NAME
40.Nm mtio
41.Nd generic magnetic tape I/O interface
42.Sh SYNOPSIS
43.Cd "#include \*[Lt]sys/ioctl.h\*[Gt]"
44.Cd "#include \*[Lt]sys/types.h\*[Gt]"
45.Cd "#include \*[Lt]sys/mtio.h\*[Gt]"
46.Sh DESCRIPTION
47Magnetic tape has been the computer system backup and data transfer
48medium of choice for decades, because it has historically been
49cheaper in cost per bit stored, and the formats have been designed
50for portability and storage.
51However, tape drives have generally been the slowest mass
52storage devices attached to any computer system.
53.Pp
54Magnetic tape comes in a wide variety of formats, from classic 9-track,
55through various Quarter Inch Cartridge
56.Pq Tn QIC
57variants, to more modern systems using 8mm video tape, and
58Digital Audio Tape
59.Pq Tn DAT .
60There have also been a variety of proprietary tape systems, including
61.Tn DECtape ,
62and
63.Tn "IBM 3480" .
64.Ss UNIX TAPE I/O
65Regardless of the specific characteristics of the particular tape
66transport mechanism (tape drive),
67.Ux
68tape I/O has two interfaces:
69.Qq block
70and
71.Qq raw .
72I/O through the block interface of a tape device is similar to I/O
73through the block special device for a disk driver: the individual
74.Xr read 2
75and
76.Xr write 2
77calls can be done in any amount of bytes, but all data is buffered
78through the system buffer cache, and I/O to the device is done in
791024 byte sized blocks.
80This limitation is sufficiently restrictive that the block interface
81to tape devices is rarely used.
82.Pp
83The
84.Qq raw
85interface differs in that all I/O can be done in arbitrary sized blocks,
86within the limitations for the specific device and device driver,
87and all I/O is synchronous.
88This is the most flexible interface, but since there is very little
89that is handled automatically by the kernel, user programs must
90implement specific magnetic tape handling routines, which puts the onus
91of correctness on the application programmer.
92.Ss DEVICE NAME CONVENTIONS
93Each magnetic tape subsystem has a couple of special devices
94associated with it.
95.Pp
96The block device is usually named for the driver, e.g.
97.Pa /dev/st0
98for unit zero of a
99.Xr st 4
100.Tn SCSI
101tape drive.
102.Pp
103The raw device name is the block device name with an
104.Qq r
105prepended, e.g.
106.Pa /dev/rst0 .
107.Pp
108By default, the tape driver will rewind the tape drive when the
109device is closed.
110To make it possible for multiple program invocations to
111sequentially write multiple files on the same tape, a
112.Qq no rewind on close
113device is provided, denoted by the letter
114.Qq n
115prepended to the name of the device, e.g.
116.Pa /dev/nst0 ,
117.Pa /dev/nrst0 .
118.Pp
119The
120.Xr mt 1
121command can be used to explicitly rewind, or otherwise position a
122tape at a particular point with the no-rewind device.
123.Ss FILE MARK HANDLING
124Two end-of-file (EOF) markers mark the end of a tape (EOT), and
125one end-of-file marker marks the end of a tape file.
126.Pp
127By default, the tape driver will write two End Of File (EOF) marks
128and rewind the tape when the device is closed after the last write.
129.Pp
130If the tape is not to be rewound it is positioned with the
131head in between the two tape marks, where the next write
132will over write the second end-of-file marker.
133.Pp
134All of the magnetic tape devices may be manipulated with the
135.Xr mt 1
136command.
137.Pp
138A number of
139.Xr ioctl 2
140operations are available on raw magnetic tape.
141Please see
142.Aq Pa sys/mtio.h
143for their definitions.
144.\" The following definitions are from
145.\" .Aq Pa sys/mtio.h :
146.\" .Bd  -literal
147.\" there was a copy of sys/mtio.h here. silly.
148.\" .Ed
149.Pp
150The manual pages for specific tape device drivers should list their
151particular capabilities and limitations.
152.Sh SEE ALSO
153.Xr dd 1 ,
154.Xr mt 1 ,
155.Xr pax 1 ,
156.Xr tar 1 ,
157.Xr st 4 ,
158.Xr wt 4
159.Sh HISTORY
160The
161.Nm
162manual appeared in
163.Bx 4.2 .
164.Sh BUGS
165The status should be returned in a device independent format.
166.Pp
167If and when
168.Nx
169is updated to deal with non-512 byte per sector disk media through the
170system buffer cache, perhaps a more sane tape interface can be
171implemented.
172