/share/man/man4/mtio.4

https://bitbucket.org/freebsd/freebsd-head/ · Forth · 307 lines · 287 code · 20 blank · 0 comment · 26 complexity · 1a2e588219fcb98079dccd5e77db11db MD5 · raw file

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