Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 85
Recovering From Errors
Recovering From Errors
The tape process attempts automatic recovery for all tape I/O operations. However, it
is the application’s responsibility to ensure that the tape gets positioned correctly
following an error. For example, if a power failure or other hardware error occurs while
a tape read or write is taking place, it is indeterminate where the tape is positioned at
the point of failure. If, for example, an error is returned from a write request, you may
not know whether the write to tape started.
If an error is reported when operating in buffered mode the application cannot
determine which I/O operation caused the error. During a sequence of buffered writes,
for example, an error reported to the application by the tape process does not indicate
which of the previous write requests failed. Therefore, to recover from the error, the
application must reposition to the last known good record and resume writing from that
point.
In summary, your application must be able to respond to I/O errors depending on mode
of buffering as follows:
Reconsider the buffered-mode tape access example shown in Figure 12-3. Assume
that the application encounters an error because the tape drive is unloaded and offline.
Figure 12-4 shows what happens.
As described earlier in Working in Buffered Mode, two write requests are buffered by
the tape process while the first write request is passed to the tape device. This time,
however, the tape device replies with an error (error 100, for example). On receipt of
an error, the tape process discards the contents of its buffer. The application is not
notified of the error until the next time it passes a request to the tape process. In this
case, the third write request receives the error. A CONTROL or SETMODE request to
the tape process would also receive the error.
The application cannot tell from the information returned which write request caused
the error.
If you are using buffered mode... Then your program must...
0 (no buffered mode) Retry the current record
1 (buffered mode, no EOF mark
b
uffering)
Be able to reconstruct the file on tape
2 (EOF mark buffering enabled) Be able to reconstruct all the data it has written to tape