Initial import from FreeBSD RELENG_4:
[dragonfly.git] / share / man / man4 / sa.4
1 .\" Copyright (c) 1996
2 .\"     Julian Elischer <julian@FreeBSD.org>.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\"
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/share/man/man4/sa.4,v 1.22.2.7 2001/08/17 13:08:39 ru Exp $
27 .\"
28 .Dd June 6, 1999
29 .Dt SA 4
30 .Os
31 .Sh NAME
32 .Nm sa
33 .Nd SCSI Sequential Access device driver
34 .Sh SYNOPSIS
35 .Cd device sa
36 .Cd device sa1 at scbus0 target 4 unit 0
37 .Sh DESCRIPTION
38 The
39 .Nm
40 driver provides support for all
41 .Tn SCSI
42 devices of the sequential access class that are attached to the system
43 through a supported
44 .Tn SCSI
45 Host Adapter.
46 The sequential access class includes tape and other linear access devices.
47 .Pp
48 A
49 .Tn SCSI
50 Host
51 adapter must also be separately configured into the system
52 before a
53 .Tn SCSI
54 sequential access device can be configured.
55 .Sh MOUNT SESSIONS
56 The
57 .Nm
58 driver is based around the concept of a
59 .Dq Em mount session ,
60 which is defined as the period between the time that a tape is
61 mounted, and the time when it is unmounted.  Any parameters set during
62 a mount session remain in effect for the remainder of the session or
63 until replaced.
64 The tape can be unmounted, bringing the session to a
65 close in several ways.  These include:
66 .Bl -enum
67 .It
68 Closing a `rewind device',
69 referred to as sub-mode 00 below.
70 An example is
71 .Pa /dev/sa0 .
72 .It
73 Using the MTOFFL
74 .Xr ioctl 2
75 command, reachable through the
76 .Sq Cm offline
77 command of
78 .Xr mt 1 .
79 .El
80 .Pp
81 It should be noted that tape devices are exclusive open devices, except in
82 the case where a control mode device is opened.
83 In the latter case, exclusive
84 access is only sought when needed (e.g., to set parameters).
85 .Sh SUB-MODES
86 Bits 0 and 1 of the minor number are interpreted as
87 .Sq sub-modes .
88 The sub-modes differ in the action taken when the device is closed:
89 .Bl -tag -width XXXX
90 .It 00
91 A close will rewind the device; if the tape has been
92 written, then a file mark will be written before the rewind is requested.
93 The device is unmounted.
94 .It 01
95 A close will leave the tape mounted.
96 If the tape was written to, a file mark will be written.
97 No other head positioning takes place.
98 Any further reads or writes will occur directly after the
99 last read, or the written file mark.
100 .It 10
101 A close will rewind the device.
102 If the tape has been
103 written, then a file mark will be written before the rewind is requested.
104 On completion of the rewind an unload command will be issued.
105 The device is unmounted.
106 .El
107 .Sh BLOCKING MODES
108 .Tn SCSI
109 tapes may run in either
110 .Sq Em variable
111 or
112 .Sq Em fixed
113 block-size modes.  Most
114 .Tn QIC Ns -type
115 devices run in fixed block-size mode, where most nine-track tapes and
116 many new cartridge formats allow variable block-size.  The difference
117 between the two is as follows:
118 .Bl -inset
119 .It Variable block-size:
120 Each write made to the device results in a single logical record
121 written to the tape.  One can never read or write
122 .Em part
123 of a record from tape (though you may request a larger block and read
124 a smaller record); nor can one read multiple blocks.  Data from a
125 single write is therefore read by a single read.
126 The block size used
127 may be any value supported by the device, the
128 .Tn SCSI
129 adapter and the system (usually between 1 byte and 64 Kbytes,
130 sometimes more).
131 .Pp
132 When reading a variable record/block from the tape, the head is
133 logically considered to be immediately after the last item read,
134 and before the next item after that.
135 If the next item is a file mark,
136 but it was never read, then the next
137 process to read will immediately hit the file mark and receive an end-of-file notification.
138 .It Fixed block-size:
139 Data written by the user is passed to the tape as a succession of
140 fixed size blocks.  It may be contiguous in memory, but it is
141 considered to be a series of independent blocks.
142 One may never write
143 an amount of data that is not an exact multiple of the blocksize.  One
144 may read and write the same data as a different set of records, In
145 other words, blocks that were written together may be read separately,
146 and vice-versa.
147 .Pp
148 If one requests more blocks than remain in the file, the drive will
149 encounter the file mark.  Because there is some data to return (unless
150 there were no records before the file mark), the read will succeed,
151 returning that data, The next read will return immediately with a value
152 of 0.  (As above, if the file mark is never read, it remains for the next
153 process to read if in no-rewind mode.)
154 .El
155 .Sh FILE MARK HANDLING
156 The handling of file marks on write is automatic.
157 If the user has
158 written to the tape, and has not done a read since the last write,
159 then a file mark will be written to the tape when the device is
160 closed.  If a rewind is requested after a write, then the driver
161 assumes that the last file on the tape has been written, and ensures
162 that there are two file marks written to the tape.  The exception to
163 this is that there seems to be a standard (which we follow, but don't
164 understand why) that certain types of tape do not actually write two
165 file marks to tape, but when read, report a `phantom' file mark when the
166 last file is read.  These devices include the QIC family of devices.
167 (It might be that this set of devices is the same set as that of fixed
168 block devices.  This has not been determined yet, and they are treated
169 as separate behaviors by the driver at this time.)
170 .Sh IOCTLS
171 The
172 .Nm
173 driver supports all of the ioctls of
174 .Xr mtio 4 .
175 .Sh FILES
176 .Bl -tag -width /dev/[n][e]sa[0-9] -compact
177 .It Pa /dev/[n][e]sa[0-9]
178 general form:
179 .It Pa /dev/sa0
180 Rewind on close
181 .It Pa /dev/nsa0
182 No rewind on close
183 .It Pa /dev/esa0
184 Eject on close (if capable)
185 .It Pa /dev/sa0.ctl
186 Control mode device (to examine state while another program is
187 accessing the device, e.g.).
188 .El
189 .Sh BUGS
190 This driver lacks many of the hacks required to deal with older devices.
191 Many older
192 .Tn SCSI-1
193 devices may not work properly with this driver yet.
194 .Pp
195 Additionally, certain
196 tapes (QIC tapes mostly) that were written under
197 .Fx
198 2.X
199 aren't automatically read correctly with this driver: you may need to
200 explicitly set variable block mode or set to the blocksize that works best
201 for your device in order to read tapes written under
202 .Fx
203 2.X.
204 .Pp
205 Fine grained density and compression mode support that is bound to specific
206 device names needs to be added.
207 .Pp
208 Support for fast indexing by use of partitions is missing.
209 .Sh DIAGNOSTICS
210 None.
211 .Sh SEE ALSO
212 .Xr mt 1 ,
213 .Xr scsi 4
214 .Sh HISTORY
215 The
216 .Nm
217 driver was written for the
218 .Tn CAM
219 .Tn SCSI
220 subsystem by Justin T. Gibbs and Kenneth Merry.
221 Many ideas were gleaned from the
222 .Nm st
223 device driver written and ported from
224 .Tn Mach
225 2.5
226 by
227 .An Julian Elischer .
228 .Pp
229 The current owner of record is
230 .An Matthew Jacob
231 who has suffered too many
232 years of breaking tape drivers.