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