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 logically ORed  with
284               a  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 logically or'ed  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.  MT_ST_ASYNC_WRITES
312                      (Default: true) When this option is true,  write  opera‐
313                      tions return immediately without waiting for the data to
314                      be transferred to the drive if the data  fits  into  the
315                      driver's  buffer.   The  write  threshold determines how
316                      full the buffer must be before a new SCSI write  command
317                      is  issued.   Any  errors  reported by the drive will be
318                      held until the next operation.  This option must be  set
319                      false to write reliable multivolume archives.
320
321               MT_ST_READ_AHEAD (Default: true)
322                      This  option causes the driver to provide read buffering
323                      and read-ahead in fixed-block mode.  If this  option  is
324                      false  and  the  drive uses a fixed block size, then all
325                      read operations must be for  a  multiple  of  the  block
326                      size.
327
328               MT_ST_TWO_FM (Default: false)
329                      This  option modifies the driver behavior when a file is
330                      closed.  The normal action is to write  a  single  file‐
331                      mark.   If  the option is true the driver will write two
332                      filemarks and backspace over the second one.
333
334                      Note: This option should not be set true  for  QIC  tape
335                      drives  since  they  are unable to overwrite a filemark.
336                      These drives detect the end of recorded data by  testing
337                      for  blank  tape  rather than two consecutive filemarks.
338                      Most  other  current  drives  also  detect  the  end  of
339                      recorded  data and using two filemarks is usually neces‐
340                      sary only when interchanging tapes with some other  sys‐
341                      tems.
342
343               MT_ST_DEBUGGING (Default: false)
344                      This option turns on various debugging messages from the
345                      driver (effective only if the driver was  compiled  with
346                      DEBUG defined nonzero).
347
348               MT_ST_FAST_EOM (Default: false)
349                      This  option  causes  the  MTEOM  operation  to  be sent
350                      directly to the drive, potentially speeding up the oper‐
351                      ation  but  causing the driver to lose track of the cur‐
352                      rent file  number  normally  returned  by  the  MTIOCGET
353                      request.   If  MT_ST_FAST_EOM  is  false the driver will
354                      respond to an MTEOM  request  by  forward  spacing  over
355                      files.
356
357               MT_ST_AUTO_LOCK (Default: false)
358                      When  this option is true, the drive door is locked when
359                      the device is opened and unlocked when it is closed.
360
361               MT_ST_DEF_WRITES (Default: false)
362                      The tape options (block size, mode,  compression,  etc.)
363                      may  change  when  changing  from one device linked to a
364                      drive to another device linked to the same drive depend‐
365                      ing on how the devices are defined.  This option defines
366                      when the changes are enforced by the driver using  SCSI-
367                      commands and when the drives auto-detection capabilities
368                      are relied upon.  If this option is  false,  the  driver
369                      sends  the  SCSI-commands immediately when the device is
370                      changed.  If the option is true, the  SCSI-commands  are
371                      not  sent  until a write is requested.  In this case the
372                      drive firmware is allowed to detect the  tape  structure
373                      when reading and the SCSI-commands are used only to make
374                      sure that a tape is written  according  to  the  correct
375                      specification.
376
377               MT_ST_CAN_BSR (Default: false)
378                      When  read-ahead  is  used,  the  tape must sometimes be
379                      spaced backward to the correct position when the  device
380                      is  closed  and the SCSI command to space backwards over
381                      records is used for this  purpose.   Some  older  drives
382                      can't  process this command reliably and this option can
383                      be used to instruct the driver not to use  the  command.
384                      The  end result is that, with read-ahead and fixed-block
385                      mode, the tape may not be correctly positioned within  a
386                      file  when  the  device is closed.  With 2.6 kernel, the
387                      default is true for drives supporting SCSI-3.
388
389               MT_ST_NO_BLKLIMS (Default: false)
390                      Some drives don't accept the READ BLOCK LIMITS SCSI com‐
391                      mand.  If this is used, the driver does not use the com‐
392                      mand.  The drawback  is  that  the  driver  can't  check
393                      before  sending  commands  if the selected block size is
394                      acceptable to the drive.
395
396               MT_ST_CAN_PARTITIONS (Default: false)
397                      This  option  enables  support  for  several  partitions
398                      within a tape.  The option applies to all devices linked
399                      to a drive.
400
401               MT_ST_SCSI2LOGICAL (Default: false)
402                      This option instructs the  driver  to  use  the  logical
403                      block addresses defined in the SCSI-2 standard when per‐
404                      forming the seek and tell operations (both  with  MTSEEK
405                      and MTIOCPOS commands and when changing tape partition).
406                      Otherwise the device-specific addresses are used.  It is
407                      highly  advisable  to  set this option if the drive sup‐
408                      ports the logical  addresses  because  they  count  also
409                      filemarks.   There are some drives that only support the
410                      logical block addresses.
411
412               MT_ST_SYSV (Default: false)
413                      When this option is enabled, the tape  devices  use  the
414                      SystemV  semantics.   Otherwise  the  BSD  semantics are
415                      used.  The most important difference between the  seman‐
416                      tics  is  what happens when a device used for reading is
417                      closed: in System V semantics the tape is spaced forward
418                      past  the  next  filemark if this has not happened while
419                      using the device.  In BSD semantics the tape position is
420                      not changed.
421
422               MT_NO_WAIT (Default: false)
423                      Enables immediate mode (i.e., don't wait for the command
424                      to finish) for some commands (e.g., rewind).
425
426               An example:
427
428                   struct mtop mt_cmd;
429                   mt_cmd.mt_op = MTSETDRVBUFFER;
430                   mt_cmd.mt_count = MT_ST_BOOLEANS |
431                           MT_ST_BUFFER_WRITES | MT_ST_ASYNC_WRITES;
432                   ioctl(fd, MTIOCTOP, mt_cmd);
433
434               The  default  block  size  for  a  device  can  be   set   with
435               MT_ST_DEF_BLKSIZE  and the default density code can be set with
436               MT_ST_DEFDENSITY.  The values for the parameters are or'ed with
437               the operation code.
438
439               With  kernels  2.1.x  and  later, the timeout values can be set
440               with the subcommand MT_ST_SET_TIMEOUT ORed with the timeout  in
441               seconds.  The long timeout (used for rewinds and other commands
442               that may take a long time) can be set with MT_ST_SET_LONG_TIME‐
443               OUT.   The  kernel  defaults  are very long to make sure that a
444               successful command is not timed out with any drive.  Because of
445               this  the  driver may seem stuck even if it is only waiting for
446               the timeout.  These commands can be used to set more  practical
447               values  for  a specific drive.  The timeouts set for one device
448               apply for all devices linked to the same drive.
449
450               Starting from kernels 2.4.19 and 2.5.43, the driver supports  a
451               status bit which indicates whether the drive requests cleaning.
452               The method used by the drive to return cleaning information  is
453               set  using the MT_ST_SEL_CLN subcommand.  If the value is zero,
454               the cleaning bit is always zero.  If  the  value  is  one,  the
455               TapeAlert  data defined in the SCSI-3 standard is used (not yet
456               implemented).  Values 2-17 are reserved.  If the  lowest  eight
457               bits  are  >=  18,  bits from the extended sense data are used.
458               The bits 9-16 specify a mask to select the bits to look at  and
459               the bits 17-23 specify the bit pattern to look for.  If the bit
460               pattern is zero, one or more bits under the mask  indicate  the
461               cleaning  request.  If the pattern is nonzero, the pattern must
462               match the masked sense data byte.
463
464   MTIOCGET — Get status
465       This request takes an argument of type (struct mtget *).
466
467           /* structure for MTIOCGET - mag tape get status command */
468           struct mtget {
469               long     mt_type;
470               long     mt_resid;
471               /* the following registers are device dependent */
472               long     mt_dsreg;
473               long     mt_gstat;
474               long     mt_erreg;
475               /* The next two fields are not always used */
476               daddr_t  mt_fileno;
477               daddr_t  mt_blkno;
478           };
479
480       mt_type    The header file defines many values  for  mt_type,  but  the
481                  current  driver  reports  only  the generic types MT_ISSCSI1
482                  (Generic SCSI-1 tape) and MT_ISSCSI2 (Generic SCSI-2 tape).
483
484       mt_resid   contains the current tape partition number.
485
486       mt_dsreg   reports the drive's current settings for block size (in  the
487                  low 24 bits) and density (in the high 8 bits).  These fields
488                  are  defined  by  MT_ST_BLKSIZE_SHIFT,   MT_ST_BLKSIZE_MASK,
489                  MT_ST_DENSITY_SHIFT, and MT_ST_DENSITY_MASK.
490
491       mt_gstat   reports  generic  (device  independent)  status information.
492                  The header file defines  macros  for  testing  these  status
493                  bits:
494
495                  GMT_EOF(x):  The  tape  is  positioned just after a filemark
496                      (always false after an MTSEEK operation).
497
498                  GMT_BOT(x): The tape is positioned at the beginning  of  the
499                      first file (always false after an MTSEEK operation).
500
501                  GMT_EOT(x): A tape operation has reached the physical End Of
502                      Tape.
503
504                  GMT_SM(x): The tape is currently  positioned  at  a  setmark
505                      (always false after an MTSEEK operation).
506
507                  GMT_EOD(x):  The  tape  is positioned at the end of recorded
508                      data.
509
510                  GMT_WR_PROT(x): The  drive  is  write-protected.   For  some
511                      drives  this  can also mean that the drive does not sup‐
512                      port writing on the current medium type.
513
514                  GMT_ONLINE(x): The last open(2) found the drive with a  tape
515                      in place and ready for operation.
516
517                  GMT_D_6250(x),  GMT_D_1600(x),  GMT_D_800(x): This “generic”
518                      status information reports the current  density  setting
519                      for 9-track ½" tape drives only.
520
521                  GMT_DR_OPEN(x): The drive does not have a tape in place.
522
523                  GMT_IM_REP_EN(x): Immediate report mode.  This bit is set if
524                      there are no guarantees that the data  has  been  physi‐
525                      cally  written  to the tape when the write call returns.
526                      It is set zero only when the driver does not buffer data
527                      and the drive is set not to buffer data.
528
529                  GMT_CLN(x):  The  drive has requested cleaning.  Implemented
530                      in kernels since 2.4.19 and 2.5.43.
531
532       mt_erreg   The only field defined in mt_erreg is  the  recovered  error
533                  count  in the low 16 bits (as defined by MT_ST_SOFTERR_SHIFT
534                  and MT_ST_SOFTERR_MASK.  Due to inconsistencies in  the  way
535                  drives  report  recovered  errors,  this  count is often not
536                  maintained (most drives do not by default report soft errors
537                  but this can be changed with a SCSI MODE SELECT command).
538
539       mt_fileno  reports the current file number (zero-based).  This value is
540                  set to -1 when the file number is unknown (e.g., after MTBSS
541                  or MTSEEK).
542
543       mt_blkno   reports  the  block  number  (zero-based) within the current
544                  file.  This value is set to -1  when  the  block  number  is
545                  unknown (e.g., after MTBSF, MTBSS, or MTSEEK).
546
547   MTIOCPOS — Get tape position
548       This request takes an argument of type (struct mtpos *) and reports the
549       drive's notion of the current tape block number, which is not the  same
550       as  mt_blkno  returned  by MTIOCGET.  This drive must be a SCSI-2 drive
551       that supports the READ POSITION command (device-specific address) or  a
552       Tandberg-compatible SCSI-1 drive (Tandberg, Archive Viper, Wangtek, ...
553       ).
554
555           /* structure for MTIOCPOS - mag tape get position command */
556           struct mtpos {
557               long mt_blkno;    /* current block number */
558           };
559

RETURN VALUE

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

FILES

596       /dev/st*    the auto-rewind SCSI tape devices
597
598       /dev/nst*   the nonrewind SCSI tape devices
599

NOTES

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

SEE ALSO

640       mt(1)
641
642       The  file  drivers/scsi/README.st  or  Documentation/scsi/st.txt
643       (kernel  >=  2.6) in the kernel sources contains the most recent
644       information about the driver and  its  configuration  possibili‐
645       ties.
646

COLOPHON

648       This  page  is  part  of  release  3.25  of  the Linux man-pages
649       project.  A description of the project,  and  information  about
650       reporting  bugs,  can be found at http://www.kernel.org/doc/man-
651       pages/.
652
653
654
655Linux                             2007-12-16                             ST(4)
Impressum