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

RETURN VALUE

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

FILES

597       /dev/st*    the auto-rewind SCSI tape devices
598
599       /dev/nst*   the non-rewind SCSI tape devices
600

NOTES

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

SEE ALSO

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

COLOPHON

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