1 .\" $NetBSD: st.4,v 1.23 2003/06/27 18:46:33 wiz Exp $
4 .\" Julian Elischer <julian@freebsd.org>. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd SCSI/ATAPI tape driver
35 .Cd "st* at scsibus? target ? lun ?"
36 .Cd "st1 at scsibus0 target 4 lun 0"
37 .Cd "st* at atapibus? drive ? flags 0x0000"
41 driver provides support for
43 and Advanced Technology Attachment Packet Interface
46 It allows a tape drive to be run in several different
47 modes depending on minor numbers and supports several different
49 The device can have both a
53 interface; however, only the raw interface is usually used (or recommended).
58 devices have a relatively high level interface and talk to the system via a
74 adapter must also be separately configured into the system before a
78 tape can be configured.
84 adapter is probed during boot, the
88 bus is scanned for devices.
89 Any devices found which answer as
91 type devices will be attached to the
97 driver is based around the concept of a
98 .Dq Em mount session ,
99 which is defined as the period between the time that a tape is
100 mounted, and the time when it is unmounted.
101 Any parameters set during a mount session remain in effect for the
102 remainder of the session or until replaced.
103 The tape can be unmounted, bringing the session to a close in
110 referred to as sub-mode 00 below.
117 command, reachable through the
122 Opening a different mode will implicitly unmount the tape, thereby
123 closing off the mode that was previously mounted.
124 All parameters will be loaded freshly from the new mode
125 (See below for more on modes).
127 .Sh MODES AND SUB-MODES
128 There are several different
131 These are controlled by bits 2 and 3 of the minor number
132 and are designed to allow users to easily read and write different
133 formats of tape on devices that allow multiple formats.
134 The parameters for each mode can be set individually by hand with the
137 When a device corresponding to a particular mode is first
138 mounted, The operating parameters for that mount session are copied
140 Further changes to the parameters during the session will change
141 those in effect for the session but not those set in the operation mode.
142 To change the parameters for an operation mode, one must compile
145 table in the driver's source code.
147 In addition to the operating modes mentioned above, bits 0 and 1
148 of the minor number are interpreted as
150 The sub-modes differ in the action taken when the device is closed:
153 A close will rewind the device; if the tape has been written, then
154 a file mark will be written before the rewind is requested.
155 The device is unmounted.
157 A close will leave the tape mounted.
158 If the tape was written to, a file mark will be written.
159 No other head positioning takes place.
160 Any further reads or writes will occur directly after the last
161 read, or the written file mark.
163 A close will rewind the device.
164 If the tape has been written, then a file mark will be written
165 before the rewind is requested.
166 On completion of the rewind an unload command will be issued.
167 The device is unmounted.
169 This is Control mode, which allows the tape driver to be opened without a tape
170 inserted to allow various ioctls (e.g. MTIOCGET or MTIOCTOP to set density
171 or blocksize) and raw SCSI command on
172 through. I/O can be done in this mode, if desired, with the same
173 rewind/eject behaviour as mode 01. This isn't really an 'action taken
174 on close' type of distinction, but this seems to be the place to put
179 tapes may run in either
186 devices run in fixed block-size mode, where most nine-track tapes
187 and many new cartridge formats allow variable block-size.
188 The difference between the two is as follows:
190 .It Variable block-size
191 Each write made to the device results in a single logical record
193 One can never read or write
195 of a record from tape (though you may request a larger block and
196 read a smaller record); nor can one read multiple blocks.
197 Data from a single write is therefore read by a single read.
198 The block size used may be any value supported by the device, the
200 adapter and the system (usually between 1 byte and 64 Kbytes,
203 When reading a variable record/block from the tape, the head is
204 logically considered to be immediately after the last item read,
205 and before the next item after that.
206 If the next item is a file mark, but it was never read, then the
207 next process to read will immediately hit the file mark and receive
208 an end-of-file notification.
210 Data written by the user is passed to the tape as a succession of
212 It may be contiguous in memory, but it is considered to be a series
213 of independent blocks.
214 One may never write an amount of data that is not an exact multiple
216 One may read and write the same data as a different set of records,
217 In other words, blocks that were written together may be read
218 separately, and vice-versa.
220 If one requests more blocks than remain in the file, the drive will
221 encounter the file mark.
222 Because there is some data to return (unless there were no records
223 before the file mark), the read will succeed, returning that data.
224 The next read will return immediately with an EOF (as above, if
225 the file mark is never read, it remains for the next process to
226 read if in no-rewind mode).
228 .Sh FILE MARK HANDLING
229 The handling of file marks on write is automatic.
230 If the user has written to the tape, and has not done a read since
231 the last write, then a file mark will be written to the tape when
232 the device is closed.
233 If a rewind is requested after a write, then the driver assumes
234 that the last file on the tape has been written, and ensures that
235 there are two file marks written to the tape.
236 The exception to this is that there seems to be a standard (which
237 we follow, but don't understand why) that certain types of tape do
238 not actually write two file marks to tape, but when read, report a
240 file mark when the last file is read.
241 These devices include the QIC family of devices
242 (it might be that this set of devices is
243 the same set as that of fixed block devices.
244 This has not been determined yet, and they are treated as separate
245 behaviors by the driver at this time).
247 Attempts to write past EOM and how EOM is reported are handled slightly
248 differently based upon whether EARLY WARNING recognition is enabled in
251 If EARLY WARNING recognitions is
253 enabled, then detection
254 of EOM (as reported in SCSI Sense Data with an EOM indicator)
255 causes the write operation to be flagged with I/O error (EIO).
256 This has the effect for the user application of not knowing actually
257 how many bytes were read (since the return of the
259 system call is set to \(mi1).
261 If EARLY WARNING recognition
263 enabled, then detection of EOM
264 (as reported in SCSI Sense Data with an EOM indicator)
265 has no immediate effect except that
266 the driver notes that EOM has been detected. If the write completing
267 didn't transfer all data that was requested, then the residual count
271 is returned to the user application. In any event, the next attempt
272 to write (if that is the next action the user application takes)
273 is immediately completed with no data transferred, and a residual
274 returned to the user application indicating that no data was transferred.
275 This is the traditional UNIX EOF indication. The state that EOM had
276 been seen is then cleared.
278 In either mode of operation, the driver does not prohibit the
279 user application from writing more data, if it chooses to do so. This
280 will continue up until the physical end of media, which is usually
281 signalled internally to the driver as a CHECK CONDITION with
282 the Sense Key set to VOLUME OVERFLOW. When this or any otherwise
283 unhandled error occurs, an error return of EIO will be transmitted
284 to the user application. This does indeed mean that if EARLY WARNING
285 is enables and the device continues to set EOM indicators prior to
286 hitting physical end of media, that an indeterminate number of 'short write
287 returns' as described in the previous paragraph will occur. However, the
288 expected user application behaviour (in common with other systems) is
289 to close the tape and rewind and request another tape upon the receipt
290 of the first EOM indicator, possibly after writing one trailer record.
291 .Sh KERNEL CONFIGURATION
292 Because different tape drives behave differently, there is a
293 mechanism within the source to
295 to quickly and conveniently recognize and deal with brands and
296 models of drive that have special requirements.
298 There is a table (called the
300 in which the identification strings of known errant drives can be stored.
301 Alongside each is a set of flags that allows the setting
302 of densities and blocksizes for each of the modes, along with a
303 set of `QUIRK' flags that can be used to enable or disable sections
304 of code within the driver if a particular drive is recognized.
311 Some also apply to other tapes.
312 They are defined in the header file
315 .\" Almost all of this discussion belongs in a separate mt(4)
316 .\" manual page, since it is common to all magnetic tapes.
319 .Bl -tag -width MTIOCEEOT
321 .Pq Li "struct mtget"
322 Retrieve the status and parameters of the tape. Error status
323 and residual is unlatched and cleared by the driver when it receives
327 Perform a multiplexed operation.
328 The argument structure is as follows:
329 .Bd -literal -offset indent
336 The following operation values are defined for
338 .Bl -tag -width MTSELDNSTY
342 end of file marks at the present head position.
347 Leave the head on the EOM side of the last skipped file mark.
354 Leave the head on the BOM (beginning of media)
355 side of the last skipped file mark.
365 Rewind the device to the beginning of the media.
367 Rewind the media (and, if possible, eject).
368 Even if the device cannot eject the media it will often no longer
369 respond to normal requests.
371 No-op; set status only.
373 Erase the media from current position. If the field
375 is nonzero, a full erase is done (from current position to end of
378 is zero, only an erase gap is written. It is hard to say which
379 drives support only one but not the other option
381 Enable controller buffering.
383 Disable controller buffering.
385 Set the blocksize to use for the device/mode.
386 If the device is capable of variable blocksize operation, and the
387 blocksize is set to 0, then the drive will be driven in variable mode.
388 This parameter is in effect for the present mount session only, unless
389 the device was opened in Control Mode (in which case this set value persists
392 Set the density value (see
394 to use when running in the mode opened (minor bits 2 and 3).
395 This parameter is in effect for the present
396 mount session only, unless the device was opened in Control Mode (in which
397 case this set value persists until a reboot).
398 Any byte sized value may be specified. Note that
399 only a very small number of them will actually usefully work. The
400 rest will cause the tape drive to spit up.
402 Enable or disable tape drive data compression.
403 Typically tape drives will quite contentedly ignore settings on
404 reads, and will probably keep you from changing density for writing
407 Enable or disable EARLY WARNING at EOM behaviour (using the count
412 Read device logical block position.
413 Not all drives support this option.
416 Read device hardware block position.
417 Not all drives support this option.
420 Position the tape to the specified device logical block position.
423 Position the tape to the specified hardware block position.
424 Not all drives support this option.
427 .Bl -tag -width /dev/[n][e]rst[0-9] -compact
428 .It Pa /dev/[n][e]rst[0-9]
431 Mode 0, Rewind on close
433 Mode 1, No rewind on close
435 Mode 2, Eject on close (if capable)
437 Mode 3, Control Mode (elsewise like mode 0)
447 driver was originally written for
449 2.5 by Julian Elischer, and was ported to
452 This man page was edited for
456 The selection of compression could possibly also be usefully done
457 as with a minor device bit.