]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 1995 Robert K. Nichols (Robert.K.Nichols@att.com) |
e2af0daf | 2 | .\" Copyright 1999-2005 Kai Mäkisara (Kai.Makisara@kolumbus.fi) |
fea681da MK |
3 | .\" |
4 | .\" Permission is granted to make and distribute verbatim copies of this | |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
e2af0daf | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
e2af0daf | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
72542487 | 23 | .TH ST 4 2010-09-04 "Linux" "Linux Programmer's Manual" |
fea681da MK |
24 | .SH NAME |
25 | st \- SCSI tape device | |
26 | .SH SYNOPSIS | |
27 | .nf | |
28 | .B #include <sys/mtio.h> | |
29 | .sp | |
30 | .BI "int ioctl(int " fd ", int " request " [, (void *)" arg3 "]);" | |
e40c76c0 MK |
31 | .BI "int ioctl(int " fd ", MTIOCTOP, (struct mtop *)" mt_cmd ); |
32 | .BI "int ioctl(int " fd ", MTIOCGET, (struct mtget *)" mt_status ); | |
33 | .BI "int ioctl(int " fd ", MTIOCPOS, (struct mtpos *)" mt_pos ); | |
fea681da MK |
34 | .fi |
35 | .SH DESCRIPTION | |
36 | The | |
37 | .B st | |
38 | driver provides the interface to a variety of SCSI tape devices. | |
39 | Currently, the driver takes control of all detected devices of type | |
cba04495 | 40 | \(lqsequential-access\(rq. |
fea681da MK |
41 | The |
42 | .B st | |
43 | driver uses major device number 9. | |
44 | .PP | |
c13182ef MK |
45 | Each device uses eight minor device numbers. |
46 | The lowermost five bits | |
fea681da | 47 | in the minor numbers are assigned sequentially in the order of |
c13182ef MK |
48 | detection. |
49 | In the 2.6 kernel, the bits above the eight lowermost bits are | |
e51d6af5 | 50 | concatenated to the five lowermost bits to form the tape number. |
e2af0daf | 51 | The minor numbers can be grouped into |
fea681da MK |
52 | two sets of four numbers: the principal (auto-rewind) minor device numbers, |
53 | .IR n , | |
e2af0daf | 54 | and the \(lqno-rewind\(rq device numbers, |
cba04495 | 55 | .RI ( n " + 128)." |
fea681da | 56 | Devices opened using the principal device number will be sent a |
e40c76c0 MK |
57 | .BR REWIND |
58 | command when they are closed. | |
fea681da MK |
59 | Devices opened using the \(lqno-rewind\(rq device number will not. |
60 | (Note that using an auto-rewind device for positioning the tape with, | |
61 | for instance, mt does not lead to the desired result: the tape is | |
62 | rewound after the mt command and the next command starts from the | |
63 | beginning of the tape). | |
64 | .PP | |
65 | Within each group, four minor numbers are available to define | |
66 | devices with different characteristics (block size, compression, | |
c13182ef MK |
67 | density, etc.) |
68 | When the system starts up, only the first device is available. | |
69 | The other three are activated when the default | |
6387216b MK |
70 | characteristics are defined (see below). |
71 | (By changing compile-time | |
fea681da MK |
72 | constants, it is possible to change the balance between the maximum |
73 | number of tape drives and the number of minor numbers for each | |
c13182ef MK |
74 | drive. |
75 | The default allocation allows control of 32 tape drives. | |
fea681da MK |
76 | For instance, it is possible to control up to 64 tape drives |
77 | with two minor numbers for different options.) | |
78 | .PP | |
79 | Devices are typically created by: | |
a6e2f128 | 80 | .in +4n |
fea681da | 81 | .nf |
cf0a9ace | 82 | |
2bc2f479 MK |
83 | mknod \-m 666 /dev/st0 c 9 0 |
84 | mknod \-m 666 /dev/st0l c 9 32 | |
85 | mknod \-m 666 /dev/st0m c 9 64 | |
86 | mknod \-m 666 /dev/st0a c 9 96 | |
87 | mknod \-m 666 /dev/nst0 c 9 128 | |
88 | mknod \-m 666 /dev/nst0l c 9 160 | |
89 | mknod \-m 666 /dev/nst0m c 9 192 | |
90 | mknod \-m 666 /dev/nst0a c 9 224 | |
fea681da | 91 | .fi |
a6e2f128 | 92 | .in |
fea681da MK |
93 | .PP |
94 | There is no corresponding block device. | |
95 | .PP | |
96 | The driver uses an internal buffer that has to be large enough to hold | |
c13182ef MK |
97 | at least one tape block. |
98 | In kernels before 2.1.121, the buffer is | |
99 | allocated as one contiguous block. | |
100 | This limits the block size to the | |
fea681da | 101 | largest contiguous block of memory the kernel allocator can provide. |
e2af0daf | 102 | The limit is currently 128 kB for 32-bit architectures and |
c13182ef MK |
103 | 256 kB for 64-bit architectures. |
104 | In newer kernels the driver | |
105 | allocates the buffer in several parts if necessary. | |
106 | By default, the | |
107 | maximum number of parts is 16. | |
108 | This means that the maximum block size | |
fea681da MK |
109 | is very large (2 MB if allocation of 16 blocks of 128 kB succeeds). |
110 | .PP | |
111 | The driver's internal buffer size is determined by a compile-time | |
112 | constant which can be overridden with a kernel startup option. | |
113 | In addition to this, the driver tries to allocate a larger temporary | |
cf50118f | 114 | buffer at run time if necessary. |
c13182ef | 115 | However, run-time allocation of large |
fea681da MK |
116 | contiguous blocks of memory may fail and it is advisable not to rely |
117 | too much on dynamic buffer allocation with kernels older than 2.1.121 | |
118 | (this applies also to demand-loading the driver with kerneld or kmod). | |
119 | .PP | |
120 | The driver does not specifically support any tape drive brand or | |
c13182ef MK |
121 | model. |
122 | After system start-up the tape device options are defined by | |
e2af0daf MK |
123 | the drive firmware. |
124 | For example, if the drive firmware selects fixed-block mode, | |
c13182ef MK |
125 | the tape device uses fixed-block mode. |
126 | The options can | |
fea681da | 127 | be changed with explicit |
5e21af3a | 128 | .BR ioctl (2) |
fea681da | 129 | calls and remain in effect when the device is closed and reopened. |
24b74457 | 130 | Setting the options affects both the auto-rewind and the nonrewind |
fea681da MK |
131 | device. |
132 | .PP | |
133 | Different options can be specified for the different devices within | |
c13182ef MK |
134 | the subgroup of four. |
135 | The options take effect when the device is | |
136 | opened. | |
137 | For example, the system administrator can define | |
e2af0daf MK |
138 | one device that writes in fixed-block mode with a certain block size, |
139 | and one which writes in variable-block mode (if the drive supports | |
fea681da MK |
140 | both modes). |
141 | .PP | |
142 | The driver supports | |
143 | .B tape partitions | |
c13182ef MK |
144 | if they are supported by the drive. |
145 | (Note that the tape partitions | |
146 | have nothing to do with disk partitions. | |
147 | A partitioned tape can be | |
148 | seen as several logical tapes within one medium.) | |
149 | Partition support has to be enabled with an | |
5e21af3a | 150 | .BR ioctl (2). |
1e321034 | 151 | The tape |
fea681da MK |
152 | location is preserved within each partition across partition changes. |
153 | The partition used for subsequent tape operations is | |
c13182ef | 154 | selected with an |
5e21af3a | 155 | .BR ioctl (2). |
1e321034 | 156 | The partition switch is executed together with |
fea681da | 157 | the next tape operation in order to avoid unnecessary tape |
c13182ef MK |
158 | movement. |
159 | The maximum number of partitions on a tape is defined by a | |
160 | compile-time constant (originally four). | |
161 | The driver contains an | |
5e21af3a | 162 | .BR ioctl (2) |
1e321034 | 163 | that can format a tape with either one or two partitions. |
fea681da MK |
164 | .PP |
165 | Device | |
8478ee02 | 166 | .I /dev/tape |
fea681da MK |
167 | is usually created as a hard or soft link to the default tape device |
168 | on the system. | |
e2af0daf MK |
169 | .PP |
170 | Starting from kernel 2.6.2, the driver exports in the sysfs directory | |
0daa9e92 | 171 | .I /sys/class/scsi_tape |
e2af0daf | 172 | the attached devices and some parameters assigned to the devices. |
2b2581ee | 173 | .SS "Data Transfer" |
e2af0daf MK |
174 | The driver supports operation in both fixed-block mode and |
175 | variable-block mode (if supported by the drive). | |
176 | In fixed-block mode the drive | |
fea681da | 177 | writes blocks of the specified size and the block size is not |
e2af0daf MK |
178 | dependent on the byte counts of the write system calls. |
179 | In variable-block mode one tape block is written for each write call | |
180 | and the byte | |
c13182ef MK |
181 | count determines the size of the corresponding tape block. |
182 | Note that | |
e2af0daf | 183 | the blocks on the tape don't contain any information about the |
fea681da MK |
184 | writing mode: when reading, the only important thing is to use |
185 | commands that accept the block sizes on the tape. | |
186 | .PP | |
e2af0daf | 187 | In variable-block mode the read byte count does not have to match |
c13182ef MK |
188 | the tape block size exactly. |
189 | If the byte count is larger than the | |
fea681da | 190 | next block on tape, the driver returns the data and the function |
c13182ef MK |
191 | returns the actual block size. |
192 | If the block size is larger than the | |
fea681da MK |
193 | byte count, the requested amount of data from the start of the block |
194 | is returned and the rest of the block is discarded. | |
195 | .PP | |
e2af0daf | 196 | In fixed-block mode the read byte counts can be arbitrary if |
fea681da | 197 | buffering is enabled, or a multiple of the tape block size if |
c13182ef MK |
198 | buffering is disabled. |
199 | Kernels before 2.1.121 allow writes with | |
200 | arbitrary byte count if buffering is enabled. | |
201 | In all other cases | |
fea681da MK |
202 | (kernel before 2.1.121 with buffering disabled or newer kernel) the |
203 | write byte count must be a multiple of the tape block size. | |
204 | .PP | |
e2af0daf | 205 | In the 2.6 kernel, the driver tries to use direct transfers between the user |
c13182ef MK |
206 | buffer and the device. |
207 | If this is not possible, the driver's internal buffer | |
208 | is used. | |
209 | The reasons for not using direct transfers include improper alignment | |
e2af0daf MK |
210 | of the user buffer (default is 512 bytes but this can be changed by the HBA |
211 | driver), one of more pages of the user buffer not reachable by the | |
212 | SCSI adapter, etc. | |
213 | .PP | |
fea681da MK |
214 | A filemark is automatically written to tape if the last tape operation |
215 | before close was a write. | |
216 | .PP | |
217 | When a filemark is encountered while reading, the following | |
c13182ef MK |
218 | happens. |
219 | If there are data remaining in the buffer when the filemark | |
220 | is found, the buffered data is returned. | |
221 | The next read returns zero | |
222 | bytes. | |
223 | The following read returns data from the next file. | |
224 | The end of | |
fea681da | 225 | recorded data is signaled by returning zero bytes for two consecutive |
c13182ef MK |
226 | read calls. |
227 | The third read returns an error. | |
2b2581ee | 228 | .SS Ioctls |
c13182ef | 229 | The driver supports three |
5e21af3a | 230 | .BR ioctl (2) |
1e321034 | 231 | requests. |
fea681da MK |
232 | Requests not recognized by the |
233 | .B st | |
234 | driver are passed to the | |
235 | .B SCSI | |
236 | driver. | |
237 | The definitions below are from | |
8478ee02 | 238 | .IR /usr/include/linux/mtio.h : |
e40c76c0 | 239 | .SS "MTIOCTOP \(em Perform a tape operation" |
fea681da MK |
240 | .PP |
241 | This request takes an argument of type | |
8478ee02 | 242 | .IR "(struct mtop *)" . |
fea681da | 243 | Not all drives support all operations. |
a9b4ebbc MK |
244 | The driver returns an |
245 | .B EIO | |
246 | error if the drive rejects an operation. | |
fea681da | 247 | .PP |
088a639b | 248 | .in +4n |
fea681da | 249 | .nf |
e40c76c0 | 250 | /* Structure for MTIOCTOP \- mag tape op command: */ |
fea681da | 251 | struct mtop { |
cf0a9ace MK |
252 | short mt_op; /* operations defined below */ |
253 | int mt_count; /* how many of them */ | |
fea681da MK |
254 | }; |
255 | .fi | |
e40c76c0 | 256 | .in |
fea681da MK |
257 | .PP |
258 | Magnetic Tape operations for normal tape use: | |
e40c76c0 | 259 | .TP 14 |
e40c76c0 | 260 | .B MTBSF |
fea681da | 261 | Backward space over |
f19a0f03 | 262 | .I mt_count |
fea681da | 263 | filemarks. |
e40c76c0 MK |
264 | .TP |
265 | .B MTBSFM | |
fea681da | 266 | Backward space over |
f19a0f03 | 267 | .I mt_count |
fea681da MK |
268 | filemarks. |
269 | Reposition the tape to the EOT side of the last filemark. | |
e40c76c0 MK |
270 | .TP |
271 | .B MTBSR | |
fea681da | 272 | Backward space over |
f19a0f03 | 273 | .I mt_count |
fea681da | 274 | records (tape blocks). |
e40c76c0 MK |
275 | .TP |
276 | .B MTBSS | |
fea681da | 277 | Backward space over |
f19a0f03 | 278 | .I mt_count |
fea681da | 279 | setmarks. |
e40c76c0 MK |
280 | .TP |
281 | .B MTCOMPRESSION | |
fea681da | 282 | Enable compression of tape data within the drive if |
f19a0f03 | 283 | .I mt_count |
c7094399 | 284 | is nonzero and disable compression if |
f19a0f03 | 285 | .I mt_count |
c13182ef MK |
286 | is zero. |
287 | This command uses the MODE page 15 supported by most DATs. | |
e40c76c0 MK |
288 | .TP |
289 | .B MTEOM | |
fea681da | 290 | Go to the end of the recorded media (for appending files). |
e40c76c0 MK |
291 | .TP |
292 | .B MTERASE | |
c13182ef MK |
293 | Erase tape. |
294 | With 2.6 kernel, short erase (mark tape empty) is performed if the | |
295 | argument is zero. | |
296 | Otherwise long erase (erase all) is done. | |
e40c76c0 MK |
297 | .TP |
298 | .B MTFSF | |
fea681da | 299 | Forward space over |
f19a0f03 | 300 | .I mt_count |
fea681da | 301 | filemarks. |
e40c76c0 MK |
302 | .TP |
303 | .B MTFSFM | |
fea681da | 304 | Forward space over |
f19a0f03 | 305 | .I mt_count |
fea681da MK |
306 | filemarks. |
307 | Reposition the tape to the BOT side of the last filemark. | |
e40c76c0 MK |
308 | .TP |
309 | .B MTFSR | |
fea681da | 310 | Forward space over |
f19a0f03 | 311 | .I mt_count |
fea681da | 312 | records (tape blocks). |
e40c76c0 MK |
313 | .TP |
314 | .B MTFSS | |
fea681da | 315 | Forward space over |
f19a0f03 | 316 | .I mt_count |
fea681da | 317 | setmarks. |
e40c76c0 MK |
318 | .TP |
319 | .B MTLOAD | |
c13182ef MK |
320 | Execute the SCSI load command. |
321 | A special case is available for some HP | |
322 | autoloaders. | |
323 | If | |
f19a0f03 | 324 | .I mt_count |
08362d55 MK |
325 | is the constant |
326 | .B MT_ST_HPLOADER_OFFSET | |
327 | plus a number, the number is | |
fea681da | 328 | sent to the drive to control the autoloader. |
e40c76c0 MK |
329 | .TP |
330 | .B MTLOCK | |
fea681da | 331 | Lock the tape drive door. |
e40c76c0 MK |
332 | .TP |
333 | .B MTMKPART | |
c13182ef MK |
334 | Format the tape into one or two partitions. |
335 | If | |
f19a0f03 | 336 | .I mt_count |
c7094399 | 337 | is nonzero, it gives the size of the first partition and the second |
c13182ef MK |
338 | partition contains the rest of the tape. |
339 | If | |
f19a0f03 | 340 | .I mt_count |
fea681da MK |
341 | is zero, the tape is formatted into one partition. |
342 | This command is not allowed for a drive unless the partition support | |
e40c76c0 MK |
343 | is enabled for the drive (see |
344 | .BR MT_ST_CAN_PARTITIONS | |
345 | below). | |
346 | .TP | |
347 | .B MTNOP | |
df8a3cac | 348 | No op \(em flushes the driver's buffer as a side effect. |
979c2c91 | 349 | Should be used before reading status with |
e40c76c0 MK |
350 | .BR MTIOCGET . |
351 | .TP | |
352 | .B MTOFFL | |
fea681da | 353 | Rewind and put the drive off line. |
e40c76c0 MK |
354 | .TP |
355 | .B MTRESET | |
fea681da | 356 | Reset drive. |
e40c76c0 MK |
357 | .TP |
358 | .B MTRETEN | |
3f1c1b0a | 359 | Re-tension tape. |
e40c76c0 MK |
360 | .TP |
361 | .B MTREW | |
fea681da | 362 | Rewind. |
e40c76c0 MK |
363 | .TP |
364 | .B MTSEEK | |
fea681da | 365 | Seek to the tape block number specified in |
f19a0f03 | 366 | .IR mt_count . |
e40c76c0 MK |
367 | This operation requires either a SCSI-2 drive that supports the |
368 | .B LOCATE | |
fea681da MK |
369 | command (device-specific address) |
370 | or a Tandberg-compatible SCSI-1 drive (Tandberg, Archive | |
e40c76c0 | 371 | Viper, Wangtek, ...). |
fea681da | 372 | The block number should be one that was previously returned by |
e40c76c0 MK |
373 | .BR MTIOCPOS |
374 | if device-specific addresses are used. | |
375 | .TP | |
376 | .B MTSETBLK | |
fea681da | 377 | Set the drive's block length to the value specified in |
f19a0f03 | 378 | .IR mt_count . |
fea681da | 379 | A block length of zero sets the drive to variable block size mode. |
e40c76c0 MK |
380 | .TP |
381 | .B MTSETDENSITY | |
fea681da | 382 | Set the tape density to the code in |
f19a0f03 | 383 | .IR mt_count . |
fea681da MK |
384 | The density codes supported by a drive can be found from the drive |
385 | documentation. | |
e40c76c0 MK |
386 | .TP |
387 | .B MTSETPART | |
fea681da | 388 | The active partition is switched to |
f19a0f03 | 389 | .IR mt_count . |
c13182ef MK |
390 | The partitions are numbered from zero. |
391 | This command is not allowed for | |
fea681da | 392 | a drive unless the partition support is enabled for the drive (see |
e40c76c0 MK |
393 | .B MT_ST_CAN_PARTITIONS |
394 | below). | |
395 | .TP | |
396 | .B MTUNLOAD | |
fea681da | 397 | Execute the SCSI unload command (does not eject the tape). |
e40c76c0 MK |
398 | .TP |
399 | .B MTUNLOCK | |
fea681da | 400 | Unlock the tape drive door. |
e40c76c0 MK |
401 | .TP |
402 | .B MTWEOF | |
e2af0daf | 403 | Write |
f19a0f03 | 404 | .I mt_count |
fea681da | 405 | filemarks. |
e40c76c0 MK |
406 | .TP |
407 | .B MTWSM | |
fea681da | 408 | Write |
f19a0f03 | 409 | .I mt_count |
fea681da | 410 | setmarks. |
fea681da MK |
411 | .PP |
412 | Magnetic Tape operations for setting of device options (by the superuser): | |
e40c76c0 MK |
413 | .TP 8 |
414 | .B MTSETDRVBUFFER | |
fea681da | 415 | Set various drive and driver options according to bits encoded in |
f19a0f03 | 416 | .IR mt_count . |
e2af0daf | 417 | These consist of the drive's buffering mode, a set of Boolean driver |
fea681da | 418 | options, the buffer write threshold, defaults for the block size and |
74aace8a | 419 | density, and timeouts (only in kernels 2.1 and later). |
fea681da MK |
420 | A single operation can affect only one item in the list above (the |
421 | Booleans counted as one item.) | |
fea681da MK |
422 | .IP |
423 | A value having zeros in the high-order 4 bits will be used to set the | |
424 | drive's buffering mode. | |
425 | The buffering modes are: | |
426 | .RS 12 | |
427 | .IP 0 4 | |
979c2c91 | 428 | The drive will not report |
e40c76c0 MK |
429 | .BR GOOD |
430 | status on write commands until the data | |
fea681da | 431 | blocks are actually written to the medium. |
fea681da | 432 | .IP 1 |
979c2c91 | 433 | The drive may report |
e40c76c0 MK |
434 | .BR GOOD |
435 | status on write commands as soon as all the | |
fea681da MK |
436 | data has been transferred to the drive's internal buffer. |
437 | .IP 2 | |
979c2c91 | 438 | The drive may report |
e40c76c0 MK |
439 | .BR GOOD |
440 | status on write commands as soon as (a) all | |
fea681da MK |
441 | the data has been transferred to the drive's internal buffer, and |
442 | (b) all buffered data from different initiators has been successfully | |
443 | written to the medium. | |
fea681da | 444 | .RE |
e40c76c0 | 445 | .IP |
fea681da | 446 | To control the write threshold the value in |
f19a0f03 | 447 | .I mt_count |
fea681da | 448 | must include the constant |
e40c76c0 | 449 | .BR MT_ST_WRITE_THRESHOLD |
87f6d861 | 450 | bitwise ORed with a block count in the low 28 bits. |
fea681da MK |
451 | The block count refers to 1024-byte blocks, not the physical block |
452 | size on the tape. | |
453 | The threshold cannot exceed the driver's internal buffer size (see | |
e40c76c0 | 454 | DESCRIPTION, above). |
fea681da MK |
455 | .IP |
456 | To set and clear the Boolean options | |
457 | the value in | |
f19a0f03 | 458 | .I mt_count |
e40c76c0 MK |
459 | must include one of the constants |
460 | .BR MT_ST_BOOLEANS , | |
979c2c91 | 461 | .BR MT_ST_SETBOOLEANS , |
e40c76c0 MK |
462 | .BR MT_ST_CLEARBOOLEANS , |
463 | or | |
464 | .BR MT_ST_DEFBOOLEANS | |
87f6d861 | 465 | bitwise ORed with |
fea681da | 466 | whatever combination of the following options is desired. |
e40c76c0 MK |
467 | Using |
468 | .BR MT_ST_BOOLEANS | |
469 | the options can be set to the values | |
c13182ef | 470 | defined in the corresponding bits. |
e40c76c0 MK |
471 | With |
472 | .BR MT_ST_SETBOOLEANS | |
979c2c91 | 473 | the options can be selectively set and with |
e40c76c0 | 474 | .BR MT_ST_DEFBOOLEANS |
fea681da MK |
475 | selectively cleared. |
476 | .IP "" | |
477 | The default options for a tape device are set with | |
e40c76c0 | 478 | .BR MT_ST_DEFBOOLEANS . |
24b74457 | 479 | A nonactive tape device (e.g., device with |
fea681da | 480 | minor 32 or 160) is activated when the default options for it are |
c13182ef MK |
481 | defined the first time. |
482 | An activated device inherits from the device | |
fea681da MK |
483 | activated at start-up the options not set explicitly. |
484 | .IP "" | |
485 | The Boolean options are: | |
fea681da | 486 | .RS |
979c2c91 | 487 | .TP |
e40c76c0 | 488 | .BR MT_ST_BUFFER_WRITES " (Default: true)" |
e2af0daf | 489 | Buffer all write operations in fixed-block mode. |
fea681da MK |
490 | If this option is false and the drive uses a fixed block size, then |
491 | all write operations must be for a multiple of the block size. | |
ae03dc66 | 492 | This option must be set false to write reliable multivolume archives. |
ddf54565 YK |
493 | .TP |
494 | .TP | |
e40c76c0 | 495 | .BR MT_ST_ASYNC_WRITES " (Default: true)" |
e2af0daf | 496 | When this option is true, write operations return immediately without |
fea681da MK |
497 | waiting for the data to be transferred to the drive if the data fits |
498 | into the driver's buffer. | |
499 | The write threshold determines how full the buffer must be before a | |
500 | new SCSI write command is issued. | |
501 | Any errors reported by the drive will be held until the next | |
502 | operation. | |
ae03dc66 | 503 | This option must be set false to write reliable multivolume archives. |
e40c76c0 MK |
504 | .TP |
505 | .BR MT_ST_READ_AHEAD " (Default: true)" | |
fea681da | 506 | This option causes the driver to provide read buffering and |
e2af0daf | 507 | read-ahead in fixed-block mode. |
fea681da MK |
508 | If this option is false and the drive uses a fixed block size, then |
509 | all read operations must be for a multiple of the block size. | |
e40c76c0 MK |
510 | .TP |
511 | .BR MT_ST_TWO_FM " (Default: false)" | |
fea681da MK |
512 | This option modifies the driver behavior when a file is closed. |
513 | The normal action is to write a single filemark. | |
514 | If the option is true the driver will write two filemarks and | |
515 | backspace over the second one. | |
fea681da MK |
516 | .IP |
517 | Note: | |
518 | This option should not be set true for QIC tape drives since they are | |
519 | unable to overwrite a filemark. | |
520 | These drives detect the end of recorded data by testing for blank tape | |
c13182ef MK |
521 | rather than two consecutive filemarks. |
522 | Most other current drives also | |
fea681da MK |
523 | detect the end of recorded data and using two filemarks is usually |
524 | necessary only when interchanging tapes with some other systems. | |
e40c76c0 MK |
525 | .TP |
526 | .BR MT_ST_DEBUGGING " (Default: false)" | |
fea681da | 527 | This option turns on various debugging messages from the driver |
e40c76c0 MK |
528 | (effective only if the driver was compiled with |
529 | .B DEBUG | |
c7094399 | 530 | defined nonzero). |
e40c76c0 MK |
531 | .TP |
532 | .BR MT_ST_FAST_EOM " (Default: false)" | |
979c2c91 | 533 | This option causes the |
e40c76c0 MK |
534 | .B MTEOM |
535 | operation to be sent directly to the | |
fea681da MK |
536 | drive, potentially speeding up the operation but causing the driver to |
537 | lose track of the current file number normally returned by the | |
e40c76c0 MK |
538 | .B MTIOCGET |
539 | request. | |
540 | If | |
541 | .B MT_ST_FAST_EOM | |
542 | is false the driver will respond to an | |
543 | .B MTEOM | |
544 | request by forward spacing over files. | |
979c2c91 | 545 | .TP |
e40c76c0 | 546 | .BR MT_ST_AUTO_LOCK " (Default: false)" |
fea681da MK |
547 | When this option is true, the drive door is locked when the device is |
548 | opened and unlocked when it is closed. | |
979c2c91 | 549 | .TP |
e40c76c0 | 550 | .BR MT_ST_DEF_WRITES " (Default: false)" |
fea681da MK |
551 | The tape options (block size, mode, compression, etc.) may change |
552 | when changing from one device linked to a drive to another device | |
553 | linked to the same drive depending on how the devices are | |
c13182ef MK |
554 | defined. |
555 | This option defines when the changes are enforced by the | |
fea681da | 556 | driver using SCSI-commands and when the drives auto-detection |
c13182ef MK |
557 | capabilities are relied upon. |
558 | If this option is false, the driver | |
559 | sends the SCSI-commands immediately when the device is changed. | |
560 | If the | |
fea681da | 561 | option is true, the SCSI-commands are not sent until a write is |
c13182ef MK |
562 | requested. |
563 | In this case the drive firmware is allowed to detect the | |
fea681da MK |
564 | tape structure when reading and the SCSI-commands are used only to |
565 | make sure that a tape is written according to the correct specification. | |
979c2c91 | 566 | .TP |
e40c76c0 | 567 | .BR MT_ST_CAN_BSR " (Default: false)" |
fea681da MK |
568 | When read-ahead is used, the tape must sometimes be spaced backward to the |
569 | correct position when the device is closed and the SCSI command to | |
c13182ef MK |
570 | space backwards over records is used for this purpose. |
571 | Some older | |
fea681da | 572 | drives can't process this command reliably and this option can be used |
c13182ef MK |
573 | to instruct the driver not to use the command. |
574 | The end result is that, | |
e2af0daf | 575 | with read-ahead and fixed-block mode, the tape may not be correctly |
c13182ef MK |
576 | positioned within a file when the device is closed. |
577 | With 2.6 kernel, the | |
e2af0daf | 578 | default is true for drives supporting SCSI-3. |
e40c76c0 MK |
579 | .TP |
580 | .BR MT_ST_NO_BLKLIMS " (Default: false)" | |
581 | Some drives don't accept the | |
582 | .B "READ BLOCK LIMITS" | |
583 | SCSI command. | |
584 | If this is used, the driver does not use the command. | |
c13182ef | 585 | The drawback is |
fea681da MK |
586 | that the driver can't check before sending commands if the selected |
587 | block size is acceptable to the drive. | |
e40c76c0 MK |
588 | .TP |
589 | .BR MT_ST_CAN_PARTITIONS " (Default: false)" | |
fea681da | 590 | This option enables support for several partitions within a |
c13182ef MK |
591 | tape. |
592 | The option applies to all devices linked to a drive. | |
e40c76c0 MK |
593 | .TP |
594 | .BR MT_ST_SCSI2LOGICAL " (Default: false)" | |
fea681da MK |
595 | This option instructs the driver to use the logical block addresses |
596 | defined in the SCSI-2 standard when performing the seek and tell | |
e40c76c0 MK |
597 | operations (both with |
598 | .B MTSEEK | |
599 | and | |
600 | .B MTIOCPOS | |
601 | commands and when changing tape | |
c13182ef MK |
602 | partition). |
603 | Otherwise the device-specific addresses are used. | |
fea681da | 604 | It is highly advisable to set this option if the drive supports the |
c13182ef MK |
605 | logical addresses because they count also filemarks. |
606 | There are some | |
fea681da | 607 | drives that only support the logical block addresses. |
979c2c91 | 608 | .TP |
e40c76c0 | 609 | .BR MT_ST_SYSV " (Default: false)" |
fea681da | 610 | When this option is enabled, the tape devices use the SystemV |
c13182ef MK |
611 | semantics. |
612 | Otherwise the BSD semantics are used. | |
613 | The most important | |
fea681da | 614 | difference between the semantics is what happens when a device used |
80b50848 | 615 | for reading is closed: in System V semantics the tape is spaced forward |
fea681da | 616 | past the next filemark if this has not happened while using the |
c13182ef MK |
617 | device. |
618 | In BSD semantics the tape position is not changed. | |
979c2c91 | 619 | .TP |
e40c76c0 | 620 | .BR MT_NO_WAIT " (Default: false)" |
e2af0daf MK |
621 | Enables immediate mode (i.e., don't wait for the command to finish) for some |
622 | commands (e.g., rewind). | |
e40c76c0 MK |
623 | .PP |
624 | An example: | |
088a639b | 625 | .in +4n |
fea681da | 626 | .nf |
e40c76c0 MK |
627 | |
628 | struct mtop mt_cmd; | |
629 | mt_cmd.mt_op = MTSETDRVBUFFER; | |
630 | mt_cmd.mt_count = MT_ST_BOOLEANS | | |
631 | MT_ST_BUFFER_WRITES | MT_ST_ASYNC_WRITES; | |
632 | ioctl(fd, MTIOCTOP, mt_cmd); | |
fea681da | 633 | .fi |
e40c76c0 | 634 | .in |
fea681da | 635 | .RE |
fea681da MK |
636 | .IP "" |
637 | The default block size for a device can be set with | |
e40c76c0 MK |
638 | .B MT_ST_DEF_BLKSIZE |
639 | and the default density code can be set with | |
640 | .BR MT_ST_DEFDENSITY . | |
c13182ef | 641 | The values for the parameters are or'ed |
fea681da MK |
642 | with the operation code. |
643 | .IP "" | |
644 | With kernels 2.1.x and later, the timeout values can be set with the | |
e40c76c0 MK |
645 | subcommand |
646 | .B MT_ST_SET_TIMEOUT | |
647 | ORed with the timeout in seconds. | |
fea681da MK |
648 | The long timeout (used for rewinds and other commands |
649 | that may take a long time) can be set with | |
e40c76c0 | 650 | .BR MT_ST_SET_LONG_TIMEOUT . |
c13182ef | 651 | The kernel defaults are very long to |
fea681da | 652 | make sure that a successful command is not timed out with any |
c13182ef MK |
653 | drive. |
654 | Because of this the driver may seem stuck even if it is only | |
655 | waiting for the timeout. | |
656 | These commands can be used to set more | |
657 | practical values for a specific drive. | |
658 | The timeouts set for one device | |
fea681da | 659 | apply for all devices linked to the same drive. |
e2af0daf MK |
660 | .IP "" |
661 | Starting from kernels 2.4.19 and 2.5.43, the driver supports a status | |
662 | bit which indicates whether the drive requests cleaning. | |
663 | The method used by the | |
664 | drive to return cleaning information is set using the | |
e40c76c0 MK |
665 | .B MT_ST_SEL_CLN |
666 | subcommand. | |
c13182ef MK |
667 | If the value is zero, the cleaning |
668 | bit is always zero. | |
669 | If the value is one, the TapeAlert data defined | |
670 | in the SCSI-3 standard is used (not yet implemented). | |
671 | Values 2-17 are | |
672 | reserved. | |
673 | If the lowest eight bits are >= 18, bits from the extended | |
674 | sense data are used. | |
675 | The bits 9-16 specify a mask to select the bits | |
e2af0daf MK |
676 | to look at and the bits 17-23 specify the bit pattern to look for. |
677 | If the bit pattern is zero, one or more bits under the mask indicate | |
c13182ef | 678 | the cleaning request. |
c7094399 | 679 | If the pattern is nonzero, the pattern must match |
e2af0daf | 680 | the masked sense data byte. |
e40c76c0 | 681 | .SS "MTIOCGET \(em Get status" |
fea681da MK |
682 | .PP |
683 | This request takes an argument of type | |
8478ee02 | 684 | .IR "(struct mtget *)" . |
fea681da | 685 | .PP |
088a639b | 686 | .in +4n |
fea681da | 687 | .nf |
e40c76c0 | 688 | /* structure for MTIOCGET \- mag tape get status command */ |
fea681da | 689 | struct mtget { |
cf0a9ace MK |
690 | long mt_type; |
691 | long mt_resid; | |
e2af0daf | 692 | /* the following registers are device dependent */ |
cf0a9ace MK |
693 | long mt_dsreg; |
694 | long mt_gstat; | |
695 | long mt_erreg; | |
e2af0daf | 696 | /* The next two fields are not always used */ |
cf0a9ace MK |
697 | daddr_t mt_fileno; |
698 | daddr_t mt_blkno; | |
fea681da MK |
699 | }; |
700 | .fi | |
e40c76c0 | 701 | .in |
f19a0f03 | 702 | .IP \fImt_type\fP 11 |
fea681da | 703 | The header file defines many values for |
f19a0f03 | 704 | .IR mt_type , |
fea681da | 705 | but the current driver reports only the generic types |
e40c76c0 MK |
706 | .B MT_ISSCSI1 |
707 | (Generic SCSI-1 tape) | |
708 | and | |
709 | .B MT_ISSCSI2 | |
710 | (Generic SCSI-2 tape). | |
f19a0f03 | 711 | .IP \fImt_resid\fP |
fea681da | 712 | contains the current tape partition number. |
f19a0f03 | 713 | .IP \fImt_dsreg\fP |
fea681da MK |
714 | reports the drive's current settings for block size (in the low 24 |
715 | bits) and density (in the high 8 bits). | |
e40c76c0 | 716 | These fields are defined by |
979c2c91 | 717 | .BR MT_ST_BLKSIZE_SHIFT , |
e40c76c0 MK |
718 | .BR MT_ST_BLKSIZE_MASK , |
719 | .BR MT_ST_DENSITY_SHIFT , | |
720 | and | |
721 | .BR MT_ST_DENSITY_MASK . | |
f19a0f03 | 722 | .IP \fImt_gstat\fP |
fea681da MK |
723 | reports generic (device independent) status information. |
724 | The header file defines macros for testing these status bits: | |
725 | .RS | |
726 | .HP 4 | |
e40c76c0 | 727 | \fBGMT_EOF\fP(\fIx\fP): |
fea681da | 728 | The tape is positioned just after a filemark |
979c2c91 | 729 | (always false after an |
e40c76c0 MK |
730 | .B MTSEEK |
731 | operation). | |
fea681da | 732 | .HP |
e40c76c0 | 733 | \fBGMT_BOT\fP(\fIx\fP): |
fea681da | 734 | The tape is positioned at the beginning of the first file (always false |
e40c76c0 MK |
735 | after an |
736 | .B MTSEEK | |
737 | operation). | |
fea681da | 738 | .HP |
e40c76c0 | 739 | \fBGMT_EOT\fP(\fIx\fP): |
fea681da MK |
740 | A tape operation has reached the physical End Of Tape. |
741 | .HP | |
e40c76c0 | 742 | \fBGMT_SM\fP(\fIx\fP): |
fea681da | 743 | The tape is currently positioned at a setmark |
e40c76c0 MK |
744 | (always false after an |
745 | .B MTSEEK | |
746 | operation). | |
fea681da | 747 | .HP |
e40c76c0 | 748 | \fBGMT_EOD\fP(\fIx\fP): |
fea681da MK |
749 | The tape is positioned at the end of recorded data. |
750 | .HP | |
e40c76c0 | 751 | \fBGMT_WR_PROT\fP(\fIx\fP): |
fea681da MK |
752 | The drive is write-protected. |
753 | For some drives this can also mean that the drive does not support | |
754 | writing on the current medium type. | |
755 | .HP | |
e40c76c0 | 756 | \fBGMT_ONLINE\fP(\fIx\fP): |
fea681da | 757 | The last |
5e21af3a | 758 | .BR open (2) |
fea681da MK |
759 | found the drive with a tape in place and ready for operation. |
760 | .HP | |
e40c76c0 | 761 | \fBGMT_D_6250\fP(\fIx\fP), \fBGMT_D_1600\fP(\fIx\fP), \fBGMT_D_800\fP(\fIx\fP): |
fea681da MK |
762 | This \(lqgeneric\(rq status information reports the current |
763 | density setting for 9-track \(12" tape drives only. | |
764 | .HP | |
e40c76c0 | 765 | \fBGMT_DR_OPEN\fP(\fIx\fP): |
fea681da MK |
766 | The drive does not have a tape in place. |
767 | .HP | |
e40c76c0 | 768 | \fBGMT_IM_REP_EN\fP(\fIx\fP): |
c13182ef MK |
769 | Immediate report mode. |
770 | This bit is set if there are no guarantees that | |
fea681da | 771 | the data has been physically written to the tape when the write call |
c13182ef MK |
772 | returns. |
773 | It is set zero only when the driver does not buffer data and | |
fea681da | 774 | the drive is set not to buffer data. |
e2af0daf | 775 | .HP |
e40c76c0 | 776 | \fBGMT_CLN\fP(\fIx\fP): |
c13182ef | 777 | The drive has requested cleaning. |
74aace8a | 778 | Implemented in kernels since 2.4.19 and 2.5.43. |
fea681da | 779 | .RE |
f19a0f03 | 780 | .IP \fImt_erreg\fP |
fea681da | 781 | The only field defined in |
f19a0f03 | 782 | .I mt_erreg |
fea681da | 783 | is the recovered error count in the low 16 bits (as defined by |
e40c76c0 MK |
784 | .BR MT_ST_SOFTERR_SHIFT |
785 | and | |
786 | .BR MT_ST_SOFTERR_MASK . | |
fea681da MK |
787 | Due to inconsistencies in the way drives report recovered errors, this |
788 | count is often not maintained (most drives do not by default report | |
789 | soft errors but this can be changed with a SCSI MODE SELECT command). | |
f19a0f03 | 790 | .IP \fImt_fileno\fP |
fea681da MK |
791 | reports the current file number (zero-based). |
792 | This value is set to \-1 when the file number is unknown (e.g., after | |
e40c76c0 MK |
793 | .BR MTBSS |
794 | or | |
795 | .BR MTSEEK ). | |
f19a0f03 | 796 | .IP \fImt_blkno\fP |
fea681da MK |
797 | reports the block number (zero-based) within the current file. |
798 | This value is set to \-1 when the block number is unknown (e.g., after | |
e40c76c0 MK |
799 | .BR MTBSF , |
800 | .BR MTBSS , | |
801 | or | |
802 | .BR MTSEEK ). | |
803 | .SS "MTIOCPOS \(em Get tape position" | |
fea681da MK |
804 | .PP |
805 | This request takes an argument of type | |
8478ee02 | 806 | .I "(struct mtpos *)" |
fea681da MK |
807 | and reports the drive's notion of the current tape block number, |
808 | which is not the same as | |
f19a0f03 | 809 | .I mt_blkno |
e40c76c0 MK |
810 | returned by |
811 | .BR MTIOCGET . | |
979c2c91 | 812 | This drive must be a SCSI-2 drive that supports the |
e40c76c0 | 813 | .B "READ POSITION" |
fea681da MK |
814 | command (device-specific address) |
815 | or a Tandberg-compatible SCSI-1 drive (Tandberg, Archive | |
816 | Viper, Wangtek, ... ). | |
817 | .PP | |
088a639b | 818 | .in +4n |
fea681da | 819 | .nf |
e40c76c0 | 820 | /* structure for MTIOCPOS \- mag tape get position command */ |
cf0a9ace MK |
821 | struct mtpos { |
822 | long mt_blkno; /* current block number */ | |
fea681da | 823 | }; |
fea681da | 824 | .fi |
e40c76c0 | 825 | .in |
fea681da | 826 | .SH "RETURN VALUE" |
e40c76c0 MK |
827 | .TP 14 |
828 | .TP | |
829 | .B EACCES | |
fea681da MK |
830 | An attempt was made to write or erase a write-protected tape. |
831 | (This error is not detected during | |
5e21af3a | 832 | .BR open (2).) |
e40c76c0 MK |
833 | .TP |
834 | .B EBUSY | |
fea681da MK |
835 | The device is already in use or the driver was unable to allocate a |
836 | buffer. | |
e40c76c0 MK |
837 | .TP |
838 | .B EFAULT | |
839 | The command parameters point to memory not belonging to the calling | |
840 | process. | |
841 | .TP | |
842 | .B EINVAL | |
fea681da | 843 | An |
5e21af3a | 844 | .BR ioctl (2) |
e935e108 | 845 | had an invalid argument, or a requested block size was invalid. |
e40c76c0 MK |
846 | .TP |
847 | .B EIO | |
848 | The requested operation could not be completed. | |
849 | .TP | |
850 | .B ENOMEM | |
851 | The byte count in | |
852 | .BR read (2) | |
853 | is smaller than the next physical block on the tape. | |
854 | (Before 2.2.18 and 2.4.0-test6 the extra bytes have been | |
855 | silently ignored.) | |
856 | .TP | |
857 | .B ENOSPC | |
858 | A write operation could not be completed because the tape reached | |
859 | end-of-medium. | |
860 | .TP | |
861 | .B ENOSYS | |
fea681da | 862 | Unknown |
5e21af3a | 863 | .BR ioctl (2). |
e40c76c0 MK |
864 | .TP |
865 | .B ENXIO | |
866 | During opening, the tape device does not exist. | |
867 | .TP | |
868 | .B EOVERFLOW | |
869 | An attempt was made to read or write a variable-length block that is | |
870 | larger than the driver's internal buffer. | |
871 | .TP | |
872 | .B EROFS | |
873 | Open is attempted with | |
874 | .B O_WRONLY | |
875 | or | |
876 | .B O_RDWR | |
877 | when the tape in the drive is write-protected. | |
fea681da | 878 | .SH FILES |
cba04495 MK |
879 | .TP 12 |
880 | .I /dev/st* | |
881 | the auto-rewind SCSI tape devices | |
882 | .TP 12 | |
883 | .I /dev/nst* | |
24b74457 | 884 | the nonrewind SCSI tape devices |
d2dc6294 MK |
885 | .\" .SH AUTHOR |
886 | .\" The driver has been written by Kai M\(:akisara (Kai.Makisara@metla.fi) | |
887 | .\" starting from a driver written by Dwayne Forsyth. | |
888 | .\" Several other | |
889 | .\" people have also contributed to the driver. | |
fea681da | 890 | .SH NOTES |
e40c76c0 MK |
891 | .IP 1. 4 |
892 | When exchanging data between systems, both systems have to agree on | |
c13182ef MK |
893 | the physical tape block size. |
894 | The parameters of a drive after startup | |
fea681da | 895 | are often not the ones most operating systems use with these |
c13182ef MK |
896 | devices. |
897 | Most systems use drives in variable-block mode if the drive | |
898 | supports that mode. | |
899 | This applies to most modern drives, including | |
900 | DATs, 8mm helical scan drives, DLTs, etc. | |
901 | It may be advisable to use | |
e40c76c0 MK |
902 | these drives in variable-block mode also in Linux (i.e., use |
903 | .B MTSETBLK | |
904 | or | |
905 | .B MTSETDEFBLK | |
906 | at system startup to set the mode), at least when | |
c13182ef MK |
907 | exchanging data with a foreign system. |
908 | The drawback of | |
fea681da MK |
909 | this is that a fairly large tape block size has to be used to get |
910 | acceptable data transfer rates on the SCSI bus. | |
e40c76c0 MK |
911 | .IP 2. |
912 | Many programs (e.g., | |
913 | .BR tar (1)) | |
914 | allow the user to specify the blocking | |
c13182ef MK |
915 | factor on the command line. |
916 | Note that this determines the physical block | |
e2af0daf | 917 | size on tape only in variable-block mode. |
e40c76c0 MK |
918 | .IP 3. |
919 | In order to use SCSI tape drives, the basic SCSI driver, | |
fea681da | 920 | a SCSI-adapter driver and the SCSI tape driver must be either |
c13182ef MK |
921 | configured into the kernel or loaded as modules. |
922 | If the SCSI-tape | |
fea681da MK |
923 | driver is not present, the drive is recognized but the tape support |
924 | described in this page is not available. | |
e40c76c0 MK |
925 | .IP 4. |
926 | The driver writes error messages to the console/log. | |
c13182ef | 927 | The SENSE |
fea681da MK |
928 | codes written into some messages are automatically translated to text |
929 | if verbose SCSI messages are enabled in kernel configuration. | |
e40c76c0 MK |
930 | .IP 5. |
931 | The driver's internal buffering allows good throughput in fixed-block | |
c13182ef | 932 | mode also with small |
5e21af3a | 933 | .BR read (2) |
c13182ef | 934 | and |
5e21af3a | 935 | .BR write (2) |
c13182ef MK |
936 | byte counts. |
937 | With direct transfers | |
e2af0daf MK |
938 | this is not possible and may cause a surprise when moving to the 2.6 |
939 | kernel. | |
940 | The solution is to tell the software to use larger transfers (often | |
941 | telling it to use larger blocks). | |
942 | If this is not possible, direct transfers can be disabled. | |
2b2581ee | 943 | .\" .SH COPYRIGHT |
e37e3282 MK |
944 | .\" Copyright \(co 1995 Robert K. Nichols. |
945 | .\" .br | |
946 | .\" Copyright \(co 1999-2005 Kai M\(:akisara. | |
947 | .\" .PP | |
948 | .\" Permission is granted to make and distribute verbatim copies of this | |
949 | .\" manual provided the copyright notice and this permission notice are | |
950 | .\" preserved on all copies. | |
951 | .\" Additional permissions are contained in the header of the source file. | |
952 | .SH "SEE ALSO" | |
953 | .BR mt (1) | |
fea681da | 954 | .PP |
cba04495 MK |
955 | The file |
956 | .I drivers/scsi/README.st | |
957 | or | |
958 | .I Documentation/scsi/st.txt | |
959 | (kernel >= 2.6) in the kernel sources contains | |
e37e3282 MK |
960 | the most recent information about the driver and its configuration |
961 | possibilities. |