1ST(4)                      Linux Programmer's Manual                     ST(4)
2
3
4

NAME

6       st - SCSI tape device
7

SYNOPSIS

9       #include <sys/mtio.h>
10
11       int ioctl(int fd, int request [, (void *)arg3]);
12       int ioctl(int fd, MTIOCTOP, (struct mtop *)mt_cmd);
13       int ioctl(int fd, MTIOCGET, (struct mtget *)mt_status);
14       int ioctl(int fd, MTIOCPOS, (struct mtpos *)mt_pos);
15

DESCRIPTION

17       The st driver provides the interface to a variety of SCSI tape devices.
18       Currently, the driver takes control of all  detected  devices  of  type
19       “sequential-access.”  The st driver uses major device number 9.
20
21       Each device uses eight minor device numbers. The lowermost five bits in
22       the minor numbers are assigned sequentially in the order of  detection.
23       In the 2.6 kernel, the bits above the eight lowermost bits are concate‐
24       nated to the five lowermost bits to form the tape  number.   The  minor
25       numbers  can  be  grouped  into two sets of four numbers: the principal
26       (auto-rewind) minor device numbers, n, and the “no-rewind” device  num‐
27       bers,  (n+ 128).  Devices opened using the principal device number will
28       be sent a REWIND command when they are closed.   Devices  opened  using
29       the  “no-rewind”  device  number  will  not.  (Note that using an auto-
30       rewind device for positioning the tape with, for instance, mt does  not
31       lead  to  the  desired result: the tape is rewound after the mt command
32       and the next command starts from the beginning of the tape).
33
34       Within each group, four minor numbers are available to  define  devices
35       with different characteristics (block size, compression, density, etc.)
36       When the system starts up, only the  first  device  is  available.  The
37       other  three are activated when the default characteristics are defined
38       (see below). (By changing compile-time constants,  it  is  possible  to
39       change  the  balance  between the maximum number of tape drives and the
40       number of minor numbers for each drive. The default  allocation  allows
41       control  of 32 tape drives.  For instance, it is possible to control up
42       to 64 tape drives with two minor numbers for different options.)
43
44       Devices are typically created by:
45              mknod -m 666 /dev/st0 c 9 0
46              mknod -m 666 /dev/st0l c 9 32
47              mknod -m 666 /dev/st0m c 9 64
48              mknod -m 666 /dev/st0a c 9 96
49              mknod -m 666 /dev/nst0 c 9 128
50              mknod -m 666 /dev/nst0l c 9 160
51              mknod -m 666 /dev/nst0m c 9 192
52              mknod -m 666 /dev/nst0a c 9 224
53
54       There is no corresponding block device.
55
56       The driver uses an internal buffer that has to be large enough to  hold
57       at least one tape block. In kernels before 2.1.121, the buffer is allo‐
58       cated as one contiguous block.  This  limits  the  block  size  to  the
59       largest  contiguous  block  of memory the kernel allocator can provide.
60       The limit is currently 128 kB for 32-bit architectures and 256  kB  for
61       64-bit  architectures. In newer kernels the driver allocates the buffer
62       in several parts if necessary. By default, the maximum number of  parts
63       is  16.  This  means that the maximum block size is very large (2 MB if
64       allocation of 16 blocks of 128 kB succeeds).
65
66       The driver's internal buffer size is determined by a compile-time  con‐
67       stant  which  can be overridden with a kernel startup option.  In addi‐
68       tion to this, the driver tries to allocate a larger temporary buffer at
69       run-time if necessary. However, run-time allocation of large contiguous
70       blocks of memory may fail and it is advisable not to rely too  much  on
71       dynamic buffer allocation with kernels older than 2.1.121 (this applies
72       also to demand-loading the driver with kerneld or kmod).
73
74       The driver does not specifically support any tape drive brand or model.
75       After  system start-up the tape device options are defined by the drive
76       firmware.  For example, if the drive firmware selects fixed-block mode,
77       the  tape device uses fixed-block mode. The options can be changed with
78       explicit ioctl() calls and remain in effect when the device  is  closed
79       and reopened.  Setting the options affects both the auto-rewind and the
80       non-rewind device.
81
82       Different options can be specified for the different devices within the
83       subgroup  of  four.  The options take effect when the device is opened.
84       For example, the system administrator can define one device that writes
85       in  fixed-block mode with a certain block size, and one which writes in
86       variable-block mode (if the drive supports both modes).
87
88       The driver supports tape partitions if they are supported by the drive.
89       (Note that the tape partitions have nothing to do with disk partitions.
90       A partitioned tape can be seen as  several  logical  tapes  within  one
91       medium.) Partition support has to be enabled with an ioctl().  The tape
92       location is preserved within each partition across  partition  changes.
93       The  partition  used for subsequent tape operations is selected with an
94       ioctl().  The partition switch is executed together with the next  tape
95       operation in order to avoid unnecessary tape movement. The maximum num‐
96       ber of partitions on a tape  is  defined  by  a  compile-time  constant
97       (originally  four).  The  driver  contains an ioctl() that can format a
98       tape with either one or two partitions.
99
100       Device /dev/tape is usually created as a  hard  or  soft  link  to  the
101       default tape device on the system.
102
103       Starting  from  kernel 2.6.2, the driver exports in the sysfs directory
104       /sys/class/scsi_tape the attached devices and some parameters  assigned
105       to the devices.
106

