xref: /freebsd/share/man/man4/sa.4 (revision 51a9219f5780e61e1437d25220bf8750d9df7f8b)
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$
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.Sh DESCRIPTION
37The
38.Nm
39driver provides support for all
40.Tn SCSI
41devices of the sequential access class that are attached to the system
42through a supported
43.Tn SCSI
44Host Adapter.
45The sequential access class includes tape and other linear access devices.
46.Pp
47A
48.Tn SCSI
49Host
50adapter must also be separately configured into the system
51before a
52.Tn SCSI
53sequential access device can be configured.
54.Sh MOUNT SESSIONS
55The
56.Nm
57driver is based around the concept of a
58.Dq Em mount session ,
59which is defined as the period between the time that a tape is
60mounted, and the time when it is unmounted.  Any parameters set during
61a mount session remain in effect for the remainder of the session or
62until replaced.
63The tape can be unmounted, bringing the session to a
64close in several ways.  These include:
65.Bl -enum
66.It
67Closing a `rewind device',
68referred to as sub-mode 00 below.
69An example is
70.Pa /dev/sa0 .
71.It
72Using the MTOFFL
73.Xr ioctl 2
74command, reachable through the
75.Sq Cm offline
76command of
77.Xr mt 1 .
78.El
79.Pp
80It should be noted that tape devices are exclusive open devices, except in
81the case where a control mode device is opened.
82In the latter case, exclusive
83access is only sought when needed (e.g., to set parameters).
84.Sh SUB-MODES
85Bits 0 and 1 of the minor number are interpreted as
86.Sq sub-modes .
87The sub-modes differ in the action taken when the device is closed:
88.Bl -tag -width XXXX
89.It 00
90A close will rewind the device; if the tape has been
91written, then a file mark will be written before the rewind is requested.
92The device is unmounted.
93.It 01
94A close will leave the tape mounted.
95If the tape was written to, a file mark will be written.
96No other head positioning takes place.
97Any further reads or writes will occur directly after the
98last read, or the written file mark.
99.It 10
100A close will rewind the device.
101If the tape has been
102written, then a file mark will be written before the rewind is requested.
103On completion of the rewind an unload command will be issued.
104The device is unmounted.
105.El
106.Sh BLOCKING MODES
107.Tn SCSI
108tapes may run in either
109.Sq Em variable
110or
111.Sq Em fixed
112block-size modes.  Most
113.Tn QIC Ns -type
114devices run in fixed block-size mode, where most nine-track tapes and
115many new cartridge formats allow variable block-size.  The difference
116between the two is as follows:
117.Bl -inset
118.It Variable block-size:
119Each write made to the device results in a single logical record
120written to the tape.  One can never read or write
121.Em part
122of a record from tape (though you may request a larger block and read
123a smaller record); nor can one read multiple blocks.  Data from a
124single write is therefore read by a single read.
125The block size used
126may be any value supported by the device, the
127.Tn SCSI
128adapter and the system (usually between 1 byte and 64 Kbytes,
129sometimes more).
130.Pp
131When reading a variable record/block from the tape, the head is
132logically considered to be immediately after the last item read,
133and before the next item after that.
134If the next item is a file mark,
135but it was never read, then the next
136process to read will immediately hit the file mark and receive an end-of-file notification.
137.It Fixed block-size:
138Data written by the user is passed to the tape as a succession of
139fixed size blocks.  It may be contiguous in memory, but it is
140considered to be a series of independent blocks.
141One may never write
142an amount of data that is not an exact multiple of the blocksize.  One
143may read and write the same data as a different set of records, In
144other words, blocks that were written together may be read separately,
145and vice-versa.
146.Pp
147If one requests more blocks than remain in the file, the drive will
148encounter the file mark.  Because there is some data to return (unless
149there were no records before the file mark), the read will succeed,
150returning that data, The next read will return immediately with a value
151of 0.  (As above, if the file mark is never read, it remains for the next
152process to read if in no-rewind mode.)
153.El
154.Sh FILE MARK HANDLING
155The handling of file marks on write is automatic.
156If the user has
157written to the tape, and has not done a read since the last write,
158then a file mark will be written to the tape when the device is
159closed.  If a rewind is requested after a write, then the driver
160assumes that the last file on the tape has been written, and ensures
161that there are two file marks written to the tape.  The exception to
162this is that there seems to be a standard (which we follow, but don't
163understand why) that certain types of tape do not actually write two
164file marks to tape, but when read, report a `phantom' file mark when the
165last file is read.  These devices include the QIC family of devices.
166(It might be that this set of devices is the same set as that of fixed
167block devices.  This has not been determined yet, and they are treated
168as separate behaviors by the driver at this time.)
169.Sh IOCTLS
170The
171.Nm
172driver supports all of the ioctls of
173.Xr mtio 4 .
174.Sh FILES
175.Bl -tag -width /dev/[n][e]sa[0-9] -compact
176.It Pa /dev/[n][e]sa[0-9]
177general form:
178.It Pa /dev/sa0
179Rewind on close
180.It Pa /dev/nsa0
181No rewind on close
182.It Pa /dev/esa0
183Eject on close (if capable)
184.It Pa /dev/sa0.ctl
185Control mode device (to examine state while another program is
186accessing the device, e.g.).
187.El
188.Sh BUGS
189This driver lacks many of the hacks required to deal with older devices.
190Many older
191.Tn SCSI-1
192devices may not work properly with this driver yet.
193.Pp
194Additionally, certain
195tapes (QIC tapes mostly) that were written under
196.Fx
1972.X
198aren't automatically read correctly with this driver: you may need to
199explicitly set variable block mode or set to the blocksize that works best
200for your device in order to read tapes written under
201.Fx
2022.X.
203.Pp
204Fine grained density and compression mode support that is bound to specific
205device names needs to be added.
206.Pp
207Support for fast indexing by use of partitions is missing.
208.Sh DIAGNOSTICS
209None.
210.Sh SEE ALSO
211.Xr mt 1 ,
212.Xr scsi 4
213.Sh HISTORY
214The
215.Nm
216driver was written for the
217.Tn CAM
218.Tn SCSI
219subsystem by Justin T. Gibbs and Kenneth Merry.
220Many ideas were gleaned from the
221.Nm st
222device driver written and ported from
223.Tn Mach
2242.5
225by
226.An Julian Elischer .
227.Pp
228The current owner of record is
229.An Matthew Jacob
230who has suffered too many
231years of breaking tape drivers.
232