]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - share/man/man4/mtio.4
MFC sa(4) and mt(1) improvements.
[FreeBSD/stable/10.git] / share / man / man4 / mtio.4
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 12, 2015
39 .Dt MTIO 4
40 .Os
41 .Sh NAME
42 .Nm mtio
43 .Nd FreeBSD magtape interface
44 .Sh DESCRIPTION
45 The special files
46 named
47 .Pa /dev/[en]sa*
48 refer to SCSI tape drives,
49 which may be attached to the system.
50 .Pa /dev/sa*.ctl
51 are control devices that can be used to issue ioctls to the SCSI
52 tape driver to set parameters that are required to last beyond the
53 unmounting of a tape.
54 .Pp
55 The rewind devices automatically rewind
56 when the last requested read, write or seek has finished, or the end of the tape
57 has been reached.
58 The letter
59 .Ql n
60 is prepended to
61 the name of the no-rewind devices.
62 The letter
63 .Ql e
64 is prepended to the name of the eject devices.
65 .Pp
66 Tapes can be written with either fixed length records or variable length
67 records.
68 See
69 .Xr sa 4
70 for more information.
71 Two filemarks mark the end of a tape, and
72 one filemark marks the end of a tape file.
73 If the tape is not to be rewound it is positioned with the
74 head in between the two tape marks, where the next write
75 will over write the second end-of-file marker.
76 .Pp
77 All of the magtape devices may be manipulated with the
78 .Xr mt 1
79 command.
80 .Pp
81 A number of
82 .Xr ioctl 2
83 operations are available
84 on raw magnetic tape.
85 The following definitions are from
86 .In sys/mtio.h :
87 .Bd  -literal
88 #ifndef _SYS_MTIO_H_
89 #define _SYS_MTIO_H_
90
91 #ifndef _KERNEL
92 #include <sys/types.h>
93 #endif
94 #include <sys/ioccom.h>
95
96 /*
97  * Structures and definitions for mag tape io control commands
98  */
99
100 /* structure for MTIOCTOP - mag tape op command */
101 struct mtop {
102         short   mt_op;          /* operations defined below */
103         int32_t mt_count;       /* how many of them */
104 };
105
106 /* operations */
107 #define MTWEOF          0       /* write an end-of-file record */
108 #define MTFSF           1       /* forward space file */
109 #define MTBSF           2       /* backward space file */
110 #define MTFSR           3       /* forward space record */
111 #define MTBSR           4       /* backward space record */
112 #define MTREW           5       /* rewind */
113 #define MTOFFL          6       /* rewind and put the drive offline */
114 #define MTNOP           7       /* no operation, sets status only */
115 #define MTCACHE         8       /* enable controller cache */
116 #define MTNOCACHE       9       /* disable controller cache */
117
118 #if defined(__FreeBSD__)
119 /* Set block size for device. If device is a variable size dev          */
120 /* a non zero parameter will change the device to a fixed block size    */
121 /* device with block size set to that of the parameter passed in.       */
122 /* Resetting the block size to 0 will restore the device to a variable  */
123 /* block size device. */
124
125 #define MTSETBSIZ       10
126
127 /* Set density values for device. Sets the value for the opened mode only. */
128
129 #define MTSETDNSTY      11
130
131 #define MTERASE         12      /* erase to EOM */
132 #define MTEOD           13      /* Space to EOM */
133 #define MTCOMP          14      /* select compression mode 0=off, 1=def */
134 #define MTRETENS        15      /* re-tension tape */
135 #define MTWSS           16      /* write setmark(s) */
136 #define MTFSS           17      /* forward space setmark */
137 #define MTBSS           18      /* backward space setmark */
138 #define MTLOAD          19      /* load tape in drive */
139 #define MTWEOFI         20      /* write an end-of-file record without waiting*/
140
141 #define MT_COMP_ENABLE          0xffffffff
142 #define MT_COMP_DISABLED        0xfffffffe
143 #define MT_COMP_UNSUPP          0xfffffffd
144
145 /*
146  * Values in mt_dsreg that say what the device is doing
147  */
148 #define MTIO_DSREG_NIL  0       /* Unknown */
149 #define MTIO_DSREG_REST 1       /* Doing Nothing */
150 #define MTIO_DSREG_RBSY 2       /* Communicating with tape (but no motion) */
151 #define MTIO_DSREG_WR   20      /* Writing */
152 #define MTIO_DSREG_FMK  21      /* Writing Filemarks */
153 #define MTIO_DSREG_ZER  22      /* Erasing */
154 #define MTIO_DSREG_RD   30      /* Reading */
155 #define MTIO_DSREG_FWD  40      /* Spacing Forward */
156 #define MTIO_DSREG_REV  41      /* Spacing Reverse */
157 #define MTIO_DSREG_POS  42      /* Hardware Positioning (direction unknown) */
158 #define MTIO_DSREG_REW  43      /* Rewinding */
159 #define MTIO_DSREG_TEN  44      /* Retensioning */
160 #define MTIO_DSREG_UNL  45      /* Unloading */
161 #define MTIO_DSREG_LD   46      /* Loading */
162
163 #endif  /* __FreeBSD__ */
164
165 /* structure for MTIOCGET - mag tape get status command */
166
167 struct mtget {
168         short   mt_type;        /* type of magtape device */
169 /* the following two registers are grossly device dependent */
170         short   mt_dsreg;       /* ``drive status'' register */
171         short   mt_erreg;       /* ``error'' register */
172 /* end device-dependent registers */
173         /*
174          * Note that the residual count, while maintained, may be
175          * be nonsense because the size of the residual may (greatly)
176          * exceed 32 K-bytes. Use the MTIOCERRSTAT ioctl to get a
177          * more accurate count.
178          */
179         short   mt_resid;       /* residual count */
180 #if defined (__FreeBSD__)
181         int32_t mt_blksiz;      /* presently operating blocksize */
182         int32_t mt_density;     /* presently operating density */
183         uint32_t mt_comp;       /* presently operating compression */
184         int32_t mt_blksiz0;     /* blocksize for mode 0 */
185         int32_t mt_blksiz1;     /* blocksize for mode 1 */
186         int32_t mt_blksiz2;     /* blocksize for mode 2 */
187         int32_t mt_blksiz3;     /* blocksize for mode 3 */
188         int32_t mt_density0;    /* density for mode 0 */
189         int32_t mt_density1;    /* density for mode 1 */
190         int32_t mt_density2;    /* density for mode 2 */
191         int32_t mt_density3;    /* density for mode 3 */
192 /* the following are not yet implemented */
193         uint32_t mt_comp0;      /* compression type for mode 0 */
194         uint32_t mt_comp1;      /* compression type for mode 1 */
195         uint32_t mt_comp2;      /* compression type for mode 2 */
196         uint32_t mt_comp3;      /* compression type for mode 3 */
197 /* end not yet implemented */
198 #endif
199         int32_t mt_fileno;      /* relative file number of current position */
200         int32_t mt_blkno;       /* relative block number of current position */
201 };
202
203 /* structure for MTIOCERRSTAT - tape get error status command */
204 /* really only supported for SCSI tapes right now */
205 struct scsi_tape_errors {
206         /*
207          * These are latched from the last command that had a SCSI
208          * Check Condition noted for these operations. The act
209          * of issuing an MTIOCERRSTAT unlatches and clears them.
210          */
211         uint8_t io_sense[32];   /* Last Sense Data For Data I/O */
212         int32_t io_resid;       /* residual count from last Data I/O */
213         uint8_t io_cdb[16];     /* Command that Caused the Last Data Sense */
214         uint8_t ctl_sense[32];  /* Last Sense Data For Control I/O */
215         int32_t ctl_resid;      /* residual count from last Control I/O */
216         uint8_t ctl_cdb[16];    /* Command that Caused the Last Control Sense */
217         /*
218          * These are the read and write cumulative error counters.
219          * (how to reset cumulative error counters is not yet defined).
220          * (not implemented as yet but space is being reserved for them)
221          */
222         struct {
223                 uint32_t retries;       /* total # retries performed */
224                 uint32_t corrected;     /* total # corrections performed */
225                 uint32_t processed;     /* total # corrections successful */
226                 uint32_t failures;      /* total # corrections/retries failed */
227                 uint64_t nbytes;        /* total # bytes processed */
228         } wterr, rderr;
229 };
230
231 union mterrstat {
232         struct scsi_tape_errors scsi_errstat;
233         char _reserved_padding[256];
234 };
235
236 struct mtrblim {
237         uint32_t granularity;
238         uint32_t min_block_length;
239         uint32_t max_block_length;
240 };
241
242 typedef enum {
243         MT_LOCATE_DEST_OBJECT   = 0x00,
244         MT_LOCATE_DEST_FILE     = 0x01,
245         MT_LOCATE_DEST_SET      = 0x02,
246         MT_LOCATE_DEST_EOD      = 0x03
247 } mt_locate_dest_type;
248
249 typedef enum {
250         MT_LOCATE_BAM_IMPLICIT  = 0x00,
251         MT_LOCATE_BAM_EXPLICIT  = 0x01
252 } mt_locate_bam;
253
254 typedef enum {
255         MT_LOCATE_FLAG_IMMED            = 0x01,
256         MT_LOCATE_FLAG_CHANGE_PART      = 0x02
257 } mt_locate_flags;
258
259 struct mtlocate {
260         mt_locate_flags         flags;
261         mt_locate_dest_type     dest_type;
262         mt_locate_bam           block_address_mode;
263         int64_t                 partition;
264         uint64_t                logical_id;
265         uint8_t                 reserved[64];
266 };
267
268 typedef enum {
269         MT_EXT_GET_NONE,
270         MT_EXT_GET_OK,
271         MT_EXT_GET_NEED_MORE_SPACE,
272         MT_EXT_GET_ERROR
273 } mt_ext_get_status;
274
275 struct mtextget {
276         uint32_t                alloc_len;
277         char                    *status_xml;
278         uint32_t                fill_len;
279         mt_ext_get_status       status;
280         char                    error_str[128];
281         uint8_t                 reserved[64];
282 };
283
284 #define MT_EXT_GET_ROOT_NAME            "mtextget"
285 #define MT_DENSITY_ROOT_NAME            "mtdensity"
286 #define MT_MEDIA_DENSITY_NAME           "media_density"
287 #define MT_DENSITY_REPORT_NAME          "density_report"
288 #define MT_MEDIUM_TYPE_REPORT_NAME      "medium_type_report"
289 #define MT_MEDIA_REPORT_NAME            "media_report"
290 #define MT_DENSITY_ENTRY_NAME           "density_entry"
291
292 #define MT_DENS_WRITE_OK                0x80
293 #define MT_DENS_DUP                     0x40
294 #define MT_DENS_DEFLT                   0x20
295
296
297 #define MT_PARAM_FIXED_STR_LEN  32
298 union mt_param_value {
299         int64_t         value_signed;
300         uint64_t        value_unsigned;
301         char            *value_var_str;
302         char            value_fixed_str[MT_PARAM_FIXED_STR_LEN];
303         uint8_t         reserved[64];
304 };
305
306 typedef enum {
307         MT_PARAM_SET_NONE,
308         MT_PARAM_SET_SIGNED,
309         MT_PARAM_SET_UNSIGNED,
310         MT_PARAM_SET_VAR_STR,
311         MT_PARAM_SET_FIXED_STR
312 } mt_param_set_type;
313
314 typedef enum {
315         MT_PARAM_STATUS_NONE,
316         MT_PARAM_STATUS_OK,
317         MT_PARAM_STATUS_ERROR
318 } mt_param_set_status;
319
320 #define MT_PARAM_VALUE_NAME_LEN 64
321 struct mtparamset {
322         char                    value_name[MT_PARAM_VALUE_NAME_LEN];
323         mt_param_set_type       value_type;
324         int                     value_len;
325         union mt_param_value    value;
326         mt_param_set_status     status;
327         char                    error_str[128];
328 };
329
330 #define MT_PARAM_ROOT_NAME      "mtparamget"
331 #define MT_PROTECTION_NAME      "protection"
332
333 /*
334  * Set a list of parameters.
335  */
336 struct mtsetlist {
337         int num_params;
338         int param_len;
339         struct mtparamset *params;
340 };
341
342 /*
343  * Constants for mt_type byte.  These are the same
344  * for controllers compatible with the types listed.
345  */
346 #define MT_ISTS         0x01            /* TS-11 */
347 #define MT_ISHT         0x02            /* TM03 Massbus: TE16, TU45, TU77 */
348 #define MT_ISTM         0x03            /* TM11/TE10 Unibus */
349 #define MT_ISMT         0x04            /* TM78/TU78 Massbus */
350 #define MT_ISUT         0x05            /* SI TU-45 emulation on Unibus */
351 #define MT_ISCPC        0x06            /* SUN */
352 #define MT_ISAR         0x07            /* SUN */
353 #define MT_ISTMSCP      0x08            /* DEC TMSCP protocol (TU81, TK50) */
354 #define MT_ISCY         0x09            /* CCI Cipher */
355 #define MT_ISCT         0x0a            /* HP 1/4 tape */
356 #define MT_ISFHP        0x0b            /* HP 7980 1/2 tape */
357 #define MT_ISEXABYTE    0x0c            /* Exabyte */
358 #define MT_ISEXA8200    0x0c            /* Exabyte EXB-8200 */
359 #define MT_ISEXA8500    0x0d            /* Exabyte EXB-8500 */
360 #define MT_ISVIPER1     0x0e            /* Archive Viper-150 */
361 #define MT_ISPYTHON     0x0f            /* Archive Python (DAT) */
362 #define MT_ISHPDAT      0x10            /* HP 35450A DAT drive */
363 #define MT_ISMFOUR      0x11            /* M4 Data 1/2 9track drive */
364 #define MT_ISTK50       0x12            /* DEC SCSI TK50 */
365 #define MT_ISMT02       0x13            /* Emulex MT02 SCSI tape controller */
366
367 /* mag tape io control commands */
368 #define MTIOCTOP        _IOW('m', 1, struct mtop)       /* do a mag tape op */
369 #define MTIOCGET        _IOR('m', 2, struct mtget)      /* get tape status */
370 /* these two do not appear to be used anywhere */
371 #define MTIOCIEOT       _IO('m', 3)                     /* ignore EOT error */
372 #define MTIOCEEOT       _IO('m', 4)                     /* enable EOT error */
373 /*
374  * When more SCSI-3 SSC (streaming device) devices are out there
375  * that support the full 32 byte type 2 structure, we'll have to
376  * rethink these ioctls to support all the entities they haul into
377  * the picture (64 bit blocks, logical file record numbers, etc..).
378  */
379 #define MTIOCRDSPOS     _IOR('m', 5, uint32_t)  /* get logical blk addr */
380 #define MTIOCRDHPOS     _IOR('m', 6, uint32_t)  /* get hardware blk addr */
381 #define MTIOCSLOCATE    _IOW('m', 5, uint32_t)  /* seek to logical blk addr */
382 #define MTIOCHLOCATE    _IOW('m', 6, uint32_t)  /* seek to hardware blk addr */
383 #define MTIOCERRSTAT    _IOR('m', 7, union mterrstat)   /* get tape errors */
384 /*
385  * Set EOT model- argument is number of filemarks to end a tape with.
386  * Note that not all possible values will be accepted.
387  */
388 #define MTIOCSETEOTMODEL        _IOW('m', 8, uint32_t)
389 /* Get current EOT model */
390 #define MTIOCGETEOTMODEL        _IOR('m', 8, uint32_t)
391 #define MTIOCRBLIM      _IOR('m', 9, struct mtrblim)    /* get block limits */
392 #define MTIOCEXTLOCATE  _IOW('m', 10, struct mtlocate)  /* seek to position */
393 #define MTIOCEXTGET     _IOWR('m', 11, struct mtextget) /* get tape status */
394 #define MTIOCPARAMGET   _IOWR('m', 12, struct mtextget) /* get tape params */
395 #define MTIOCPARAMSET   _IOWR('m', 13, struct mtparamset) /* set tape params */
396 #define MTIOCSETLIST    _IOWR('m', 14, struct mtsetlist) /* set N params */
397
398 #ifndef _KERNEL
399 #define DEFTAPE "/dev/nsa0"
400 #endif
401
402 #endif /* !_SYS_MTIO_H_ */
403 .Ed
404 .Sh FILES
405 .Bl -tag -width /dev/[en]sa* -compact
406 .It Pa /dev/[en]sa*
407 .El
408 .Sh SEE ALSO
409 .Xr mt 1 ,
410 .Xr tar 1 ,
411 .Xr sa 4
412 .Sh HISTORY
413 The
414 .Nm
415 manual appeared in
416 .Bx 4.2 .
417 An i386 version first appeared in
418 .Fx 2.2 .