[9] | 1 | .TH MTIO 4
|
---|
| 2 | .SH NAME
|
---|
| 3 | mtio \- magnetic tape commands
|
---|
| 4 | .SH SYNOPSIS
|
---|
| 5 | .B "#include <sys/types.h>"
|
---|
| 6 | .br
|
---|
| 7 | .B "#include <sys/mtio.h>"
|
---|
| 8 | .br
|
---|
| 9 | .B "#include <sys/ioctl.h>"
|
---|
| 10 | .SH DESCRIPTION
|
---|
| 11 | .de SP
|
---|
| 12 | .if t .sp 0.4
|
---|
| 13 | .if n .sp
|
---|
| 14 | ..
|
---|
| 15 | The magnetic tape devices described in
|
---|
| 16 | .BR sd (4)
|
---|
| 17 | may be sent commands or queried for their status using the following ioctl
|
---|
| 18 | calls:
|
---|
| 19 | .PP
|
---|
| 20 | .RS
|
---|
| 21 | .BR ioctl ( \fIfd ,
|
---|
| 22 | .BR MTIOCTOP ,
|
---|
| 23 | .RB & "struct mtop" )
|
---|
| 24 | .br
|
---|
| 25 | .BR ioctl ( \fIfd ,
|
---|
| 26 | .BR MTIOCGET ,
|
---|
| 27 | .RB & "struct mtget" )
|
---|
| 28 | .RE
|
---|
| 29 | .PP
|
---|
| 30 | The struct mtop, struct mtget and associated definitions are defined in
|
---|
| 31 | <sys/mtio.h> as follows:
|
---|
| 32 | .PP
|
---|
| 33 | .nf
|
---|
| 34 |
|
---|
| 35 | /* Tape operations: ioctl(fd, MTIOCTOP, &struct mtop) */
|
---|
| 36 |
|
---|
| 37 | .ta +4n +7n +15n
|
---|
| 38 | struct mtop {
|
---|
| 39 | short mt_op; /* Operation (MTWEOF, etc.) */
|
---|
| 40 | int mt_count; /* Repeat count. */
|
---|
| 41 | };
|
---|
| 42 |
|
---|
| 43 | .ta +17n +5n
|
---|
| 44 | #define MTWEOF 0 /* Write End-Of-File Marker */
|
---|
| 45 | #define MTFSF 1 /* Forward Space File mark */
|
---|
| 46 | #define MTBSF 2 /* Backward Space File mark */
|
---|
| 47 | #define MTFSR 3 /* Forward Space Record */
|
---|
| 48 | #define MTBSR 4 /* Backward Space Record */
|
---|
| 49 | #define MTREW 5 /* Rewind tape */
|
---|
| 50 | #define MTOFFL 6 /* Rewind and take Offline */
|
---|
| 51 | #define MTNOP 7 /* No-Operation, set status only */
|
---|
| 52 | #define MTRETEN 8 /* Retension (completely wind and rewind) */
|
---|
| 53 | #define MTERASE 9 /* Erase the tape and rewind */
|
---|
| 54 | #define MTEOM 10 /* Position at End-Of-Media */
|
---|
| 55 | #define MTMODE 11 /* Select tape density */
|
---|
| 56 | #define MTBLKZ 12 /* Select tape block size */
|
---|
| 57 |
|
---|
| 58 | /* Tape status: ioctl(fd, MTIOCGET, &struct mtget) */
|
---|
| 59 |
|
---|
| 60 | .ta +4n +7n +15n
|
---|
| 61 | struct mtget {
|
---|
| 62 | short mt_type; /* Type of tape device. */
|
---|
| 63 |
|
---|
| 64 | /* Device dependent "registers". */
|
---|
| 65 | short mt_dsreg; /* Drive status register. */
|
---|
| 66 | short mt_erreg; /* Error register. */
|
---|
| 67 |
|
---|
| 68 | /* Misc info. */
|
---|
| 69 | off_t mt_resid; /* Residual count. */
|
---|
| 70 | off_t mt_fileno; /* Current File Number. */
|
---|
| 71 | off_t mt_blkno; /* Current Block Number within file. */
|
---|
| 72 | off_t mt_blksize; /* Current block size. */
|
---|
| 73 | };
|
---|
| 74 |
|
---|
| 75 | .fi
|
---|
| 76 | .PP
|
---|
| 77 | See
|
---|
| 78 | .BR mt (1)
|
---|
| 79 | for a detailed description on what each operation does. The mt_type field
|
---|
| 80 | is always zero, there is no use for it yet. Mt_dsreg is 0 (OK), 1 (Error),
|
---|
| 81 | or 2 (EOF encountered.) Mt_erreg holds the SCSI sense key of the last
|
---|
| 82 | operation. Mt_blksize is the current tape block size in bytes, zero if the
|
---|
| 83 | block size is variable.
|
---|
| 84 | .PP
|
---|
| 85 | Note that one can issue these commands on a file descriptor that is in use
|
---|
| 86 | to read or write data, something that
|
---|
| 87 | .B mt
|
---|
| 88 | can't do. So you can add eof markers in the middle of an output stream,
|
---|
| 89 | or get the status of a device before a rewind-on-close tape rewinds.
|
---|
| 90 | .PP
|
---|
| 91 | The driver will automatically add an end of file marker to a tape that is
|
---|
| 92 | written to if you execute a space command. If you write eof markers
|
---|
| 93 | yourself then the driver will not add one extra on close.
|
---|
| 94 | .SH "SEE ALSO"
|
---|
| 95 | .BR mt (1),
|
---|
| 96 | .BR sd (4).
|
---|
| 97 | .SH AUTHOR
|
---|
| 98 | Kees J. Bot (kjb@cs.vu.nl)
|
---|