1.\" Copyright (c) 1996 2.\" Mike Pritchard <mpp@FreeBSD.org>. All rights reserved. 3.\" 4.\" Copyright (c) 1983, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)mtio.4 8.1 (Berkeley) 6/5/93 36.\" $FreeBSD: src/share/man/man4/mtio.4,v 1.8.2.6 2001/08/17 13:08:38 ru Exp $ 37.\" 38.Dd February 11, 1996 39.Dt MTIO 4 40.Os 41.Sh NAME 42.Nm mtio 43.Nd FreeBSD magtape interface 44.Sh DESCRIPTION 45The special files 46named 47.Pa /dev/[nr]sa* 48refer to SCSI tape drives, 49which may be attached to the system. 50.Pa /dev/[nr]sa*.ctl 51are control devices that can be used to issue ioctls to the SCSI 52tape driver to set parameters that are required to last beyond the 53unmounting of a tape. 54.Pp 55.Pp 56The rewind devices automatically rewind 57when the last requested read, write or seek has finished, or the end of the tape 58has been reached. 59The letter 60.Ql n 61is usually prepended to 62the name of the no-rewind devices. 63.Pp 64Tapes can be written with either fixed length records or variable length 65records. See 66.Xr sa 4 67for more information. Two end-of-file markers mark the end of a tape, and 68one end-of-file marker marks the end of a tape file. 69If the tape is not to be rewound it is positioned with the 70head in between the two tape marks, where the next write 71will over write the second end-of-file marker. 72.Pp 73All of the magtape devices may be manipulated with the 74.Xr mt 1 75command. 76.Pp 77A number of 78.Xr ioctl 2 79operations are available 80on raw magnetic tape. 81The following definitions are from 82.Aq Pa sys/mtio.h : 83.Bd -literal 84#ifndef _SYS_MTIO_H_ 85#define _SYS_MTIO_H_ 86 87#ifndef _KERNEL 88#include <sys/types.h> 89#endif 90#include <sys/ioccom.h> 91 92/* 93 * Structures and definitions for mag tape io control commands 94 */ 95 96/* structure for MTIOCTOP - mag tape op command */ 97struct mtop { 98 short mt_op; /* operations defined below */ 99 daddr_t mt_count; /* how many of them */ 100}; 101 102/* operations */ 103#define MTWEOF 0 /* write an end-of-file record */ 104#define MTFSF 1 /* forward space file */ 105#define MTBSF 2 /* backward space file */ 106#define MTFSR 3 /* forward space record */ 107#define MTBSR 4 /* backward space record */ 108#define MTREW 5 /* rewind */ 109#define MTOFFL 6 /* rewind and put the drive offline */ 110#define MTNOP 7 /* no operation, sets status only */ 111#define MTCACHE 8 /* enable controller cache */ 112#define MTNOCACHE 9 /* disable controller cache */ 113 114#if defined(__FreeBSD__) 115/* Set block size for device. If device is a variable size dev */ 116/* a non zero parameter will change the device to a fixed block size */ 117/* device with block size set to that of the parameter passed in. */ 118/* Resetting the block size to 0 will restore the device to a variable */ 119/* block size device. */ 120 121#define MTSETBSIZ 10 122 123/* Set density values for device. Sets the value for the opened mode only. */ 124 125#define MTSETDNSTY 11 126 127#define MTERASE 12 /* erase to EOM */ 128#define MTEOD 13 /* Space to EOM */ 129#define MTCOMP 14 /* select compression mode 0=off, 1=def */ 130#define MTRETENS 15 /* re-tension tape */ 131#define MTWSS 16 /* write setmark(s) */ 132#define MTFSS 17 /* forward space setmark */ 133#define MTBSS 18 /* backward space setmark */ 134 135#define MT_COMP_ENABLE 0xffffffff 136#define MT_COMP_DISABLED 0xfffffffe 137#define MT_COMP_UNSUPP 0xfffffffd 138 139/* 140 * Values in mt_dsreg that say what the device is doing 141 */ 142#define MTIO_DSREG_NIL 0 /* Unknown */ 143#define MTIO_DSREG_REST 1 /* Doing Nothing */ 144#define MTIO_DSREG_RBSY 2 /* Communicating with tape (but no motion) */ 145#define MTIO_DSREG_WR 20 /* Writing */ 146#define MTIO_DSREG_FMK 21 /* Writing Filemarks */ 147#define MTIO_DSREG_ZER 22 /* Erasing */ 148#define MTIO_DSREG_RD 30 /* Reading */ 149#define MTIO_DSREG_FWD 40 /* Spacing Forward */ 150#define MTIO_DSREG_REV 41 /* Spacing Reverse */ 151#define MTIO_DSREG_POS 42 /* Hardware Positioning (direction unknown) */ 152#define MTIO_DSREG_REW 43 /* Rewinding */ 153#define MTIO_DSREG_TEN 44 /* Retensioning */ 154#define MTIO_DSREG_UNL 45 /* Unloading */ 155#define MTIO_DSREG_LD 46 /* Loading */ 156 157#endif /* __FreeBSD__ */ 158 159/* structure for MTIOCGET - mag tape get status command */ 160 161struct mtget { 162 short mt_type; /* type of magtape device */ 163/* the following two registers are grossly device dependent */ 164 short mt_dsreg; /* ``drive status'' register */ 165 short mt_erreg; /* ``error'' register */ 166/* end device-dependent registers */ 167 short mt_resid; /* residual count */ 168#if defined (__FreeBSD__) 169 daddr_t mt_blksiz; /* presently operating blocksize */ 170 daddr_t mt_density; /* presently operating density */ 171 u_int32_t mt_comp; /* presently operating compression */ 172 daddr_t mt_blksiz0; /* blocksize for mode 0 */ 173 daddr_t mt_blksiz1; /* blocksize for mode 1 */ 174 daddr_t mt_blksiz2; /* blocksize for mode 2 */ 175 daddr_t mt_blksiz3; /* blocksize for mode 3 */ 176 daddr_t mt_density0; /* density for mode 0 */ 177 daddr_t mt_density1; /* density for mode 1 */ 178 daddr_t mt_density2; /* density for mode 2 */ 179 daddr_t mt_density3; /* density for mode 3 */ 180/* the following are not yet implemented */ 181 u_int32_t mt_comp0; /* compression type for mode 0 */ 182 u_int32_t mt_comp1; /* compression type for mode 1 */ 183 u_int32_t mt_comp2; /* compression type for mode 2 */ 184 u_int32_t mt_comp3; /* compression type for mode 3 */ 185/* end not yet implemented */ 186#endif 187 daddr_t mt_fileno; /* relative file number of current position */ 188 daddr_t mt_blkno; /* relative block number of current position */ 189}; 190 191/* structure for MTIOCERRSTAT - tape get error status command */ 192/* really only supported for SCSI tapes right now */ 193struct scsi_tape_errors { 194 /* 195 * These are latched from the last command that had a SCSI 196 * Check Condition noted for these operations. The act 197 * of issuing an MTIOCERRSTAT unlatches and clears them. 198 */ 199 u_int8_t io_sense[32]; /* Last Sense Data For Data I/O */ 200 u_int32_t io_resid; /* residual count from last Data I/O */ 201 u_int8_t io_cdb[16]; /* Command that Caused the Last Data Sense */ 202 u_int8_t ctl_sense[32]; /* Last Sense Data For Control I/O */ 203 u_int32_t ctl_resid; /* residual count from last Control I/O */ 204 u_int8_t ctl_cdb[16]; /* Command that Caused the Last Control Sense */ 205 /* 206 * These are the read and write cumulative error counters. 207 * (how to reset cumulative error counters is not yet defined). 208 * (not implemented as yet but space is being reserved for them) 209 */ 210 struct { 211 u_int32_t retries; /* total # retries performed */ 212 u_int32_t corrected; /* total # corrections performed */ 213 u_int32_t processed; /* total # corrections succssful */ 214 u_int32_t failures; /* total # corrections/retries failed */ 215 u_int64_t nbytes; /* total # bytes processed */ 216 } wterr, rderr; 217}; 218 219union mterrstat { 220 struct scsi_tape_errors scsi_errstat; 221 char _reserved_padding[256]; 222}; 223 224/* 225 * Constants for mt_type byte. These are the same 226 * for controllers compatible with the types listed. 227 */ 228#define MT_ISTS 0x01 /* TS-11 */ 229#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */ 230#define MT_ISTM 0x03 /* TM11/TE10 Unibus */ 231#define MT_ISMT 0x04 /* TM78/TU78 Massbus */ 232#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */ 233#define MT_ISCPC 0x06 /* SUN */ 234#define MT_ISAR 0x07 /* SUN */ 235#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */ 236#define MT_ISCY 0x09 /* CCI Cipher */ 237#define MT_ISCT 0x0a /* HP 1/4 tape */ 238#define MT_ISFHP 0x0b /* HP 7980 1/2 tape */ 239#define MT_ISEXABYTE 0x0c /* Exabyte */ 240#define MT_ISEXA8200 0x0c /* Exabyte EXB-8200 */ 241#define MT_ISEXA8500 0x0d /* Exabyte EXB-8500 */ 242#define MT_ISVIPER1 0x0e /* Archive Viper-150 */ 243#define MT_ISPYTHON 0x0f /* Archive Python (DAT) */ 244#define MT_ISHPDAT 0x10 /* HP 35450A DAT drive */ 245#define MT_ISMFOUR 0x11 /* M4 Data 1/2 9track drive */ 246#define MT_ISTK50 0x12 /* DEC SCSI TK50 */ 247#define MT_ISMT02 0x13 /* Emulex MT02 SCSI tape controller */ 248 249/* mag tape io control commands */ 250#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ 251#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ 252/* these two do not appear to be used anywhere */ 253#define MTIOCIEOT _IO('m', 3) /* ignore EOT error */ 254#define MTIOCEEOT _IO('m', 4) /* enable EOT error */ 255/* 256 * When more SCSI-3 SSC (streaming device) devices are out there 257 * that support the full 32 byte type 2 structure, we'll have to 258 * rethink these ioctls to support all the entities they haul into 259 * the picture (64 bit blocks, logical file record numbers, etc..). 260 */ 261#define MTIOCRDSPOS _IOR('m', 5, u_int32_t) /* get logical blk addr */ 262#define MTIOCRDHPOS _IOR('m', 6, u_int32_t) /* get hardware blk addr */ 263#define MTIOCSLOCATE _IOW('m', 5, u_int32_t) /* seek to logical blk addr */ 264#define MTIOCHLOCATE _IOW('m', 6, u_int32_t) /* seek to hardware blk addr */ 265#define MTIOCERRSTAT _IOR('m', 7, union mterrstat) /* get tape errors */ 266/* 267 * Set EOT model- argument is number of filemarks to end a tape with. 268 * Note that not all possible values will be accepted. 269 */ 270#define MTIOCSETEOTMODEL _IOW('m', 8, u_int32_t) 271/* Get current EOT model */ 272#define MTIOCGETEOTMODEL _IOR('m', 8, u_int32_t) 273 274#ifndef _KERNEL 275#define DEFTAPE "/dev/nrsa0" 276#endif 277 278#ifdef _KERNEL 279/* 280 * minor device number 281 */ 282 283#define T_UNIT 003 /* unit selection */ 284#define T_NOREWIND 004 /* no rewind on close */ 285#define T_DENSEL 030 /* density select */ 286#define T_800BPI 000 /* select 800 bpi */ 287#define T_1600BPI 010 /* select 1600 bpi */ 288#define T_6250BPI 020 /* select 6250 bpi */ 289#define T_BADBPI 030 /* undefined selection */ 290#endif 291 292#endif /* !_SYS_MTIO_H_ */ 293.Ed 294.Sh FILES 295.Bl -tag -width /dev/[nr]sa* -compact 296.It Pa /dev/[nr]sa* 297.El 298.Sh SEE ALSO 299.Xr mt 1 , 300.Xr tar 1 , 301.Xr sa 4 302.Sh HISTORY 303The 304.Nm 305manual appeared in 306.Bx 4.2 . 307An i386 version first appeared in 308.Fx 2.2 . 309.Sh BUGS 310The status should be returned in a device independent format. 311.Pp 312The special file naming should be redone in a more consistent and 313understandable manner. 314