DATA TRANSFER

108       The  driver  supports  operation in both fixed-block mode and variable-
109       block mode (if supported by the drive).  In fixed-block mode the  drive
110       writes blocks of the specified size and the block size is not dependent
111       on the byte counts of the write system calls.  In  variable-block  mode
112       one tape block is written for each write call and the byte count deter‐
113       mines the size of the corresponding tape block. Note that the blocks on
114       the  tape  don't  contain  any information about the writing mode: when
115       reading, the only important thing is to use commands  that  accept  the
116       block sizes on the tape.
117
118       In  variable-block  mode the read byte count does not have to match the
119       tape block size exactly. If the byte count  is  larger  than  the  next
120       block on tape, the driver returns the data and the function returns the
121       actual block size. If the block size is larger than the byte count, the
122       requested  amount  of  data from the start of the block is returned and
123       the rest of the block is discarded.
124
125       In fixed-block mode the read byte counts can be arbitrary if  buffering
126       is  enabled,  or a multiple of the tape block size if buffering is dis‐
127       abled. Kernels before 2.1.121 allow writes with arbitrary byte count if
128       buffering  is  enabled.  In all other cases (kernel before 2.1.121 with
129       buffering disabled or newer kernel) the write byte count must be a mul‐
130       tiple of the tape block size.
131
132       In the 2.6 kernel, the driver tries to use direct transfers between the
133       user buffer and the device. If  this  is  not  possible,  the  driver's
134       internal  buffer  is  used.  The reasons for not using direct transfers
135       include improper alignment of the user buffer (default is 512 bytes but
136       this  can  be changed by the HBA driver), one of more pages of the user
137       buffer not reachable by the SCSI adapter, etc.
138
139       A filemark is automatically written to tape if the last tape  operation
140       before close was a write.
141
142       When a filemark is encountered while reading, the following happens. If
143       there are data remaining in the buffer when the filemark is found,  the
144       buffered  data  is returned. The next read returns zero bytes. The fol‐
145       lowing read returns data from the next file. The end of  recorded  data
146       is signaled by returning zero bytes for two consecutive read calls. The
147       third read returns an error.
148

IOCTLS

