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