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
22       in the minor numbers are assigned sequentially in the order  of  detec‐
23       tion.   In  the 2.6 kernel, the bits above the eight lowermost bits are
24       concatenated to the five lowermost bits to form the tape  number.   The
25       minor numbers can be grouped into two sets of four numbers: the princi‐
26       pal (auto-rewind) minor device numbers, n, and the  “no-rewind”  device
27       numbers,  (n  + 128).  Devices opened using the principal device number
28       will be sent a REWIND command when they  are  closed.   Devices  opened
29       using  the  “no-rewind”  device  number  will not.  (Note that using an
30       auto-rewind device for positioning the tape with, for instance, mt does
31       not  lead  to the desired result: the tape is rewound after the mt com‐
32       mand 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
46           mknod -m 666 /dev/st0 c 9 0
47           mknod -m 666 /dev/st0l c 9 32
48           mknod -m 666 /dev/st0m c 9 64
49           mknod -m 666 /dev/st0a c 9 96
50           mknod -m 666 /dev/nst0 c 9 128
51           mknod -m 666 /dev/nst0l c 9 160
52           mknod -m 666 /dev/nst0m c 9 192
53           mknod -m 666 /dev/nst0a c 9 224
54
55       There is no corresponding block device.
56
57       The driver uses an internal buffer that has to be large enough to  hold
58       at  least  one  tape  block.   In kernels before 2.1.121, the buffer is
59       allocated as one contiguous block.  This limits the block size  to  the
60       largest  contiguous  block  of memory the kernel allocator can provide.
61       The limit is currently 128 kB for 32-bit architectures and 256  kB  for
62       64-bit architectures.  In newer kernels the driver allocates the buffer
63       in several parts if necessary.  By default, the maximum number of parts
64       is  16.   This means that the maximum block size is very large (2 MB if
65       allocation of 16 blocks of 128 kB succeeds).
66
67       The driver's internal buffer size is determined by a compile-time  con‐
68       stant  which  can be overridden with a kernel startup option.  In addi‐
69       tion to this, the driver tries to allocate a larger temporary buffer at
70       run  time if necessary.  However, run-time allocation of large contigu‐
71       ous blocks of memory may fail and it is advisable not to rely too  much
72       on  dynamic  buffer  allocation  with  kernels older than 2.1.121 (this
73       applies also to demand-loading the driver with kerneld or kmod).
74
75       The driver does not specifically support any tape drive brand or model.
76       After  system start-up the tape device options are defined by the drive
77       firmware.  For example, if the drive firmware selects fixed-block mode,
78       the tape device uses fixed-block mode.  The options can be changed with
79       explicit ioctl(2) calls and remain in effect when the device is  closed
80       and reopened.  Setting the options affects both the auto-rewind and the
81       nonrewind device.
82
83       Different options can be specified for the different devices within the
84       subgroup  of  four.  The options take effect when the device is opened.
85       For example, the system administrator can define one device that writes
86       in  fixed-block mode with a certain block size, and one which writes in
87       variable-block mode (if the drive supports both modes).
88
89       The driver supports tape partitions if they are supported by the drive.
90       (Note that the tape partitions have nothing to do with disk partitions.
91       A partitioned tape can be seen as  several  logical  tapes  within  one
92       medium.)   Partition  support  has to be enabled with an ioctl(2).  The
93       tape location is  preserved  within  each  partition  across  partition
94       changes.  The partition used for subsequent tape operations is selected
95       with an ioctl(2).  The partition switch is executed together  with  the
96       next  tape  operation in order to avoid unnecessary tape movement.  The
97       maximum number of partitions on a tape is  defined  by  a  compile-time
98       constant  (originally  four).  The driver contains an ioctl(2) that can
99       format a tape with either one or two partitions.
100
101       Device /dev/tape is usually created as a  hard  or  soft  link  to  the
102       default tape device on the system.
103
104       Starting  from  kernel 2.6.2, the driver exports in the sysfs directory
105       /sys/class/scsi_tape the attached devices and some parameters  assigned
106       to the devices.
107
108   Data transfer
109       The  driver  supports  operation in both fixed-block mode and variable-
110       block mode (if supported by the drive).  In fixed-block mode the  drive
111       writes blocks of the specified size and the block size is not dependent
112       on the byte counts of the write system calls.  In  variable-block  mode
113       one tape block is written for each write call and the byte count deter‐
114       mines the size of the corresponding tape block.  Note that  the  blocks
115       on  the tape don't contain any information about the writing mode: when
116       reading, the only important thing is to use commands  that  accept  the
117       block sizes on the tape.
118
119       In  variable-block  mode the read byte count does not have to match the
120       tape block size exactly.  If the byte count is  larger  than  the  next
121       block on tape, the driver returns the data and the function returns the
122       actual block size.  If the block size is larger than  the  byte  count,
123       the  requested  amount  of data from the start of the block is returned
124       and the rest of the block is discarded.
125
126       In fixed-block mode the read byte counts can be arbitrary if  buffering
127       is  enabled,  or a multiple of the tape block size if buffering is dis‐
128       abled.  Kernels before 2.1.121 allow writes with arbitrary  byte  count
129       if  buffering  is  enabled.   In all other cases (kernel before 2.1.121
130       with buffering disabled or newer kernel) the write byte count must be a
131       multiple of the tape block size.
132
133       In the 2.6 kernel, the driver tries to use direct transfers between the
134       user buffer and the device.  If this  is  not  possible,  the  driver's
135       internal  buffer  is  used.  The reasons for not using direct transfers
136       include improper alignment of the user buffer (default is 512 bytes but
137       this  can  be changed by the HBA driver), one of more pages of the user
138       buffer not reachable by the SCSI adapter, etc.
139
140       A filemark is automatically written to tape if the last tape  operation
141       before close was a write.
142
143       When  a  filemark  is encountered while reading, the following happens.
144       If there are data remaining in the buffer when the filemark  is  found,
145       the  buffered data is returned.  The next read returns zero bytes.  The
146       following read returns data from the next file.  The  end  of  recorded
147       data  is  signaled  by  returning  zero  bytes for two consecutive read
148       calls.  The third read returns an error.
149
150   Ioctls
151       The driver supports three ioctl(2) requests.  Requests  not  recognized
152       by  the st driver are passed to the SCSI driver.  The definitions below
153       are from /usr/include/linux/mtio.h:
154
155   MTIOCTOP — perform a tape operation
156       This request takes an argument of type (struct mtop *).  Not all drives
157       support  all  operations.  The driver returns an EIO error if the drive
158       rejects an operation.
159
160           /* Structure for MTIOCTOP - mag tape op command: */
161           struct mtop {
162               short   mt_op;       /* operations defined below */
163               int     mt_count;    /* how many of them */
164           };
165
166       Magnetic Tape operations for normal tape use:
167
168       MTBSF         Backward space over mt_count filemarks.
169
170       MTBSFM        Backward space over mt_count filemarks.   Reposition  the
171                     tape to the EOT side of the last filemark.
172
173       MTBSR         Backward space over mt_count records (tape blocks).
174
175       MTBSS         Backward space over mt_count setmarks.
176
177       MTCOMPRESSION Enable  compression  of  tape  data  within  the drive if
178                     mt_count is nonzero and disable compression  if  mt_count
179                     is zero.  This command uses the MODE page 15 supported by
180                     most DATs.
181
182       MTEOM         Go to the  end  of  the  recorded  media  (for  appending
183                     files).
184
185       MTERASE       Erase  tape.   With  2.6  kernel,  short erase (mark tape
186                     empty) is performed if the argument is  zero.   Otherwise
187                     long erase (erase all) is done.
188
189       MTFSF         Forward space over mt_count filemarks.
190
191       MTFSFM        Forward  space  over  mt_count filemarks.  Reposition the
192                     tape to the BOT side of the last filemark.
193
194       MTFSR         Forward space over mt_count records (tape blocks).
195
196       MTFSS         Forward space over mt_count setmarks.
197
198       MTLOAD        Execute the SCSI load command.  A special case is  avail‐
199                     able  for  some  HP autoloaders.  If mt_count is the con‐
200                     stant MT_ST_HPLOADER_OFFSET plus a number, the number  is
201                     sent to the drive to control the autoloader.
202
203       MTLOCK        Lock the tape drive door.
204
205       MTMKPART      Format  the tape into one or two partitions.  If mt_count
206                     is nonzero, it gives the size of the first partition  and
207                     the  second  partition contains the rest of the tape.  If
208                     mt_count is zero, the tape is formatted into  one  parti‐
209                     tion.  This command is not allowed for a drive unless the
210                     partition  support  is  enabled  for   the   drive   (see
211                     MT_ST_CAN_PARTITIONS below).
212
213       MTNOP         No  op—flushes  the  driver's  buffer  as  a side effect.
214                     Should be used before reading status with MTIOCGET.
215
216       MTOFFL        Rewind and put the drive off line.
217
218       MTRESET       Reset drive.
219
220       MTRETEN       Re-tension tape.
221
222       MTREW         Rewind.
223
224       MTSEEK        Seek to the tape  block  number  specified  in  mt_count.
225                     This  operation  requires either a SCSI-2 drive that sup‐
226                     ports the LOCATE command (device-specific address)  or  a
227                     Tandberg-compatible   SCSI-1   drive  (Tandberg,  Archive
228                     Viper, Wangtek, ...).  The block  number  should  be  one
229                     that  was  previously returned by MTIOCPOS if device-spe‐
230                     cific addresses are used.
231
232       MTSETBLK      Set the drive's block length to the  value  specified  in
233                     mt_count.  A block length of zero sets the drive to vari‐
234                     able block size mode.
235
236       MTSETDENSITY  Set the tape density to the code in mt_count.   The  den‐
237                     sity  codes  supported  by  a drive can be found from the
238                     drive documentation.
239
240       MTSETPART     The active partition is switched to mt_count.  The parti‐
241                     tions  are  numbered  from  zero.   This  command  is not
242                     allowed for a  drive  unless  the  partition  support  is
243                     enabled for the drive (see MT_ST_CAN_PARTITIONS below).
244
245       MTUNLOAD      Execute  the  SCSI  unload  command  (does  not eject the
246                     tape).
247
248       MTUNLOCK      Unlock the tape drive door.
249
250       MTWEOF        Write mt_count filemarks.
251
252       MTWSM         Write mt_count setmarks.
253
254       Magnetic Tape operations for setting of device options  (by  the  supe‐
255       ruser):
256
257       MTSETDRVBUFFER
258               Set  various drive and driver options according to bits encoded
259               in mt_count.  These consist of the drive's  buffering  mode,  a
260               set  of  Boolean  driver  options,  the buffer write threshold,
261               defaults for the block size and density, and timeouts (only  in
262               kernels 2.1 and later).  A single operation can affect only one
263               item in the list above (the Booleans counted as one item.)
264
265               A value having zeros in the high-order 4 bits will be  used  to
266               set the drive's buffering mode.  The buffering modes are:
267
268                   0   The drive will not report GOOD status on write commands
269                       until the data  blocks  are  actually  written  to  the
270                       medium.
271
272                   1   The  drive  may report GOOD status on write commands as
273                       soon as all  the  data  has  been  transferred  to  the
274                       drive's internal buffer.
275
276                   2   The  drive  may report GOOD status on write commands as
277                       soon as (a) all the data has been  transferred  to  the
278                       drive's internal buffer, and (b) all buffered data from
279                       different initiators has been successfully  written  to
280                       the medium.
281
282               To  control  the  write  threshold  the  value in mt_count must
283               include the constant MT_ST_WRITE_THRESHOLD bitwise ORed with  a
284               block  count  in  the  low  28 bits.  The block count refers to
285               1024-byte blocks, not the physical block size on the tape.  The
286               threshold  cannot exceed the driver's internal buffer size (see
287               DESCRIPTION, above).
288
289               To set and clear the Boolean options the value in mt_count must
290               include one of the constants MT_ST_BOOLEANS, MT_ST_SETBOOLEANS,
291               MT_ST_CLEARBOOLEANS, or  MT_ST_DEFBOOLEANS  bitwise  ORed  with
292               whatever  combination  of  the  following  options  is desired.
293               Using MT_ST_BOOLEANS the options  can  be  set  to  the  values
294               defined  in the corresponding bits.  With MT_ST_SETBOOLEANS the
295               options can  be  selectively  set  and  with  MT_ST_DEFBOOLEANS
296               selectively cleared.
297
298               The  default  options for a tape device are set with MT_ST_DEF‐
299               BOOLEANS.  A nonactive tape device (e.g., device with minor  32
300               or  160)  is  activated  when  the  default  options for it are
301               defined the first time.  An activated device inherits from  the
302               device activated at start-up the options not set explicitly.
303
304               The Boolean options are:
305
306               MT_ST_BUFFER_WRITES (Default: true)
307                      Buffer  all  write  operations  in fixed-block mode.  If
308                      this option is false and the drive uses  a  fixed  block
309                      size,  then  all write operations must be for a multiple
310                      of the block size.  This option must  be  set  false  to
311                      write reliable multivolume archives.
312
313               MT_ST_ASYNC_WRITES (Default: true)
314                      When  this option is true, write operations return imme‐
315                      diately without waiting for the data to  be  transferred
316                      to  the drive if the data fits into the driver's buffer.
317                      The write threshold determines how full the buffer  must
318                      be  before  a  new  SCSI  write  command is issued.  Any
319                      errors reported by the drive will be held until the next
320                      operation.  This option must be set false to write reli‐
321                      able multivolume archives.
322
323               MT_ST_READ_AHEAD (Default: true)
324                      This option causes the driver to provide read  buffering
325                      and  read-ahead  in fixed-block mode.  If this option is
326                      false and the drive uses a fixed block  size,  then  all
327                      read  operations  must  be  for  a multiple of the block
328                      size.
329
330               MT_ST_TWO_FM (Default: false)
331                      This option modifies the driver behavior when a file  is
332                      closed.   The  normal  action is to write a single file‐
333                      mark.  If the option is true the driver will  write  two
334                      filemarks and backspace over the second one.
335
336                      Note:  This  option  should not be set true for QIC tape
337                      drives since they are unable to  overwrite  a  filemark.
338                      These  drives detect the end of recorded data by testing
339                      for blank tape rather than  two  consecutive  filemarks.
340                      Most  other  current  drives  also  detect  the  end  of
341                      recorded data and using two filemarks is usually  neces‐
342                      sary  only when interchanging tapes with some other sys‐
343                      tems.
344
345               MT_ST_DEBUGGING (Default: false)
346                      This option turns on various debugging messages from the
347                      driver  (effective  only if the driver was compiled with
348                      DEBUG defined nonzero).
349
350               MT_ST_FAST_EOM (Default: false)
351                      This option  causes  the  MTEOM  operation  to  be  sent
352                      directly to the drive, potentially speeding up the oper‐
353                      ation but causing the driver to lose track of  the  cur‐
354                      rent  file  number  normally  returned  by  the MTIOCGET
355                      request.  If MT_ST_FAST_EOM is  false  the  driver  will
356                      respond  to  an  MTEOM  request  by forward spacing over
357                      files.
358
359               MT_ST_AUTO_LOCK (Default: false)
360                      When this option is true, the drive door is locked  when
361                      the device is opened and unlocked when it is closed.
362
363               MT_ST_DEF_WRITES (Default: false)
364                      The  tape  options (block size, mode, compression, etc.)
365                      may change when changing from one  device  linked  to  a
366                      drive to another device linked to the same drive depend‐
367                      ing on how the devices are defined.  This option defines
368                      when  the changes are enforced by the driver using SCSI-
369                      commands and when the drives auto-detection capabilities
370                      are  relied  upon.   If this option is false, the driver
371                      sends the SCSI-commands immediately when the  device  is
372                      changed.   If  the option is true, the SCSI-commands are
373                      not sent until a write is requested.  In this  case  the
374                      drive  firmware  is allowed to detect the tape structure
375                      when reading and the SCSI-commands are used only to make
376                      sure  that  a  tape  is written according to the correct
377                      specification.
378
379               MT_ST_CAN_BSR (Default: false)
380                      When read-ahead is used,  the  tape  must  sometimes  be
381                      spaced  backward to the correct position when the device
382                      is closed and the SCSI command to  space  backward  over
383                      records  is  used  for  this purpose.  Some older drives
384                      can't process this command reliably and this option  can
385                      be  used  to instruct the driver not to use the command.
386                      The end result is that, with read-ahead and  fixed-block
387                      mode,  the tape may not be correctly positioned within a
388                      file when the device is closed.  With  2.6  kernel,  the
389                      default is true for drives supporting SCSI-3.
390
391               MT_ST_NO_BLKLIMS (Default: false)
392                      Some drives don't accept the READ BLOCK LIMITS SCSI com‐
393                      mand.  If this is used, the driver does not use the com‐
394                      mand.   The  drawback  is  that  the  driver can't check
395                      before sending commands if the selected  block  size  is
396                      acceptable to the drive.
397
398               MT_ST_CAN_PARTITIONS (Default: false)
399                      This  option  enables  support  for  several  partitions
400                      within a tape.  The option applies to all devices linked
401                      to a drive.
402
403               MT_ST_SCSI2LOGICAL (Default: false)
404                      This  option  instructs  the  driver  to use the logical
405                      block addresses defined in the SCSI-2 standard when per‐
406                      forming  the  seek and tell operations (both with MTSEEK
407                      and MTIOCPOS commands and when changing tape partition).
408                      Otherwise the device-specific addresses are used.  It is
409                      highly advisable to set this option if  the  drive  sup‐
410                      ports  the  logical  addresses  because  they count also
411                      filemarks.  There are some drives that support only  the
412                      logical block addresses.
413
414               MT_ST_SYSV (Default: false)
415                      When  this  option  is enabled, the tape devices use the
416                      SystemV semantics.   Otherwise  the  BSD  semantics  are
417                      used.   The most important difference between the seman‐
418                      tics is what happens when a device used for  reading  is
419                      closed: in System V semantics the tape is spaced forward
420                      past the next filemark if this has  not  happened  while
421                      using the device.  In BSD semantics the tape position is
422                      not changed.
423
424               MT_NO_WAIT (Default: false)
425                      Enables immediate mode (i.e., don't wait for the command
426                      to finish) for some commands (e.g., rewind).
427
428               An example:
429
430                   struct mtop mt_cmd;
431                   mt_cmd.mt_op = MTSETDRVBUFFER;
432                   mt_cmd.mt_count = MT_ST_BOOLEANS |
433                           MT_ST_BUFFER_WRITES | MT_ST_ASYNC_WRITES;
434                   ioctl(fd, MTIOCTOP, mt_cmd);
435
436               The   default   block  size  for  a  device  can  be  set  with
437               MT_ST_DEF_BLKSIZE and the default density code can be set  with
438               MT_ST_DEFDENSITY.  The values for the parameters are or'ed with
439               the operation code.
440
441               With kernels 2.1.x and later, the timeout  values  can  be  set
442               with  the subcommand MT_ST_SET_TIMEOUT ORed with the timeout in
443               seconds.  The long timeout (used for rewinds and other commands
444               that may take a long time) can be set with MT_ST_SET_LONG_TIME‐
445               OUT.  The kernel defaults are very long to  make  sure  that  a
446               successful command is not timed out with any drive.  Because of
447               this the driver may seem stuck even if it is only  waiting  for
448               the  timeout.  These commands can be used to set more practical
449               values for a specific drive.  The timeouts set for  one  device
450               apply for all devices linked to the same drive.
451
452               Starting  from kernels 2.4.19 and 2.5.43, the driver supports a
453               status bit which indicates whether the drive requests cleaning.
454               The  method used by the drive to return cleaning information is
455               set using the MT_ST_SEL_CLN subcommand.  If the value is  zero,
456               the  cleaning  bit  is  always  zero.  If the value is one, the
457               TapeAlert data defined in the SCSI-3 standard is used (not  yet
458               implemented).   Values  2-17 are reserved.  If the lowest eight
459               bits are >= 18, bits from the extended  sense  data  are  used.
460               The  bits 9-16 specify a mask to select the bits to look at and
461               the bits 17-23 specify the bit pattern to look for.  If the bit
462               pattern  is  zero, one or more bits under the mask indicate the
463               cleaning request.  If the pattern is nonzero, the pattern  must
464               match the masked sense data byte.
465
466   MTIOCGET — get status
467       This request takes an argument of type (struct mtget *).
468
469           /* structure for MTIOCGET - mag tape get status command */
470           struct mtget {
471               long     mt_type;
472               long     mt_resid;
473               /* the following registers are device dependent */
474               long     mt_dsreg;
475               long     mt_gstat;
476               long     mt_erreg;
477               /* The next two fields are not always used */
478               daddr_t  mt_fileno;
479               daddr_t  mt_blkno;
480           };
481
482       mt_type    The  header  file  defines  many values for mt_type, but the
483                  current driver reports only  the  generic  types  MT_ISSCSI1
484                  (Generic SCSI-1 tape) and MT_ISSCSI2 (Generic SCSI-2 tape).
485
486       mt_resid   contains the current tape partition number.
487
488       mt_dsreg   reports  the drive's current settings for block size (in the
489                  low 24 bits) and density (in the high 8 bits).  These fields
490                  are   defined  by  MT_ST_BLKSIZE_SHIFT,  MT_ST_BLKSIZE_MASK,
491                  MT_ST_DENSITY_SHIFT, and MT_ST_DENSITY_MASK.
492
493       mt_gstat   reports generic  (device  independent)  status  information.
494                  The  header  file  defines  macros  for testing these status
495                  bits:
496
497                  GMT_EOF(x): The tape is positioned  just  after  a  filemark
498                      (always false after an MTSEEK operation).
499
500                  GMT_BOT(x):  The  tape is positioned at the beginning of the
501                      first file (always false after an MTSEEK operation).
502
503                  GMT_EOT(x): A tape operation has reached the physical End Of
504                      Tape.
505
506                  GMT_SM(x):  The  tape  is  currently positioned at a setmark
507                      (always false after an MTSEEK operation).
508
509                  GMT_EOD(x): The tape is positioned at the  end  of  recorded
510                      data.
511
512                  GMT_WR_PROT(x):  The  drive  is  write-protected.   For some
513                      drives this can also mean that the drive does  not  sup‐
514                      port writing on the current medium type.
515
516                  GMT_ONLINE(x):  The last open(2) found the drive with a tape
517                      in place and ready for operation.
518
519                  GMT_D_6250(x), GMT_D_1600(x), GMT_D_800(x):  This  “generic”
520                      status  information  reports the current density setting
521                      for 9-track ½" tape drives only.
522
523                  GMT_DR_OPEN(x): The drive does not have a tape in place.
524
525                  GMT_IM_REP_EN(x): Immediate report mode.  This bit is set if
526                      there  are  no  guarantees that the data has been physi‐
527                      cally written to the tape when the write  call  returns.
528                      It is set zero only when the driver does not buffer data
529                      and the drive is set not to buffer data.
530
531                  GMT_CLN(x): The drive has requested  cleaning.   Implemented
532                      in kernels since 2.4.19 and 2.5.43.
533
534       mt_erreg   The  only  field  defined in mt_erreg is the recovered error
535                  count in the low 16 bits (as defined by  MT_ST_SOFTERR_SHIFT
536                  and  MT_ST_SOFTERR_MASK.   Due to inconsistencies in the way
537                  drives report recovered errors,  this  count  is  often  not
538                  maintained (most drives do not by default report soft errors
539                  but this can be changed with a SCSI MODE SELECT command).
540
541       mt_fileno  reports the current file number (zero-based).  This value is
542                  set to -1 when the file number is unknown (e.g., after MTBSS
543                  or MTSEEK).
544
545       mt_blkno   reports the block number  (zero-based)  within  the  current
546                  file.   This  value  is  set  to -1 when the block number is
547                  unknown (e.g., after MTBSF, MTBSS, or MTSEEK).
548
549   MTIOCPOS — get tape position
550       This request takes an argument of type (struct mtpos *) and reports the
551       drive's  notion of the current tape block number, which is not the same
552       as mt_blkno returned by MTIOCGET.  This drive must be  a  SCSI-2  drive
553       that  supports the READ POSITION command (device-specific address) or a
554       Tandberg-compatible SCSI-1 drive (Tandberg, Archive Viper, Wangtek, ...
555       ).
556
557           /* structure for MTIOCPOS - mag tape get position command */
558           struct mtpos {
559               long mt_blkno;    /* current block number */
560           };
561

RETURN VALUE

563       EACCES        An attempt was made to write or erase a write-pro‐
564                     tected tape.  (This error is not  detected  during
565                     open(2).)
566
567       EBUSY         The  device  is  already  in use or the driver was
568                     unable to allocate a buffer.
569
570       EFAULT        The command parameters point to memory not belong‐
571                     ing to the calling process.
572
573       EINVAL        An   ioctl(2)   had  an  invalid  argument,  or  a
574                     requested block size was invalid.
575
576       EIO           The requested operation could not be completed.
577
578       ENOMEM        The byte count in read(2) is smaller than the next
579                     physical  block  on  the tape.  (Before 2.2.18 and
580                     2.4.0-test6 the extra  bytes  have  been  silently
581                     ignored.)
582
583       ENOSPC        A  write  operation could not be completed because
584                     the tape reached end-of-medium.
585
586       ENOSYS        Unknown ioctl(2).
587
588       ENXIO         During opening, the tape device does not exist.
589
590       EOVERFLOW     An attempt was made to read or write  a  variable-
591                     length  block  that  is  larger  than the driver's
592                     internal buffer.
593
594       EROFS         Open is attempted with O_WRONLY or O_RDWR when the
595                     tape in the drive is write-protected.
596

FILES

598       /dev/st*    the auto-rewind SCSI tape devices
599
600       /dev/nst*   the nonrewind SCSI tape devices
601

NOTES

603       1.  When  exchanging  data between systems, both systems have to
604           agree on the physical tape block size.  The parameters of  a
605           drive  after  startup  are often not the ones most operating
606           systems use with these devices.  Most systems use drives  in
607           variable-block  mode  if the drive supports that mode.  This
608           applies to most modern drives, including DATs,  8mm  helical
609           scan  drives,  DLTs,  etc.  It may be advisable to use these
610           drives in variable-block  mode  also  in  Linux  (i.e.,  use
611           MTSETBLK  or MTSETDEFBLK at system startup to set the mode),
612           at least when exchanging data with a  foreign  system.   The
613           drawback  of this is that a fairly large tape block size has
614           to be used to get acceptable data transfer rates on the SCSI
615           bus.
616
617       2.  Many  programs  (e.g., tar(1)) allow the user to specify the
618           blocking factor on the command line.  Note that this  deter‐
619           mines the physical block size on tape only in variable-block
620           mode.
621
622       3.  In order to use SCSI tape drives, the basic SCSI  driver,  a
623           SCSI-adapter  driver and the SCSI tape driver must be either
624           configured into the kernel or loaded  as  modules.   If  the
625           SCSI-tape driver is not present, the drive is recognized but
626           the tape support described in this page is not available.
627
628       4.  The driver writes error messages to  the  console/log.   The
629           SENSE  codes  written  into  some messages are automatically
630           translated to text if verbose SCSI messages are  enabled  in
631           kernel configuration.
632
633       5.  The  driver's  internal  buffering allows good throughput in
634           fixed-block mode also with small read(2) and  write(2)  byte
635           counts.   With direct transfers this is not possible and may
636           cause a surprise when moving to the 2.6 kernel.   The  solu‐
637           tion  is to tell the software to use larger transfers (often
638           telling it to use larger blocks).  If this is not  possible,
639           direct transfers can be disabled.
640

SEE ALSO

642       mt(1)
643
644       The  file  drivers/scsi/README.st  or  Documentation/scsi/st.txt
645       (kernel >= 2.6) in the Linux kernel  source  tree  contains  the
646       most  recent  information about the driver and its configuration
647       possibilities
648

COLOPHON

650       This page is  part  of  release  3.53  of  the  Linux  man-pages
651       project.   A  description  of the project, and information about
652       reporting       bugs,       can        be        found        at
653       http://www.kernel.org/doc/man-pages/.
654
655
656
657Linux                             2010-09-04                             ST(4)
Impressum