150       The driver supports three ioctl() requests.  Requests not recognized by
151       the st driver are passed to the SCSI driver.  The definitions below are
152       from /usr/include/linux/mtio.h:
153
154   MTIOCTOP — Perform a tape operation
155       This request takes an argument of type (struct mtop *).  Not all drives
156       support  all  operations.  The driver returns an EIO error if the drive
157       rejects an operation.
158
159       /* Structure for MTIOCTOP - mag tape op command: */
160       struct mtop {
161           short    mt_op;        /* operations defined below */
162           int    mt_count;    /* how many of them */
163       };
164
165       Magnetic Tape operations for normal tape use:
166       MTBSF         Backward space over mt_count filemarks.
167       MTBSFM        Backward space over mt_count filemarks.   Reposition  the
168                     tape to the EOT side of the last filemark.
169       MTBSR         Backward space over mt_count records (tape blocks).
170       MTBSS         Backward space over mt_count setmarks.
171       MTCOMPRESSION Enable  compression  of  tape  data  within  the drive if
172                     mt_count is non-zero and disable compression if  mt_count
173                     is  zero. This command uses the MODE page 15 supported by
174                     most DATs.
175       MTEOM         Go to the  end  of  the  recorded  media  (for  appending
176                     files).
177       MTERASE       Erase  tape.  With  2.6  kernel,  short  erase (mark tape
178                     empty) is performed if the argument  is  zero.  Otherwise
179                     long erase (erase all) is done.
180       MTFSF         Forward space over mt_count filemarks.
181       MTFSFM        Forward  space  over  mt_count filemarks.  Reposition the
182                     tape to the BOT side of the last filemark.
183       MTFSR         Forward space over mt_count records (tape blocks).
184       MTFSS         Forward space over mt_count setmarks.
185       MTLOAD        Execute the SCSI load command. A special case  is  avail‐
186                     able for some HP autoloaders. If mt_count is the constant
187                     MT_ST_HPLOADER_OFFSET plus a number, the number  is  sent
188                     to the drive to control the autoloader.
189       MTLOCK        Lock the tape drive door.
190       MTMKPART      Format  the  tape into one or two partitions. If mt_count
191                     is non-zero, it gives the size of the first partition and
192                     the  second  partition  contains the rest of the tape. If
193                     mt_count is zero, the tape is formatted into  one  parti‐
194                     tion.  This command is not allowed for a drive unless the
195                     partition  support  is  enabled  for   the   drive   (see
196                     MT_ST_CAN_PARTITIONS below).
197       MTNOP         No  op  —  flushes  the driver's buffer as a side effect.
198                     Should be used before reading status with MTIOCGET.
199       MTOFFL        Rewind and put the drive off line.
200       MTRESET       Reset drive.
201       MTRETEN       Re-tension tape.
202       MTREW         Rewind.
203       MTSEEK        Seek to the tape  block  number  specified  in  mt_count.
204                     This  operation  requires either a SCSI-2 drive that sup‐
205                     ports the LOCATE command (device-specific address)  or  a
206                     Tandberg-compatible   SCSI-1   drive  (Tandberg,  Archive
207                     Viper, Wangtek, ... ).  The block number  should  be  one
208                     that  was  previously returned by MTIOCPOS if device-spe‐
209                     cific addresses are used.
210       MTSETBLK      Set the drive's block length to the  value  specified  in
211                     mt_count.  A block length of zero sets the drive to vari‐
212                     able block size mode.
213       MTSETDENSITY  Set the tape density to the code in mt_count.   The  den‐
214                     sity  codes  supported  by  a drive can be found from the
215                     drive documentation.
216       MTSETPART     The active partition is switched to mt_count.  The parti‐
217                     tions are numbered from zero. This command is not allowed
218                     for a drive unless the partition support is  enabled  for
219                     the drive (see MT_ST_CAN_PARTITIONS below).
220       MTUNLOAD      Execute  the  SCSI  unload  command  (does  not eject the
221                     tape).
222       MTUNLOCK      Unlock the tape drive door.
223       MTWEOF        Write mt_count filemarks.
224       MTWSM         Write mt_count setmarks.
225
226       Magnetic Tape operations for setting of device options  (by  the  supe‐
227       ruser):
228       MTSETDRVBUFFER
229               Set  various drive and driver options according to bits encoded
230               in mt_count.  These consist of the drive's  buffering  mode,  a
231               set  of  Boolean  driver  options,  the buffer write threshold,
232               defaults for the block size and density, and timeouts (only  in
233               kernels  >=  2.1).  A single operation can affect only one item
234               in the list above (the Booleans counted as one item.)
235
236               A value having zeros in the high-order 4 bits will be  used  to
237               set the drive's buffering mode.  The buffering modes are:
238
239                   0   The drive will not report GOOD status on write commands
240                       until the data  blocks  are  actually  written  to  the
241                       medium.
242                   1   The  drive  may report GOOD status on write commands as
243                       soon as all  the  data  has  been  transferred  to  the
244                       drive's internal buffer.
245                   2   The  drive  may report GOOD status on write commands as
246                       soon as (a) all the data has been  transferred  to  the
247                       drive's internal buffer, and (b) all buffered data from
248                       different initiators has been successfully  written  to
249                       the medium.
250
251               To  control  the  write  threshold  the  value in mt_count must
252               include the constant MT_ST_WRITE_THRESHOLD logically ORed  with
253               a  block  count  in the low 28 bits.  The block count refers to
254               1024-byte blocks, not the physical block size on the tape.  The
255               threshold  cannot exceed the driver's internal buffer size (see
256               DESCRIPTION, above).
257
258               To set and clear the Boolean options the value in mt_count must
259               include one of the constants MT_ST_BOOLEANS, MT_ST_SETBOOLEANS,
260               MT_ST_CLEARBOOLEANS, or MT_ST_DEFBOOLEANS logically or'ed  with
261               whatever  combination  of  the  following  options  is desired.
262               Using MT_ST_BOOLEANS the options  can  be  set  to  the  values
263               defined  in  the corresponding bits. With MT_ST_SETBOOLEANS the
264               options can  be  selectively  set  and  with  MT_ST_DEFBOOLEANS
265               selectively cleared.
266
267               The  default  options for a tape device are set with MT_ST_DEF‐
268               BOOLEANS. A non-active tape device (e.g., device with minor  32
269               or  160)  is  activated  when  the  default  options for it are
270               defined the first time. An activated device inherits  from  the
271               device activated at start-up the options not set explicitly.
272
273               The Boolean options are:
274
275               MT_ST_BUFFER_WRITES  (Default: true)
276                      Buffer  all  write  operations  in fixed-block mode.  If
277                      this option is false and the drive uses  a  fixed  block
278                      size,  then  all write operations must be for a multiple
279                      of the block size.  This option must  be  set  false  to
280                      write reliable multi-volume archives.
281               MT_ST_ASYNC_WRITES  (Default: true)
282                      When  this option is true, write operations return imme‐
283                      diately without waiting for the data to  be  transferred
284                      to  the drive if the data fits into the driver's buffer.
285                      The write threshold determines how full the buffer  must
286                      be  before  a  new  SCSI  write  command is issued.  Any
287                      errors reported by the drive will be held until the next
288                      operation.  This option must be set false to write reli‐
289                      able multi-volume archives.
290               MT_ST_READ_AHEAD  (Default: true)
291                      This option causes the driver to provide read  buffering
292                      and  read-ahead  in fixed-block mode.  If this option is
293                      false and the drive uses a fixed block  size,  then  all
294                      read  operations  must  be  for  a multiple of the block
295                      size.
296               MT_ST_TWO_FM  (Default: false)
297                      This option modifies the driver behavior when a file  is
298                      closed.   The  normal  action is to write a single file‐
299                      mark.  If the option is true the driver will  write  two
300                      filemarks and backspace over the second one.
301
302                      Note:  This  option  should not be set true for QIC tape
303                      drives since they are unable to  overwrite  a  filemark.
304                      These  drives detect the end of recorded data by testing
305                      for blank tape rather than  two  consecutive  filemarks.
306                      Most  other  current  drives  also  detect  the  end  of
307                      recorded data and using two filemarks is usually  neces‐
308                      sary  only when interchanging tapes with some other sys‐
309                      tems.
310
311               MT_ST_DEBUGGING  (Default: false)
312                      This option turns on various debugging messages from the
313                      driver  (effective  only if the driver was compiled with
314                      DEBUG defined non-zero).
315               MT_ST_FAST_EOM  (Default: false)
316                      This option  causes  the  MTEOM  operation  to  be  sent
317                      directly to the drive, potentially speeding up the oper‐
318                      ation but causing the driver to lose track of  the  cur‐
319                      rent  file  number  normally  returned  by  the MTIOCGET
320                      request.  If MT_ST_FAST_EOM is  false  the  driver  will
321                      respond  to  an  MTEOM  request  by forward spacing over
322                      files.
323               MT_ST_AUTO_LOCK (Default: false)
324                      When this option is true, the drive door is locked  when
325                      the device is opened and unlocked when it is closed.
326               MT_ST_DEF_WRITES (Default: false)
327                      The  tape  options (block size, mode, compression, etc.)
328                      may change when changing from one  device  linked  to  a
329                      drive to another device linked to the same drive depend‐
330                      ing on how the devices are defined. This option  defines
331                      when  the changes are enforced by the driver using SCSI-
332                      commands and when the drives auto-detection capabilities
333                      are  relied  upon.  If  this option is false, the driver
334                      sends the SCSI-commands immediately when the  device  is
335                      changed.  If  the  option is true, the SCSI-commands are
336                      not sent until a write is requested. In  this  case  the
337                      drive  firmware  is allowed to detect the tape structure
338                      when reading and the SCSI-commands are used only to make
339                      sure  that  a  tape  is written according to the correct
340                      specification.
341               MT_ST_CAN_BSR (Default: false)
342                      When read-ahead is used,  the  tape  must  sometimes  be
343                      spaced  backward to the correct position when the device
344                      is closed and the SCSI command to space  backwards  over
345                      records  is  used  for  this  purpose. Some older drives
346                      can't process this command reliably and this option  can
347                      be  used  to instruct the driver not to use the command.
348                      The end result is that, with read-ahead and  fixed-block
349                      mode,  the tape may not be correctly positioned within a
350                      file when the device is closed.  With  2.6  kernel,  the
351                      default is true for drives supporting SCSI-3.
352               MT_ST_NO_BLKLIMS (Default: false)
353                      Some drives don't accept the READ BLOCK LIMITS SCSI com‐
354                      mand. If this is used, the driver does not use the  com‐
355                      mand. The drawback is that the driver can't check before
356                      sending commands if the selected block size  is  accept‐
357                      able to the drive.
358               MT_ST_CAN_PARTITIONS (Default: false)
359                      This  option  enables  support  for  several  partitions
360                      within a tape. The option applies to all devices  linked
361                      to a drive.
362               MT_ST_SCSI2LOGICAL (Default: false)
363                      This  option  instructs  the  driver  to use the logical
364                      block addresses defined in the SCSI-2 standard when per‐
365                      forming  the  seek and tell operations (both with MTSEEK
366                      and MTIOCPOS commands and when changing tape partition).
367                      Otherwise the device-specific addresses are used.  It is
368                      highly advisable to set this option if  the  drive  sup‐
369                      ports  the  logical  addresses  because  they count also
370                      filemarks. There are some drives that only  support  the
371                      logical block addresses.
372               MT_ST_SYSV (Default: false)
373                      When  this  option  is enabled, the tape devices use the
374                      SystemV semantics. Otherwise the BSD semantics are used.
375                      The  most  important difference between the semantics is
376                      what happens when a device used for reading  is  closed:
377                      in  System  V  semantics the tape is spaced forward past
378                      the next filemark if this has not happened  while  using
379                      the  device.  In  BSD semantics the tape position is not
380                      changed.
381               MT_NO_WAIT (Default: false)
382                      Enables immediate mode (i.e., don't wait for the command
383                      to finish) for some commands (e.g., rewind).
384               EXAMPLE
385                      struct mtop mt_cmd;
386                      mt_cmd.mt_op = MTSETDRVBUFFER;
387                      mt_cmd.mt_count = MT_ST_BOOLEANS |
388                              MT_ST_BUFFER_WRITES |
389                              MT_ST_ASYNC_WRITES;
390                      ioctl(fd, MTIOCTOP, &mt_cmd);
391
392               The   default   block  size  for  a  device  can  be  set  with
393               MT_ST_DEF_BLKSIZE and the default density code can be set  with
394               MT_ST_DEFDENSITY.  The values for the parameters are or'ed with
395               the operation code.
396
397               With kernels 2.1.x and later, the timeout  values  can  be  set
398               with  the subcommand MT_ST_SET_TIMEOUT ORed with the timeout in
399               seconds.  The long timeout (used for rewinds and other commands
400               that may take a long time) can be set with MT_ST_SET_LONG_TIME‐
401               OUT. The kernel defaults are very long to make sure that a suc‐
402               cessful  command  is  not  timed out with any drive. Because of
403               this the driver may seem stuck even if it is only  waiting  for
404               the  timeout.  These commands can be used to set more practical
405               values for a specific drive. The timeouts set  for  one  device
406               apply for all devices linked to the same drive.
407
408               Starting  from kernels 2.4.19 and 2.5.43, the driver supports a
409               status bit which indicates whether the drive requests cleaning.
410               The  method used by the drive to return cleaning information is
411               set using the MT_ST_SEL_CLN subcommand. If the value  is  zero,
412               the  cleaning  bit  is  always  zero.  If the value is one, the
413               TapeAlert data defined in the SCSI-3 standard is used (not  yet
414               implemented).  Values  2-17  are  reserved. If the lowest eight
415               bits are >= 18, bits from the extended sense data are used. The
416               bits  9-16 specify a mask to select the bits to look at and the
417               bits 17-23 specify the bit pattern to look  for.   If  the  bit
418               pattern  is  zero, one or more bits under the mask indicate the
419               cleaning request. If the pattern is non-zero, the pattern  must
420               match the masked sense data byte.
421
422   MTIOCGET — Get status
423       This request takes an argument of type (struct mtget *).
424
425       /* structure for MTIOCGET - mag tape get status command */
426       struct mtget {
427           long    mt_type;
428           long    mt_resid;
429           /* the following registers are device dependent */
430           long    mt_dsreg;
431           long    mt_gstat;
432           long    mt_erreg;
433           /* The next two fields are not always used */
434           daddr_t    mt_fileno;
435           daddr_t    mt_blkno;
436       };
437
438       mt_type    The  header  file  defines  many values for mt_type, but the
439                  current driver reports only  the  generic  types  MT_ISSCSI1
440                  (Generic SCSI-1 tape) and MT_ISSCSI2 (Generic SCSI-2 tape).
441       mt_resid   contains the current tape partition number.
442       mt_dsreg   reports  the drive's current settings for block size (in the
443                  low 24 bits) and density (in the high 8 bits).  These fields
444                  are   defined  by  MT_ST_BLKSIZE_SHIFT,  MT_ST_BLKSIZE_MASK,
445                  MT_ST_DENSITY_SHIFT, and MT_ST_DENSITY_MASK.
446       mt_gstat   reports generic  (device  independent)  status  information.
447                  The  header  file  defines  macros  for testing these status
448                  bits:
449                  GMT_EOF(x): The tape is positioned  just  after  a  filemark
450                      (always false after an MTSEEK operation).
451                  GMT_BOT(x):  The  tape is positioned at the beginning of the
452                      first file (always false after an MTSEEK operation).
453                  GMT_EOT(x): A tape operation has reached the physical End Of
454                      Tape.
455                  GMT_SM(x):  The  tape  is  currently positioned at a setmark
456                      (always false after an MTSEEK operation).
457                  GMT_EOD(x): The tape is positioned at the  end  of  recorded
458                      data.
459                  GMT_WR_PROT(x):  The  drive  is  write-protected.   For some
460                      drives this can also mean that the drive does  not  sup‐
461                      port writing on the current medium type.
462                  GMT_ONLINE(x):  The  last open() found the drive with a tape
463                      in place and ready for operation.
464                  GMT_D_6250(x), GMT_D_1600(x), GMT_D_800(x):  This  “generic”
465                      status  information  reports the current density setting
466                      for 9-track ½" tape drives only.
467                  GMT_DR_OPEN(x): The drive does not have a tape in place.
468                  GMT_IM_REP_EN(x): Immediate report mode. This bit is set  if
469                      there  are  no  guarantees that the data has been physi‐
470                      cally written to the tape when the write  call  returns.
471                      It is set zero only when the driver does not buffer data
472                      and the drive is set not to buffer data.
473                  GMT_CLN(x): The drive has requested cleaning. Implemented in
474                      kernels >= 2.4.19 and 2.5.43.
475       mt_erreg   The  only  field  defined in mt_erreg is the recovered error
476                  count in the low 16 bits (as defined by  MT_ST_SOFTERR_SHIFT
477                  and  MT_ST_SOFTERR_MASK).  Due to inconsistencies in the way
478                  drives report recovered errors,  this  count  is  often  not
479                  maintained (most drives do not by default report soft errors
480                  but this can be changed with a SCSI MODE SELECT command).
481       mt_fileno  reports the current file number (zero-based).  This value is
482                  set to -1 when the file number is unknown (e.g., after MTBSS
483                  or MTSEEK).
484       mt_blkno   reports the block number  (zero-based)  within  the  current
485                  file.   This  value  is  set  to -1 when the block number is
486                  unknown (e.g., after MTBSF, MTBSS, or MTSEEK).
487
488   MTIOCPOS — Get tape position
489       This request takes an argument of type (struct mtpos *) and reports the
490       drive's  notion of the current tape block number, which is not the same
491       as mt_blkno returned by MTIOCGET.  This drive must be  a  SCSI-2  drive
492       that  supports the READ POSITION command (device-specific address) or a
493       Tandberg-compatible SCSI-1 drive (Tandberg, Archive Viper, Wangtek, ...
494       ).
495
496       /* structure for MTIOCPOS - mag tape get position command */
497       struct    mtpos {
498           long     mt_blkno;    /* current block number */
499       };
500
501

