SYNOPSIS

DESCRIPTION

The st driver provides the interface to a variety of SCSI
tape devices. Currently, the driver takes control of all
detected devices of type sequential-access. The st driver
uses major device number 9.
Each device uses two minor device numbers: a principal
minor device number, n, assigned sequentially in order of
detection, and a no-rewind device number, Devices opened
using the principal device number will be sent a REWIND com-
mand when they are closed. Devices opened using the no-
rewind device number will not. Options such as density or
block size are not coded in the minor device number. These
options must be set by explicit ioctl() calls and remain in
effect when the device is closed and reopened.
Devices are typically created by:
mknod -m 660 /dev/st0 c 9 0
mknod -m 660 /dev/st1 c 9 1
mknod -m 660 /dev/nst0 c 9 128
mknod -m 660 /dev/nst1 c 9 129
There is no corresponding block device. The character dev-
ice provides buffering and read-ahead by default and sup-
ports reads and writes of arbitrary size (limited by the
drivers internal buffer size, which defaults to 32768 bytes,
but can be changed either by using a kernel startup option
or by changing a compile-time constant).
Device /dev/tape is usually created as a hard or soft link
to the default tape device on the system.

IOCTLS

The driver supports three ioctl requests. Requests not
recognized by the st driver are passed to the scsi driver.
The definitions below are from <linux/mtio.h>:
MTIOCTOP - Performatapeoperation
This request takes an argument of type (structmtop*). Not
all drives support all operations. The driver returns an
EIO error if the drive rejects an operation.
/* Structure for MTIOCTOP - mag tape op command: */
struct mtop {
short mt_op; /* operations defined below */
int mt_count; /* how many of them */
};
Magnetic Tape operations:
MTBSF Backward space over mt_count filemarks.
MTBSFM Backward space over mt_count filemarks. Repo-
sition the tape to the EOT side of the last
filemark.
MTBSR Backward space over mt_count records (tape
blocks).
MTBSS Backward space over mt_count setmarks.
MTEOM Go to the end of the recorded media (for
appending files).
MTERASE Erase tape.
MTFSF Forward space over mt_count filemarks.
MTFSFM Forward space over mt_count filemarks. Repo-
sition the tape to the BOT side of the last
filemark.
MTFSR Forward space over mt_count records (tape
blocks).
MTFSS Forward space over mt_count setmarks.
MTNOP No op - flushes the drivers buffer as a side
effect. Should be used before reading status
with MTIOCGET.
MTOFFL Rewind and put the drive off line.
MTRESET Reset drive.
MTRETEN Retension tape.
MTREW Rewind.
MTSEEK Seek to the tape block number specified in
mt_count. This operation requires either a
SCSI-2 drive that supports the LOCATE command
(device-specific address) or a Tandberg-
compatible SCSI-1 drive (Tandberg, Archive
Viper, Wangtek, ... ). The block number
should be one that was previously returned by
MTIOCPOS because the number is device-
specific.
MTSETBLK Set the drives block length to the value
specified in mt_count. A block length of zero
sets the drive to variable block size mode.
MTSETDENSITY Set the tape density to the code in mt_count.
Some useful density codes are:
0x00 Implicit 0x11 QIC-525
0x04 QIC-11 0x12 QIC-1350
0x05 QIC-24 0x13 DDS
0x0F QIC-120 0x14 Exabyte EXB-8200
0x10 QIC-150 0x15 Exabyte EXB-8500
MTWEOF Write mt_count filemarks.
MTWSM Write mt_count setmarks.
MTSETDRVBUFFER
Set various drive and driver options according to
bits encoded in mt_count. These consist of the
drives buffering mode, 6 Boolean driver options and
the buffer write threshold. These parameters are
initialized only when the device is first detected.
The settings persist when the device is closed and
reopened. A single operation can affect (a) just
the buffering mode, (b) just the Boolean options, or
(c) just the write threshold.
A value having zeros in the high-order 4 bits will
be used to set the drives buffering mode. The
buffering modes are:
0 The drive will not report GOOD status on
write commands until the data blocks are
actually written to the medium.
1 The drive may report GOOD status on write
commands as soon as all the data has been
transferred to the drives internal buffer.
2 The drive may report GOOD status on write
commands as soon as (a) all the data has
been transferred to the drives internal
buffer, and (b) all buffered data from dif-
ferent initiators has been successfully
written to the medium.
To control the write threshold the value in mt_count
must include the constant MT_ST_WRITE_THRESHOLD log-
ically ORed with a block count in the low 28 bits.
The block count refers to 1024-byte blocks, not the
physical block size on the tape. The threshold can-
not exceed the drivers internal buffer size (see
DESCRIPTION, above).
To set and clear the Boolean options the value in
mt_count must include the constant MT_ST_BOOLEANS
logically ORed with whatever combination of the fol-
lowing options is desired. Any options not speci-
fied will be set false. The Boolean options are:
MT_ST_BUFFER_WRITES (Default: true)
Buffer all write operations. If this option is
false and the drive uses a fixed block size,
then all write operations must be for a multi-
ple of the block size. This option must be set
false to write reliable multi-volume archives.
MT_ST_ASYNC_WRITES (Default: true)
When this options is true write operations
return immediately without waiting for the data
to be transferred to the drive if the data fits
into the drivers buffer. The write threshold
determines how full the buffer must be before a
new SCSI write command is issued. Any errors
reported by the drive will be held until the
next operation. This option must be set false
to write reliable multi-volume archives.
MT_ST_READ_AHEAD (Default: true)
This option causes the driver to provide read
buffering and read-ahead. If this option is
false and the drive uses a fixed block size,
then all read operations must be for a multiple
of the block size.
MT_ST_TWO_FM (Default: false)
This option modifies the driver behavior when a
file is closed. The normal action is to write
a single filemark. If the option is true the
driver will write two filemarks and backspace
over the second one.
Note: This option should not be set true for
QIC tape drives since they are unable to
overwrite a filemark. These drives detect the
end of recorded data by testing for blank tape
rather than two consecutive filemarks.
MT_ST_DEBUGGING (Default: false)
This option turns on various debugging messages
from the driver (effective only if the driver
was compiled with DEBUG defined).
MT_ST_FAST_EOM (Default: false)
This option causes the MTEOM operation to be
sent directly to the drive, potentially speed-
ing up the operation but causing the driver to
lose track of the current file number normally
returned by the MTIOCGET request. If
MT_ST_FAST_EOM is false the driver will respond
to an MTEOM request by forward spacing over
files.
EXAMPLE
structmtopmt_cmd;mt_cmd.mt_op=MTSETDRVBUFFER;mt_cmd.mt_count=MT_ST_BOOLEANS|MT_ST_BUFFER_WRITES|MT_ST_ASYNC_WRITES;ioctl(fd,MTIOCTOP,&mt_cmd));
MTIOCGET - Getstatus
This request takes an argument of type (structmtget*).
The driver returns an EIO error if the drive rejects an
operation.
/* structure for MTIOCGET - mag tape get status command */
struct mtget {
long mt_type;
long mt_resid;
/* the following registers are device dependent */
long mt_dsreg;
long mt_gstat;
long mt_erreg;
/* The next two fields are not always used */
daddr_t mt_fileno;
daddr_t mt_blkno;
};
mt_type The header file defines many values for mt_type,
but the current driver reports only the generic
types MT_ISSCSI1 (Generic SCSI-1 tape) and
MT_ISSCSI2 (Generic SCSI-2 tape).
mt_resid is always zero. (Not implemented for SCSI tape
drives.)
mt_dsreg reports the drives current settings for block
size (in the low 24 bits) and density (in the
high 8 bits). These fields are defined by
MT_ST_BLKSIZE_SHIFT, MT_ST_BLKSIZE_MASK,
MT_ST_DENSITY_SHIFT, and MT_ST_DENSITY_MASK.
mt_gstat reports generic (device independent) status
information. The header file defines macros for
testing these status bits:
GMT_EOF(x): The tape is positioned just after a
filemark (always false after an MTSEEK opera-
tion).
GMT_BOT(x): The tape is positioned at the begin-
ning of the first file (always false after an
MTSEEK operation).
GMT_EOT(x): A tape operation has reached the
physical End Of Tape.
GMT_SM(x): The tape is currently positioned at a
setmark (always false after an MTSEEK opera-
tion).
GMT_EOD(x): The tape is positioned at the end of
recorded data.
GMT_WR_PROT(x): The drive is write-protected.
For some drives this can also mean that the
drive does not support writing on the current
medium type.
GMT_ONLINE(x): The last open() found the drive
with a tape in place and ready for operation.
GMT_D_6250(x), GMT_D_1600(x), GMT_D_800(x): This
generic status information reports the
current density setting for 9-track 1/2" tape
drives only.
GMT_DR_OPEN(x): The drive does not have a tape
in place.
GMT_IM_REP_EN(x): Immediate report mode (not
supported).
mt_erreg The only field defined in mt_erreg is the
recovered error count in the low 16 bits (as
defined by MT_ST_SOFTERR_SHIFT and
MT_ST_SOFTERR_MASK). Due to inconsistencies in
the way drives report recovered errors, this
count is often not maintained.
mt_fileno reports the current file number (zero-based).
This value is set to -1 when the file number is
unknown (e.g., after MTBSS or MTSEEK).
mt_blkno reports the block number (zero-based) within the
current file. This value is set to -1 when the
block number is unknown (e.g., after MTBSF,
MTBSS, or MTSEEK).
MTIOCPOS - Gettapeposition
This request takes an argument of type (structmtpos*) and
reports the drives notion of the current tape block number,
which is not the same as mt_blkno returned by MTIOCGET.
This drive must be a SCSI-2 drive that supports the READ
POSITION command (device-specific address) or a Tandberg-
compatible SCSI-1 drive (Tandberg, Archive Viper, Wangtek,
... ).
/* structure for MTIOCPOS - mag tape get position command */
struct mtpos {
long mt_blkno; /* current block number */
};

RETURN VALUE

EIO The requested operation could not be com-
pleted.
ENOSPC A write operation could not be completed
because the tape reached end-of-medium.
EACCES An attempt was made to write or erase a
write-protected tape. (This error is not
detected during open().)
ENXIO During opening, the tape device does not
exist.
EBUSY The device is already in use or the driver was
unable to allocate a buffer.
EOVERFLOW An attempt was made to read or write a
variable-length block that is larger than the
drivers internal buffer.
EINVAL An ioctl() had an illegal argument, or a
requested block size was illegal.
ENOSYS Unknown ioctl().

COPYRIGHT

Copyright 8c9 1995 Robert K. Nichols.
Permission is granted to make and distribute verbatim copies
of this manual provided the copyright notice and this per-
mission notice are preserved on all copies. Additional per-
missions are contained in the header of the source file.