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