RETURN VALUE

503       EIO           The requested operation could not be completed.
504
505       ENOSPC        A write operation could not be completed because the tape
506                     reached end-of-medium.
507
508       ENOMEM        The byte count in read() is smaller than the next  physi‐
509                     cal block on the tape. (Before 2.2.18 and 2.4.0-test6 the
510                     extra bytes have been silently ignored.)
511
512       EACCES        An attempt was made to write or erase  a  write-protected
513                     tape.  (This error is not detected during open().)
514
515       EFAULT        The  command  parameters point to memory not belonging to
516                     the calling process.
517
518       ENXIO         During opening, the tape device does not exist.
519
520       EBUSY         The device is already in use or the driver was unable  to
521                     allocate a buffer.
522
523       EOVERFLOW     An  attempt  was  made to read or write a variable-length
524                     block that is larger than the driver's internal buffer.
525
526       EINVAL        An ioctl() had an illegal argument, or a requested  block
527                     size was illegal.
528
529       ENOSYS        Unknown ioctl().
530
531       EROFS         Open  is  attempted with O_WRONLY or O_RDWR when the tape
532                     in the drive is write-protected.
533

FILES

535       /dev/st*  : the auto-rewind SCSI tape devices
536       /dev/nst* : the non-rewind SCSI tape devices
537

