Debian Codegraph @

upstream/debian-unstable/man4/st.4

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