]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man4/st.4
getcpu.2, sendfile.2, cmsg.3, rtnetlink.3, arp.7, ddp.7, fifo.7, icmp.7, ip.7, ipv6...
[thirdparty/man-pages.git] / man4 / st.4
CommitLineData
fea681da 1.\" Copyright 1995 Robert K. Nichols (Robert.K.Nichols@att.com)
e2af0daf 2.\" Copyright 1999-2005 Kai Mäkisara (Kai.Makisara@kolumbus.fi)
fea681da 3.\"
4b72fb64 4.\" %%%LICENSE_START(verbatim)
fea681da
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
e2af0daf 13.\"
fea681da
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
e2af0daf 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
72542487 25.TH ST 4 2010-09-04 "Linux" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27st \- SCSI tape device
28.SH SYNOPSIS
29.nf
30.B #include <sys/mtio.h>
31.sp
32.BI "int ioctl(int " fd ", int " request " [, (void *)" arg3 "]);"
e40c76c0
MK
33.BI "int ioctl(int " fd ", MTIOCTOP, (struct mtop *)" mt_cmd );
34.BI "int ioctl(int " fd ", MTIOCGET, (struct mtget *)" mt_status );
35.BI "int ioctl(int " fd ", MTIOCPOS, (struct mtpos *)" mt_pos );
fea681da
MK
36.fi
37.SH DESCRIPTION
38The
39.B st
40driver provides the interface to a variety of SCSI tape devices.
41Currently, the driver takes control of all detected devices of type
cba04495 42\(lqsequential-access\(rq.
fea681da
MK
43The
44.B st
45driver uses major device number 9.
46.PP
c13182ef
MK
47Each device uses eight minor device numbers.
48The lowermost five bits
fea681da 49in the minor numbers are assigned sequentially in the order of
c13182ef
MK
50detection.
51In the 2.6 kernel, the bits above the eight lowermost bits are
e51d6af5 52concatenated to the five lowermost bits to form the tape number.
e2af0daf 53The minor numbers can be grouped into
fea681da
MK
54two sets of four numbers: the principal (auto-rewind) minor device numbers,
55.IR n ,
e2af0daf 56and the \(lqno-rewind\(rq device numbers,
cba04495 57.RI ( n " + 128)."
fea681da 58Devices opened using the principal device number will be sent a
e40c76c0
MK
59.BR REWIND
60command when they are closed.
fea681da
MK
61Devices opened using the \(lqno-rewind\(rq device number will not.
62(Note that using an auto-rewind device for positioning the tape with,
63for instance, mt does not lead to the desired result: the tape is
64rewound after the mt command and the next command starts from the
65beginning of the tape).
66.PP
67Within each group, four minor numbers are available to define
68devices with different characteristics (block size, compression,
c13182ef
MK
69density, etc.)
70When the system starts up, only the first device is available.
71The other three are activated when the default
6387216b
MK
72characteristics are defined (see below).
73(By changing compile-time
fea681da
MK
74constants, it is possible to change the balance between the maximum
75number of tape drives and the number of minor numbers for each
c13182ef
MK
76drive.
77The default allocation allows control of 32 tape drives.
fea681da
MK
78For instance, it is possible to control up to 64 tape drives
79with two minor numbers for different options.)
80.PP
81Devices are typically created by:
a6e2f128 82.in +4n
fea681da 83.nf
cf0a9ace 84
2bc2f479
MK
85mknod \-m 666 /dev/st0 c 9 0
86mknod \-m 666 /dev/st0l c 9 32
87mknod \-m 666 /dev/st0m c 9 64
88mknod \-m 666 /dev/st0a c 9 96
89mknod \-m 666 /dev/nst0 c 9 128
90mknod \-m 666 /dev/nst0l c 9 160
91mknod \-m 666 /dev/nst0m c 9 192
92mknod \-m 666 /dev/nst0a c 9 224
fea681da 93.fi
a6e2f128 94.in
fea681da
MK
95.PP
96There is no corresponding block device.
97.PP
98The driver uses an internal buffer that has to be large enough to hold
c13182ef
MK
99at least one tape block.
100In kernels before 2.1.121, the buffer is
101allocated as one contiguous block.
102This limits the block size to the
fea681da 103largest contiguous block of memory the kernel allocator can provide.
e2af0daf 104The limit is currently 128 kB for 32-bit architectures and
c13182ef
MK
105256 kB for 64-bit architectures.
106In newer kernels the driver
107allocates the buffer in several parts if necessary.
108By default, the
109maximum number of parts is 16.
110This means that the maximum block size
fea681da
MK
111is very large (2 MB if allocation of 16 blocks of 128 kB succeeds).
112.PP
113The driver's internal buffer size is determined by a compile-time
114constant which can be overridden with a kernel startup option.
115In addition to this, the driver tries to allocate a larger temporary
cf50118f 116buffer at run time if necessary.
c13182ef 117However, run-time allocation of large
fea681da
MK
118contiguous blocks of memory may fail and it is advisable not to rely
119too much on dynamic buffer allocation with kernels older than 2.1.121
120(this applies also to demand-loading the driver with kerneld or kmod).
121.PP
122The driver does not specifically support any tape drive brand or
c13182ef
MK
123model.
124After system start-up the tape device options are defined by
e2af0daf
MK
125the drive firmware.
126For example, if the drive firmware selects fixed-block mode,
c13182ef
MK
127the tape device uses fixed-block mode.
128The options can
fea681da 129be changed with explicit
5e21af3a 130.BR ioctl (2)
fea681da 131calls and remain in effect when the device is closed and reopened.
24b74457 132Setting the options affects both the auto-rewind and the nonrewind
fea681da
MK
133device.
134.PP
135Different options can be specified for the different devices within
c13182ef
MK
136the subgroup of four.
137The options take effect when the device is
138opened.
139For example, the system administrator can define
e2af0daf
MK
140one device that writes in fixed-block mode with a certain block size,
141and one which writes in variable-block mode (if the drive supports
fea681da
MK
142both modes).
143.PP
144The driver supports
145.B tape partitions
c13182ef
MK
146if they are supported by the drive.
147(Note that the tape partitions
148have nothing to do with disk partitions.
149A partitioned tape can be
150seen as several logical tapes within one medium.)
151Partition support has to be enabled with an
5e21af3a 152.BR ioctl (2).
1e321034 153The tape
fea681da
MK
154location is preserved within each partition across partition changes.
155The partition used for subsequent tape operations is
c13182ef 156selected with an
5e21af3a 157.BR ioctl (2).
1e321034 158The partition switch is executed together with
fea681da 159the next tape operation in order to avoid unnecessary tape
c13182ef
MK
160movement.
161The maximum number of partitions on a tape is defined by a
162compile-time constant (originally four).
163The driver contains an
5e21af3a 164.BR ioctl (2)
1e321034 165that can format a tape with either one or two partitions.
fea681da
MK
166.PP
167Device
8478ee02 168.I /dev/tape
fea681da
MK
169is usually created as a hard or soft link to the default tape device
170on the system.
e2af0daf
MK
171.PP
172Starting from kernel 2.6.2, the driver exports in the sysfs directory
0daa9e92 173.I /sys/class/scsi_tape
e2af0daf 174the attached devices and some parameters assigned to the devices.
73d8cece 175.SS Data transfer
e2af0daf
MK
176The driver supports operation in both fixed-block mode and
177variable-block mode (if supported by the drive).
178In fixed-block mode the drive
fea681da 179writes blocks of the specified size and the block size is not
e2af0daf
MK
180dependent on the byte counts of the write system calls.
181In variable-block mode one tape block is written for each write call
182and the byte
c13182ef
MK
183count determines the size of the corresponding tape block.
184Note that
e2af0daf 185the blocks on the tape don't contain any information about the
fea681da
MK
186writing mode: when reading, the only important thing is to use
187commands that accept the block sizes on the tape.
188.PP
e2af0daf 189In variable-block mode the read byte count does not have to match
c13182ef
MK
190the tape block size exactly.
191If the byte count is larger than the
fea681da 192next block on tape, the driver returns the data and the function
c13182ef
MK
193returns the actual block size.
194If the block size is larger than the
fea681da
MK
195byte count, the requested amount of data from the start of the block
196is returned and the rest of the block is discarded.
197.PP
e2af0daf 198In fixed-block mode the read byte counts can be arbitrary if
fea681da 199buffering is enabled, or a multiple of the tape block size if
c13182ef
MK
200buffering is disabled.
201Kernels before 2.1.121 allow writes with
202arbitrary byte count if buffering is enabled.
203In all other cases
fea681da
MK
204(kernel before 2.1.121 with buffering disabled or newer kernel) the
205write byte count must be a multiple of the tape block size.
206.PP
e2af0daf 207In the 2.6 kernel, the driver tries to use direct transfers between the user
c13182ef
MK
208buffer and the device.
209If this is not possible, the driver's internal buffer
210is used.
211The reasons for not using direct transfers include improper alignment
e2af0daf
MK
212of the user buffer (default is 512 bytes but this can be changed by the HBA
213driver), one of more pages of the user buffer not reachable by the
214SCSI adapter, etc.
215.PP
fea681da
MK
216A filemark is automatically written to tape if the last tape operation
217before close was a write.
218.PP
219When a filemark is encountered while reading, the following
c13182ef
MK
220happens.
221If there are data remaining in the buffer when the filemark
222is found, the buffered data is returned.
223The next read returns zero
224bytes.
225The following read returns data from the next file.
226The end of
fea681da 227recorded data is signaled by returning zero bytes for two consecutive
c13182ef
MK
228read calls.
229The third read returns an error.
2b2581ee 230.SS Ioctls
c13182ef 231The driver supports three
5e21af3a 232.BR ioctl (2)
1e321034 233requests.
fea681da
MK
234Requests not recognized by the
235.B st
236driver are passed to the
237.B SCSI
238driver.
239The definitions below are from
8478ee02 240.IR /usr/include/linux/mtio.h :
73d8cece 241.SS MTIOCTOP \(em perform a tape operation
fea681da
MK
242.PP
243This request takes an argument of type
8478ee02 244.IR "(struct mtop *)" .
fea681da 245Not all drives support all operations.
a9b4ebbc
MK
246The driver returns an
247.B EIO
248error if the drive rejects an operation.
fea681da 249.PP
088a639b 250.in +4n
fea681da 251.nf
e40c76c0 252/* Structure for MTIOCTOP \- mag tape op command: */
fea681da 253struct mtop {
cf0a9ace
MK
254 short mt_op; /* operations defined below */
255 int mt_count; /* how many of them */
fea681da
MK
256};
257.fi
e40c76c0 258.in
fea681da
MK
259.PP
260Magnetic Tape operations for normal tape use:
e40c76c0 261.TP 14
e40c76c0 262.B MTBSF
fea681da 263Backward space over
f19a0f03 264.I mt_count
fea681da 265filemarks.
e40c76c0
MK
266.TP
267.B MTBSFM
fea681da 268Backward space over
f19a0f03 269.I mt_count
fea681da
MK
270filemarks.
271Reposition the tape to the EOT side of the last filemark.
e40c76c0
MK
272.TP
273.B MTBSR
fea681da 274Backward space over
f19a0f03 275.I mt_count
fea681da 276records (tape blocks).
e40c76c0
MK
277.TP
278.B MTBSS
fea681da 279Backward space over
f19a0f03 280.I mt_count
fea681da 281setmarks.
e40c76c0
MK
282.TP
283.B MTCOMPRESSION
fea681da 284Enable compression of tape data within the drive if
f19a0f03 285.I mt_count
c7094399 286is nonzero and disable compression if
f19a0f03 287.I mt_count
c13182ef
MK
288is zero.
289This command uses the MODE page 15 supported by most DATs.
e40c76c0
MK
290.TP
291.B MTEOM
fea681da 292Go to the end of the recorded media (for appending files).
e40c76c0
MK
293.TP
294.B MTERASE
c13182ef
MK
295Erase tape.
296With 2.6 kernel, short erase (mark tape empty) is performed if the
297argument is zero.
298Otherwise long erase (erase all) is done.
e40c76c0
MK
299.TP
300.B MTFSF
fea681da 301Forward space over
f19a0f03 302.I mt_count
fea681da 303filemarks.
e40c76c0
MK
304.TP
305.B MTFSFM
fea681da 306Forward space over
f19a0f03 307.I mt_count
fea681da
MK
308filemarks.
309Reposition the tape to the BOT side of the last filemark.
e40c76c0
MK
310.TP
311.B MTFSR
fea681da 312Forward space over
f19a0f03 313.I mt_count
fea681da 314records (tape blocks).
e40c76c0
MK
315.TP
316.B MTFSS
fea681da 317Forward space over
f19a0f03 318.I mt_count
fea681da 319setmarks.
e40c76c0
MK
320.TP
321.B MTLOAD
c13182ef
MK
322Execute the SCSI load command.
323A special case is available for some HP
324autoloaders.
325If
f19a0f03 326.I mt_count
08362d55
MK
327is the constant
328.B MT_ST_HPLOADER_OFFSET
329plus a number, the number is
fea681da 330sent to the drive to control the autoloader.
e40c76c0
MK
331.TP
332.B MTLOCK
fea681da 333Lock the tape drive door.
e40c76c0
MK
334.TP
335.B MTMKPART
c13182ef
MK
336Format the tape into one or two partitions.
337If
f19a0f03 338.I mt_count
c7094399 339is nonzero, it gives the size of the first partition and the second
c13182ef
MK
340partition contains the rest of the tape.
341If
f19a0f03 342.I mt_count
fea681da
MK
343is zero, the tape is formatted into one partition.
344This command is not allowed for a drive unless the partition support
e40c76c0
MK
345is enabled for the drive (see
346.BR MT_ST_CAN_PARTITIONS
347below).
348.TP
349.B MTNOP
5503c85e 350No op\(emflushes the driver's buffer as a side effect.
979c2c91 351Should be used before reading status with
e40c76c0
MK
352.BR MTIOCGET .
353.TP
354.B MTOFFL
fea681da 355Rewind and put the drive off line.
e40c76c0
MK
356.TP
357.B MTRESET
fea681da 358Reset drive.
e40c76c0
MK
359.TP
360.B MTRETEN
3f1c1b0a 361Re-tension tape.
e40c76c0
MK
362.TP
363.B MTREW
fea681da 364Rewind.
e40c76c0
MK
365.TP
366.B MTSEEK
fea681da 367Seek to the tape block number specified in
f19a0f03 368.IR mt_count .
e40c76c0
MK
369This operation requires either a SCSI-2 drive that supports the
370.B LOCATE
fea681da
MK
371command (device-specific address)
372or a Tandberg-compatible SCSI-1 drive (Tandberg, Archive
e40c76c0 373Viper, Wangtek, ...).
fea681da 374The block number should be one that was previously returned by
e40c76c0
MK
375.BR MTIOCPOS
376if device-specific addresses are used.
377.TP
378.B MTSETBLK
fea681da 379Set the drive's block length to the value specified in
f19a0f03 380.IR mt_count .
fea681da 381A block length of zero sets the drive to variable block size mode.
e40c76c0
MK
382.TP
383.B MTSETDENSITY
fea681da 384Set the tape density to the code in
f19a0f03 385.IR mt_count .
fea681da
MK
386The density codes supported by a drive can be found from the drive
387documentation.
e40c76c0
MK
388.TP
389.B MTSETPART
fea681da 390The active partition is switched to
f19a0f03 391.IR mt_count .
c13182ef
MK
392The partitions are numbered from zero.
393This command is not allowed for
fea681da 394a drive unless the partition support is enabled for the drive (see
e40c76c0
MK
395.B MT_ST_CAN_PARTITIONS
396below).
397.TP
398.B MTUNLOAD
fea681da 399Execute the SCSI unload command (does not eject the tape).
e40c76c0
MK
400.TP
401.B MTUNLOCK
fea681da 402Unlock the tape drive door.
e40c76c0
MK
403.TP
404.B MTWEOF
e2af0daf 405Write
f19a0f03 406.I mt_count
fea681da 407filemarks.
e40c76c0
MK
408.TP
409.B MTWSM
fea681da 410Write
f19a0f03 411.I mt_count
fea681da 412setmarks.
fea681da
MK
413.PP
414Magnetic Tape operations for setting of device options (by the superuser):
e40c76c0
MK
415.TP 8
416.B MTSETDRVBUFFER
fea681da 417Set various drive and driver options according to bits encoded in
f19a0f03 418.IR mt_count .
e2af0daf 419These consist of the drive's buffering mode, a set of Boolean driver
fea681da 420options, the buffer write threshold, defaults for the block size and
74aace8a 421density, and timeouts (only in kernels 2.1 and later).
fea681da
MK
422A single operation can affect only one item in the list above (the
423Booleans counted as one item.)
fea681da
MK
424.IP
425A value having zeros in the high-order 4 bits will be used to set the
426drive's buffering mode.
427The buffering modes are:
428.RS 12
429.IP 0 4
979c2c91 430The drive will not report
e40c76c0
MK
431.BR GOOD
432status on write commands until the data
fea681da 433blocks are actually written to the medium.
fea681da 434.IP 1
979c2c91 435The drive may report
e40c76c0
MK
436.BR GOOD
437status on write commands as soon as all the
fea681da
MK
438data has been transferred to the drive's internal buffer.
439.IP 2
979c2c91 440The drive may report
e40c76c0
MK
441.BR GOOD
442status on write commands as soon as (a) all
fea681da
MK
443the data has been transferred to the drive's internal buffer, and
444(b) all buffered data from different initiators has been successfully
445written to the medium.
fea681da 446.RE
e40c76c0 447.IP
fea681da 448To control the write threshold the value in
f19a0f03 449.I mt_count
fea681da 450must include the constant
e40c76c0 451.BR MT_ST_WRITE_THRESHOLD
87f6d861 452bitwise ORed with a block count in the low 28 bits.
fea681da
MK
453The block count refers to 1024-byte blocks, not the physical block
454size on the tape.
455The threshold cannot exceed the driver's internal buffer size (see
e40c76c0 456DESCRIPTION, above).
fea681da
MK
457.IP
458To set and clear the Boolean options
459the value in
f19a0f03 460.I mt_count
e40c76c0
MK
461must include one of the constants
462.BR MT_ST_BOOLEANS ,
979c2c91 463.BR MT_ST_SETBOOLEANS ,
e40c76c0
MK
464.BR MT_ST_CLEARBOOLEANS ,
465or
466.BR MT_ST_DEFBOOLEANS
87f6d861 467bitwise ORed with
fea681da 468whatever combination of the following options is desired.
e40c76c0
MK
469Using
470.BR MT_ST_BOOLEANS
471the options can be set to the values
c13182ef 472defined in the corresponding bits.
e40c76c0
MK
473With
474.BR MT_ST_SETBOOLEANS
979c2c91 475the options can be selectively set and with
e40c76c0 476.BR MT_ST_DEFBOOLEANS
fea681da
MK
477selectively cleared.
478.IP ""
479The default options for a tape device are set with
e40c76c0 480.BR MT_ST_DEFBOOLEANS .
24b74457 481A nonactive tape device (e.g., device with
fea681da 482minor 32 or 160) is activated when the default options for it are
c13182ef
MK
483defined the first time.
484An activated device inherits from the device
fea681da
MK
485activated at start-up the options not set explicitly.
486.IP ""
487The Boolean options are:
fea681da 488.RS
979c2c91 489.TP
e40c76c0 490.BR MT_ST_BUFFER_WRITES " (Default: true)"
e2af0daf 491Buffer all write operations in fixed-block mode.
fea681da
MK
492If this option is false and the drive uses a fixed block size, then
493all write operations must be for a multiple of the block size.
ae03dc66 494This option must be set false to write reliable multivolume archives.
ddf54565 495.TP
e40c76c0 496.BR MT_ST_ASYNC_WRITES " (Default: true)"
e2af0daf 497When this option is true, write operations return immediately without
fea681da
MK
498waiting for the data to be transferred to the drive if the data fits
499into the driver's buffer.
500The write threshold determines how full the buffer must be before a
501new SCSI write command is issued.
502Any errors reported by the drive will be held until the next
503operation.
ae03dc66 504This option must be set false to write reliable multivolume archives.
e40c76c0
MK
505.TP
506.BR MT_ST_READ_AHEAD " (Default: true)"
fea681da 507This option causes the driver to provide read buffering and
e2af0daf 508read-ahead in fixed-block mode.
fea681da
MK
509If this option is false and the drive uses a fixed block size, then
510all read operations must be for a multiple of the block size.
e40c76c0
MK
511.TP
512.BR MT_ST_TWO_FM " (Default: false)"
fea681da
MK
513This option modifies the driver behavior when a file is closed.
514The normal action is to write a single filemark.
515If the option is true the driver will write two filemarks and
516backspace over the second one.
fea681da
MK
517.IP
518Note:
519This option should not be set true for QIC tape drives since they are
520unable to overwrite a filemark.
521These drives detect the end of recorded data by testing for blank tape
c13182ef
MK
522rather than two consecutive filemarks.
523Most other current drives also
fea681da
MK
524detect the end of recorded data and using two filemarks is usually
525necessary only when interchanging tapes with some other systems.
e40c76c0
MK
526.TP
527.BR MT_ST_DEBUGGING " (Default: false)"
fea681da 528This option turns on various debugging messages from the driver
e40c76c0
MK
529(effective only if the driver was compiled with
530.B DEBUG
c7094399 531defined nonzero).
e40c76c0
MK
532.TP
533.BR MT_ST_FAST_EOM " (Default: false)"
979c2c91 534This option causes the
e40c76c0
MK
535.B MTEOM
536operation to be sent directly to the
fea681da
MK
537drive, potentially speeding up the operation but causing the driver to
538lose track of the current file number normally returned by the
e40c76c0
MK
539.B MTIOCGET
540request.
541If
542.B MT_ST_FAST_EOM
543is false the driver will respond to an
544.B MTEOM
545request by forward spacing over files.
979c2c91 546.TP
e40c76c0 547.BR MT_ST_AUTO_LOCK " (Default: false)"
fea681da
MK
548When this option is true, the drive door is locked when the device is
549opened and unlocked when it is closed.
979c2c91 550.TP
e40c76c0 551.BR MT_ST_DEF_WRITES " (Default: false)"
fea681da
MK
552The tape options (block size, mode, compression, etc.) may change
553when changing from one device linked to a drive to another device
554linked to the same drive depending on how the devices are
c13182ef
MK
555defined.
556This option defines when the changes are enforced by the
fea681da 557driver using SCSI-commands and when the drives auto-detection
c13182ef
MK
558capabilities are relied upon.
559If this option is false, the driver
560sends the SCSI-commands immediately when the device is changed.
561If the
fea681da 562option is true, the SCSI-commands are not sent until a write is
c13182ef
MK
563requested.
564In this case the drive firmware is allowed to detect the
fea681da
MK
565tape structure when reading and the SCSI-commands are used only to
566make sure that a tape is written according to the correct specification.
979c2c91 567.TP
e40c76c0 568.BR MT_ST_CAN_BSR " (Default: false)"
fea681da
MK
569When read-ahead is used, the tape must sometimes be spaced backward to the
570correct position when the device is closed and the SCSI command to
5fab2e7c 571space backward over records is used for this purpose.
c13182ef 572Some older
fea681da 573drives can't process this command reliably and this option can be used
c13182ef
MK
574to instruct the driver not to use the command.
575The end result is that,
e2af0daf 576with read-ahead and fixed-block mode, the tape may not be correctly
c13182ef
MK
577positioned within a file when the device is closed.
578With 2.6 kernel, the
e2af0daf 579default is true for drives supporting SCSI-3.
e40c76c0
MK
580.TP
581.BR MT_ST_NO_BLKLIMS " (Default: false)"
582Some drives don't accept the
583.B "READ BLOCK LIMITS"
584SCSI command.
585If this is used, the driver does not use the command.
c13182ef 586The drawback is
fea681da
MK
587that the driver can't check before sending commands if the selected
588block size is acceptable to the drive.
e40c76c0
MK
589.TP
590.BR MT_ST_CAN_PARTITIONS " (Default: false)"
fea681da 591This option enables support for several partitions within a
c13182ef
MK
592tape.
593The option applies to all devices linked to a drive.
e40c76c0
MK
594.TP
595.BR MT_ST_SCSI2LOGICAL " (Default: false)"
fea681da
MK
596This option instructs the driver to use the logical block addresses
597defined in the SCSI-2 standard when performing the seek and tell
e40c76c0
MK
598operations (both with
599.B MTSEEK
600and
601.B MTIOCPOS
602commands and when changing tape
c13182ef
MK
603partition).
604Otherwise the device-specific addresses are used.
fea681da 605It is highly advisable to set this option if the drive supports the
c13182ef
MK
606logical addresses because they count also filemarks.
607There are some
fea681da 608drives that only support the logical block addresses.
979c2c91 609.TP
e40c76c0 610.BR MT_ST_SYSV " (Default: false)"
fea681da 611When this option is enabled, the tape devices use the SystemV
c13182ef
MK
612semantics.
613Otherwise the BSD semantics are used.
614The most important
fea681da 615difference between the semantics is what happens when a device used
80b50848 616for reading is closed: in System V semantics the tape is spaced forward
fea681da 617past the next filemark if this has not happened while using the
c13182ef
MK
618device.
619In BSD semantics the tape position is not changed.
979c2c91 620.TP
e40c76c0 621.BR MT_NO_WAIT " (Default: false)"
e2af0daf
MK
622Enables immediate mode (i.e., don't wait for the command to finish) for some
623commands (e.g., rewind).
e40c76c0
MK
624.PP
625An example:
088a639b 626.in +4n
fea681da 627.nf
e40c76c0
MK
628
629struct mtop mt_cmd;
630mt_cmd.mt_op = MTSETDRVBUFFER;
631mt_cmd.mt_count = MT_ST_BOOLEANS |
632 MT_ST_BUFFER_WRITES | MT_ST_ASYNC_WRITES;
633ioctl(fd, MTIOCTOP, mt_cmd);
fea681da 634.fi
e40c76c0 635.in
fea681da 636.RE
fea681da
MK
637.IP ""
638The default block size for a device can be set with
e40c76c0
MK
639.B MT_ST_DEF_BLKSIZE
640and the default density code can be set with
641.BR MT_ST_DEFDENSITY .
c13182ef 642The values for the parameters are or'ed
fea681da
MK
643with the operation code.
644.IP ""
645With kernels 2.1.x and later, the timeout values can be set with the
e40c76c0
MK
646subcommand
647.B MT_ST_SET_TIMEOUT
648ORed with the timeout in seconds.
fea681da
MK
649The long timeout (used for rewinds and other commands
650that may take a long time) can be set with
e40c76c0 651.BR MT_ST_SET_LONG_TIMEOUT .
c13182ef 652The kernel defaults are very long to
fea681da 653make sure that a successful command is not timed out with any
c13182ef
MK
654drive.
655Because of this the driver may seem stuck even if it is only
656waiting for the timeout.
657These commands can be used to set more
658practical values for a specific drive.
659The timeouts set for one device
fea681da 660apply for all devices linked to the same drive.
e2af0daf
MK
661.IP ""
662Starting from kernels 2.4.19 and 2.5.43, the driver supports a status
663bit which indicates whether the drive requests cleaning.
664The method used by the
665drive to return cleaning information is set using the
e40c76c0
MK
666.B MT_ST_SEL_CLN
667subcommand.
c13182ef
MK
668If the value is zero, the cleaning
669bit is always zero.
670If the value is one, the TapeAlert data defined
671in the SCSI-3 standard is used (not yet implemented).
672Values 2-17 are
673reserved.
674If the lowest eight bits are >= 18, bits from the extended
675sense data are used.
676The bits 9-16 specify a mask to select the bits
e2af0daf
MK
677to look at and the bits 17-23 specify the bit pattern to look for.
678If the bit pattern is zero, one or more bits under the mask indicate
c13182ef 679the cleaning request.
c7094399 680If the pattern is nonzero, the pattern must match
e2af0daf 681the masked sense data byte.
73d8cece 682.SS MTIOCGET \(em get status
fea681da
MK
683.PP
684This request takes an argument of type
8478ee02 685.IR "(struct mtget *)" .
fea681da 686.PP
088a639b 687.in +4n
fea681da 688.nf
e40c76c0 689/* structure for MTIOCGET \- mag tape get status command */
fea681da 690struct mtget {
cf0a9ace
MK
691 long mt_type;
692 long mt_resid;
e2af0daf 693 /* the following registers are device dependent */
cf0a9ace
MK
694 long mt_dsreg;
695 long mt_gstat;
696 long mt_erreg;
e2af0daf 697 /* The next two fields are not always used */
cf0a9ace
MK
698 daddr_t mt_fileno;
699 daddr_t mt_blkno;
fea681da
MK
700};
701.fi
e40c76c0 702.in
f19a0f03 703.IP \fImt_type\fP 11
fea681da 704The header file defines many values for
f19a0f03 705.IR mt_type ,
fea681da 706but the current driver reports only the generic types
e40c76c0
MK
707.B MT_ISSCSI1
708(Generic SCSI-1 tape)
709and
710.B MT_ISSCSI2
711(Generic SCSI-2 tape).
f19a0f03 712.IP \fImt_resid\fP
fea681da 713contains the current tape partition number.
f19a0f03 714.IP \fImt_dsreg\fP
fea681da
MK
715reports the drive's current settings for block size (in the low 24
716bits) and density (in the high 8 bits).
e40c76c0 717These fields are defined by
979c2c91 718.BR MT_ST_BLKSIZE_SHIFT ,
e40c76c0
MK
719.BR MT_ST_BLKSIZE_MASK ,
720.BR MT_ST_DENSITY_SHIFT ,
721and
722.BR MT_ST_DENSITY_MASK .
f19a0f03 723.IP \fImt_gstat\fP
fea681da
MK
724reports generic (device independent) status information.
725The header file defines macros for testing these status bits:
726.RS
727.HP 4
e40c76c0 728\fBGMT_EOF\fP(\fIx\fP):
fea681da 729The tape is positioned just after a filemark
979c2c91 730(always false after an
e40c76c0
MK
731.B MTSEEK
732operation).
fea681da 733.HP
e40c76c0 734\fBGMT_BOT\fP(\fIx\fP):
fea681da 735The tape is positioned at the beginning of the first file (always false
e40c76c0
MK
736after an
737.B MTSEEK
738operation).
fea681da 739.HP
e40c76c0 740\fBGMT_EOT\fP(\fIx\fP):
fea681da
MK
741A tape operation has reached the physical End Of Tape.
742.HP
e40c76c0 743\fBGMT_SM\fP(\fIx\fP):
fea681da 744The tape is currently positioned at a setmark
e40c76c0
MK
745(always false after an
746.B MTSEEK
747operation).
fea681da 748.HP
e40c76c0 749\fBGMT_EOD\fP(\fIx\fP):
fea681da
MK
750The tape is positioned at the end of recorded data.
751.HP
e40c76c0 752\fBGMT_WR_PROT\fP(\fIx\fP):
fea681da
MK
753The drive is write-protected.
754For some drives this can also mean that the drive does not support
755writing on the current medium type.
756.HP
e40c76c0 757\fBGMT_ONLINE\fP(\fIx\fP):
fea681da 758The last
5e21af3a 759.BR open (2)
fea681da
MK
760found the drive with a tape in place and ready for operation.
761.HP
e40c76c0 762\fBGMT_D_6250\fP(\fIx\fP), \fBGMT_D_1600\fP(\fIx\fP), \fBGMT_D_800\fP(\fIx\fP):
fea681da
MK
763This \(lqgeneric\(rq status information reports the current
764density setting for 9-track \(12" tape drives only.
765.HP
e40c76c0 766\fBGMT_DR_OPEN\fP(\fIx\fP):
fea681da
MK
767The drive does not have a tape in place.
768.HP
e40c76c0 769\fBGMT_IM_REP_EN\fP(\fIx\fP):
c13182ef
MK
770Immediate report mode.
771This bit is set if there are no guarantees that
fea681da 772the data has been physically written to the tape when the write call
c13182ef
MK
773returns.
774It is set zero only when the driver does not buffer data and
fea681da 775the drive is set not to buffer data.
e2af0daf 776.HP
e40c76c0 777\fBGMT_CLN\fP(\fIx\fP):
c13182ef 778The drive has requested cleaning.
74aace8a 779Implemented in kernels since 2.4.19 and 2.5.43.
fea681da 780.RE
f19a0f03 781.IP \fImt_erreg\fP
fea681da 782The only field defined in
f19a0f03 783.I mt_erreg
fea681da 784is the recovered error count in the low 16 bits (as defined by
e40c76c0
MK
785.BR MT_ST_SOFTERR_SHIFT
786and
787.BR MT_ST_SOFTERR_MASK .
fea681da
MK
788Due to inconsistencies in the way drives report recovered errors, this
789count is often not maintained (most drives do not by default report
790soft errors but this can be changed with a SCSI MODE SELECT command).
f19a0f03 791.IP \fImt_fileno\fP
fea681da
MK
792reports the current file number (zero-based).
793This value is set to \-1 when the file number is unknown (e.g., after
e40c76c0
MK
794.BR MTBSS
795or
796.BR MTSEEK ).
f19a0f03 797.IP \fImt_blkno\fP
fea681da
MK
798reports the block number (zero-based) within the current file.
799This value is set to \-1 when the block number is unknown (e.g., after
e40c76c0
MK
800.BR MTBSF ,
801.BR MTBSS ,
802or
803.BR MTSEEK ).
73d8cece 804.SS MTIOCPOS \(em get tape position
fea681da
MK
805.PP
806This request takes an argument of type
8478ee02 807.I "(struct mtpos *)"
fea681da
MK
808and reports the drive's notion of the current tape block number,
809which is not the same as
f19a0f03 810.I mt_blkno
e40c76c0
MK
811returned by
812.BR MTIOCGET .
979c2c91 813This drive must be a SCSI-2 drive that supports the
e40c76c0 814.B "READ POSITION"
fea681da
MK
815command (device-specific address)
816or a Tandberg-compatible SCSI-1 drive (Tandberg, Archive
817Viper, Wangtek, ... ).
818.PP
088a639b 819.in +4n
fea681da 820.nf
e40c76c0 821/* structure for MTIOCPOS \- mag tape get position command */
cf0a9ace
MK
822struct mtpos {
823 long mt_blkno; /* current block number */
fea681da 824};
fea681da 825.fi
e40c76c0 826.in
47297adb 827.SH RETURN VALUE
e40c76c0
MK
828.TP 14
829.TP
830.B EACCES
fea681da
MK
831An attempt was made to write or erase a write-protected tape.
832(This error is not detected during
5e21af3a 833.BR open (2).)
e40c76c0
MK
834.TP
835.B EBUSY
fea681da
MK
836The device is already in use or the driver was unable to allocate a
837buffer.
e40c76c0
MK
838.TP
839.B EFAULT
840The command parameters point to memory not belonging to the calling
841process.
842.TP
843.B EINVAL
fea681da 844An
5e21af3a 845.BR ioctl (2)
e935e108 846had an invalid argument, or a requested block size was invalid.
e40c76c0
MK
847.TP
848.B EIO
849The requested operation could not be completed.
850.TP
851.B ENOMEM
852The byte count in
853.BR read (2)
854is smaller than the next physical block on the tape.
855(Before 2.2.18 and 2.4.0-test6 the extra bytes have been
856silently ignored.)
857.TP
858.B ENOSPC
859A write operation could not be completed because the tape reached
860end-of-medium.
861.TP
862.B ENOSYS
fea681da 863Unknown
5e21af3a 864.BR ioctl (2).
e40c76c0
MK
865.TP
866.B ENXIO
867During opening, the tape device does not exist.
868.TP
869.B EOVERFLOW
870An attempt was made to read or write a variable-length block that is
871larger than the driver's internal buffer.
872.TP
873.B EROFS
874Open is attempted with
875.B O_WRONLY
876or
877.B O_RDWR
878when the tape in the drive is write-protected.
fea681da 879.SH FILES
cba04495
MK
880.TP 12
881.I /dev/st*
882the auto-rewind SCSI tape devices
883.TP 12
884.I /dev/nst*
24b74457 885the nonrewind SCSI tape devices
d2dc6294
MK
886.\" .SH AUTHOR
887.\" The driver has been written by Kai M\(:akisara (Kai.Makisara@metla.fi)
888.\" starting from a driver written by Dwayne Forsyth.
889.\" Several other
890.\" people have also contributed to the driver.
fea681da 891.SH NOTES
e40c76c0
MK
892.IP 1. 4
893When exchanging data between systems, both systems have to agree on
c13182ef
MK
894the physical tape block size.
895The parameters of a drive after startup
fea681da 896are often not the ones most operating systems use with these
c13182ef
MK
897devices.
898Most systems use drives in variable-block mode if the drive
899supports that mode.
900This applies to most modern drives, including
901DATs, 8mm helical scan drives, DLTs, etc.
902It may be advisable to use
e40c76c0
MK
903these drives in variable-block mode also in Linux (i.e., use
904.B MTSETBLK
905or
906.B MTSETDEFBLK
907at system startup to set the mode), at least when
c13182ef
MK
908exchanging data with a foreign system.
909The drawback of
fea681da
MK
910this is that a fairly large tape block size has to be used to get
911acceptable data transfer rates on the SCSI bus.
e40c76c0
MK
912.IP 2.
913Many programs (e.g.,
914.BR tar (1))
915allow the user to specify the blocking
c13182ef
MK
916factor on the command line.
917Note that this determines the physical block
e2af0daf 918size on tape only in variable-block mode.
e40c76c0
MK
919.IP 3.
920In order to use SCSI tape drives, the basic SCSI driver,
fea681da 921a SCSI-adapter driver and the SCSI tape driver must be either
c13182ef
MK
922configured into the kernel or loaded as modules.
923If the SCSI-tape
fea681da
MK
924driver is not present, the drive is recognized but the tape support
925described in this page is not available.
e40c76c0
MK
926.IP 4.
927The driver writes error messages to the console/log.
c13182ef 928The SENSE
fea681da
MK
929codes written into some messages are automatically translated to text
930if verbose SCSI messages are enabled in kernel configuration.
e40c76c0
MK
931.IP 5.
932The driver's internal buffering allows good throughput in fixed-block
c13182ef 933mode also with small
5e21af3a 934.BR read (2)
c13182ef 935and
5e21af3a 936.BR write (2)
c13182ef
MK
937byte counts.
938With direct transfers
e2af0daf
MK
939this is not possible and may cause a surprise when moving to the 2.6
940kernel.
941The solution is to tell the software to use larger transfers (often
942telling it to use larger blocks).
943If this is not possible, direct transfers can be disabled.
2b2581ee 944.\" .SH COPYRIGHT
e37e3282
MK
945.\" Copyright \(co 1995 Robert K. Nichols.
946.\" .br
947.\" Copyright \(co 1999-2005 Kai M\(:akisara.
948.\" .PP
4b72fb64 949.\" %%%LICENSE_START(verbatim)
e37e3282
MK
950.\" Permission is granted to make and distribute verbatim copies of this
951.\" manual provided the copyright notice and this permission notice are
952.\" preserved on all copies.
953.\" Additional permissions are contained in the header of the source file.
47297adb 954.SH SEE ALSO
e37e3282 955.BR mt (1)
fea681da 956.PP
cba04495
MK
957The file
958.I drivers/scsi/README.st
959or
960.I Documentation/scsi/st.txt
173fe7e7 961(kernel >= 2.6) in the Linux kernel source tree contains
e37e3282 962the most recent information about the driver and its configuration
173fe7e7 963possibilities