AUTHOR

539       The driver has been written  by  Kai  Mäkisara  (Kai.Makisara@metla.fi)
540       starting  from a driver written by Dwayne Forsyth. Several other people
541       have also contributed to the driver.
542

SEE ALSO

544       mt(1)
545
546       The file README.st or st.txt (kernel >= 2.6) in the kernel sources con‐
547       tains  the  most recent information about the driver and its configura‐
548       tion possibilities.
549

NOTES

551       1. When exchanging data between systems, both systems have to agree  on
552       the  physical  tape block size. The parameters of a drive after startup
553       are often not the ones most operating systems use with  these  devices.
554       Most  systems  use  drives in variable-block mode if the drive supports
555       that mode. This applies to most  modern  drives,  including  DATs,  8mm
556       helical scan drives, DLTs, etc. It may be advisable to use these drives
557       in variable-block mode also in Linux (i.e., use MTSETBLK or MTSETDEFBLK
558       at  system startup to set the mode), at least when exchanging data with
559       a foreign system. The drawback of this is  that  a  fairly  large  tape
560       block  size has to be used to get acceptable data transfer rates on the
561       SCSI bus.
562
563       2. Many programs (e.g., tar) allow the user  to  specify  the  blocking
564       factor  on  the  command  line.  Note that this determines the physical
565       block size on tape only in variable-block mode.
566
567       3. In order to use SCSI tape drives, the basic  SCSI  driver,  a  SCSI-
568       adapter  driver and the SCSI tape driver must be either configured into
569       the kernel or loaded  as  modules.  If  the  SCSI-tape  driver  is  not
570       present, the drive is recognized but the tape support described in this
571       page is not available.
572
573       4. The driver writes error messages to the console/log. The SENSE codes
574       written into some messages are automatically translated to text if ver‐
575       bose SCSI messages are enabled in kernel configuration.
576
577       5. The driver's internal buffering allows  good  throughput  in  fixed-
578       block  mode also with small read() and write() byte counts. With direct
579       transfers this is not possible and may cause a surprise when moving  to
580       the  2.6  kernel.   The  solution is to tell the software to use larger
581       transfers (often telling it to use larger blocks).  If this is not pos‐
582       sible, direct transfers can be disabled.
583
585       Copyright © 1995 Robert K. Nichols.
586       Copyright © 1999-2005 Kai Mäkisara.
587
588       Permission  is  granted  to make and distribute verbatim copies of this
589       manual provided the copyright notice and  this  permission  notice  are
590       preserved  on  all copies.  Additional permissions are contained in the
591       header of the source file.
592
593
594
595Linux 2.0 - 2.6                   2005-03-13                             ST(4)
Impressum