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