OSDN Git Service

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