HP-UX Reference (11i v2 04/09) - 7 Device (Special) Files, 9 General Information, Index (vol 10)
m
mt(7) mt(7)
During a read, the record size is passed back as the number of bytes read, up to the buffer size specified.
Since the minimum read length on a tape device is a complete record (to the next record mark), the
number of bytes ignored (for records longer than the buffer size specified) is available in the
mt_resid
field of the mtget structure via the
MTIOCGET call of ioctl (2). Current restrictions require tape device
application programs to use 2-byte alignment for buffer locations and I/O sizes. To allow for more
stringent future restrictions (4-byte aligned, etc.) and to maximize performance, page alignment is sug-
gested. For example, if the target buffer is contained within a structure, care must be taken that struc-
ture elements before the buffer allow the target buffer to begin on an even address. If need be, placing a
filler integer before the target buffer will insure its location on a 4-byte boundary.
The ascending hierarchy of tape marks is defined as follows: record mark, filemark (EOF), setmark and
EOD (End of Data). Not all devices support all types of tape marks but the positioning within the hierar-
chy holds true. Each type of mark is typically used to contain one or more of the lesser marks.
When spacing over a number of a particular type of tape mark, hierarchically superior marks (except
EOD) do not terminate tape motion and are included in the count. For instance, MTFSR can be used to
pass over record marks and filemarks.
Reading an EOF mark is returned as a successful zero-length read; that is, the data count returned is
zero and the tape is positioned after the EOF, enabling the next read to return the next record.
DDS devices and the 8mm 8505 device also support setmarks , which are used to delineate a group (set)
of files. For the 8mm 8505 setmarks are only supported when the density is set to 8500 plus compression.
Reading a setmark is also returned as a zero-length read. Filemarks, setmarks and EOD can be dis-
tinguished by unique bits in the
mt_gstat field.
Spacing operations (back or forward space, setmark, file or record) position past the object being spaced
to in the direction of motion. For example, back-spacing a file leaves the tape positioned before the file
mark; forward-spacing a file leaves the tape positioned after the file mark. This is consistent with stan-
dard tape usage.
For QIC devices, spacing operations can take a very long time. In the worst case, a space command could
take as much as 2 hours! While this command is in progress, the device is not accessible for any other
commands.
lseek (2) type seeks on a magnetic tape device are ignored. Instead, the ioctl (2) operations below can be
used to position the tape and determine its status.
The header file
<sys/mtio.h> has useful information for tape handling. The following is included
from <sys/mtio.h> and describes the possible tape operations:
/* mag tape I/O control requests */
#define MTIOCTOP _IOW(’m’, 1, struct mtop) /* do mag tape op */
#define MTIOCGET _IOR(’m’, 2, struct mtget) /* get tape status */
/* structure for MTIOCTOP - mag tape op command */
struct mtop {
short mt_op; /* operations defined below */
int32_t mt_count; /* how many of them */
};
/* operations */
#define MTWEOF 0 /* write filemark (end-of-file record) */
#define MTFSF 1 /* forward space file */
#define MTBSF 2 /* backward space file */
#define MTFSR 3 /* forward space record */
#define MTBSR 4 /* backward space record */
#define MTREW 5 /* rewind */
#define MTOFFL 6 /* rewind and put the drive offline (may eject) */
#define MTNOP 7 /* no operation, may set status */
#define MTEOD 8 /* DDS, QIC and 8MM only - seek to end-of-data */
#define MTWSS 9 /* DDS and 8MM only - write setmark(s) */
#define MTFSS 10 /* DDS and 8MM only - space forward setmark(s) */
#define MTBSS 11 /* DDS and 8MM only - space backward setmark(s) */
#define MTSTARTVOL 12 /* Start a new volume (for ATS) */
#define MTENDVOL 13 /* Terminate a volume (for ATS) */
Section 7−−80 Hewlett-Packard Company − 3 − HP-UX 11i Version 2: September 2004