Magnetic Tape Considerations [ Accessing Files Programmer's Guide ] MPE/iX 5.0 Documentation
Accessing Files Programmer's Guide
Magnetic Tape Considerations
The most common medium for storage of a device file is magnetic tape.
This section describes the matters that you should keep in mind when you
work with your magnetic tape files.
Every standard reel of magnetic tape designed for digital computer use
has two reflective markers located on the back side of the tape (opposite
the recording surface). As illustrated in Figure 7-2 , one of these
marks is located behind the tape leader at the beginning-of-tape (BOT)
position, and the other is located in front of the tape trailer at the
end-of-tape (EOT) position. These markers are sensed by the tape drive
itself and their position on the tape (left or right side) determines
whether they indicate the BOT or EOT positions:
Figure 7-2. Magnetic Tape Markers
As far as the magnetic tape hardware and software are concerned, the BOT
marker is much more significant than the EOT marker because BOT signals
the start of recorded information; but EOT simply indicates that the
remaining tape supply is running low, and the program writing the tape
should bring the operation to an orderly conclusion. The difference in
treatment of these two physical tape markers is reflected by the file
system intrinsics when the file being read, written, or controlled is a
magnetic tape device file. The following paragraphs discuss the
characteristics of each appropriate intrinsic.
FWRITE. If the magnetic tape is unlabeled (as specified in the
HPFOPEN/FOPEN intrinsic or FILE command) and a user program attempts to
write over or beyond the physical EOT marker, the FWRITE intrinsic
returns an error condition code (CCL). The actual data is written to the
tape, and a call to FCHECK reveals a file error indicating end-of-tape.
All writes to the tape after the EOT marker has been crossed transfer the
data successfully, but return a CCL condition code until the tape crosses
the EOT marker again in the reverse direction (rewind or backspace).
If the magnetic tape is labeled (as specified in the HPFOPEN/FOPEN
intrinsic or FILE command), a CCL condition code is not returned when the
tape passes the EOT marker. Attempts to write to the tape after the EOT
marker is encountered cause end-of-volume (EOV) labels to be written. A
message then is printed on the operator's console requesting another reel
of tape to be mounted.
FREAD. A user program can read data written over an EOT marker and beyond
the marker into the tape trailer. The intrinsic returns no error
condition code (CCL or CCG) and does not initiate a file system error
code when the EOT marker is encountered.
[REV BEG]
DDS tape drives do not permit an FREAD past the marker. With DDS drives,
every FWRITE updates the EOT marker and does not permit a rewrite of
previous data.[REV END]
FSPACE. A user program can space records over or beyond the EOT marker
without receiving an error condition code (CCL or CCG) or a file system
error. The intrinsic does, however, return a CCG condition code when a
logical file mark is encountered. If the user program attempts to
backspace records over the BOT marker, the intrinsic returns a CCG
condition code and remains positioned on the BOT marker.
FCONTROL (Write EOF). If a user program writes a logical end-of-file
(EOF) mark on a magnetic tape over the reflective EOT marker, or in the
tape trailer after the marker, hardware status is saved to return
END-OF-TAPE on the next FWRITE. The file mark is actually written to the
tape.
FCONTROL (FORWARD SPACE TO FILE MARK). A user program that spaces forward
to logical tape marks (EOFs) with the FCONTROL intrinsic cannot detect
passing the physical EOT marker. No special condition code is returned.
FCONTROL (BACKWARD SPACE TO FILE MARK). The EOT reflective marker is not
detected by FCONTROL during backspace file (EOF) operations. If the
intrinsic discovers a BOT marker before it finds a logical EOF, it
returns a condition code of CCE and treats the BOT as if it were a
logical EOF. Subsequent backspace file operations requested when the file
is at BOT are treated as errors and return a CCL condition code and set a
file system error to indicate INVALID OPERATION.
In summary, except for FCONTROL, only those intrinsics that cause the
magnetic tape to write information are capable of sensing the physical
EOT marker. If a program designed to read a magnetic tape needed to
detect the EOT marker, it could be done by using the FCONTROL intrinsic
to read the physical status of the tape drive itself. When the drive
passes the EOT marker and is moving in the forward direction, tape status
bit 5 (%2000) is set and remains on until the drive detects the EOT
marker during a rewind or backspace operation. Under normal
circumstances, however, it is not necessary to check for EOT during read
operations. The responsibility for detecting end-of-tape and concluding
tape operations in an orderly manner belongs to the program that
originally created (wrote) the tape.
A program that needed to create a multiple reel tape file would normally
write tape records until the status returned from FWRITE indicated an EOT
condition. Writing could be continued in a limited manner to reach a
logical point at which to break the file. Then several file marks and a
trailing tape label would typically be added, the tape rewound, another
reel mounted, and the data transfer continued. The program designed to
read such a multitape file must expect to find and check for the EOF and
label sequence written by the tape's creator. Since the logical end of
the tape may be somewhat past the physical EOT marker, the format and
conventions used to create the tape are of more importance than
determining the location of the EOT.
MPE/iX 5.0 Documentation