skip book previous and next navigation links
go up to top of book: HP OpenVMS System Manager's Manual, Volume 1:... HP OpenVMS System Manager's Manual, Volume 1:...
go to beginning of chapter: Using Files and Directories Using Files and Directories
go to previous page: Accessing Disk Files Accessing Disk Files
go to next page: Copying and Transferring FilesCopying and Transferring Files
end of book navigation links

Accessing Tape Files   



This section describes file-level access for tapes. When you request access to a standard-labeled volume or a file, the operating system checks at the volume and file level to ensure that your process can access the volume or file. The level at which the system checks access depends on the operation you request and the type of access the operation requires.

When you access a volume or a file, the operating system software reads the volume- and file-header labels to determine whether access to the volume or file is restricted. Which label is read depends on the operation requested. For example, if you want to mount a volume, your process must have access to it.

The protection set on a file determines your access to the file. The expiration date field in the header can prevent you from overwriting or appending to a file immediately preceding the one in question. If the expiration date field has not been reached, a file has not expired.

To overwrite an unexpired file, you must specify the /OVERRIDE=EXPIRATION qualifier when you mount the volume. Performing this operation requires that you have read or write access.

After a section that explains tape file names are sections that tell how to perform these tasks:

Task Section
Locate standard-labeled tape files
Locating Standard-Labeled Tape Files
Use wildcards with tape files
Using Wildcard Characters with Tape Volumes
Read files on tape volumes
Reading Files on Tape Volumes
Write files to tape volumes
Writing Files to Tape Volumes

Understanding Tape File Names  

OpenVMS systems accept two types of file names for magnetic tapes:

Comparison of OpenVMS Extended Names and Standard Names compares characteristics of OpenVMS extended names and standard names.

Table 9   Comparison of OpenVMS Extended Names and Standard Names
Characteristic OpenVMS Extended Names Standard Names
Valid with...
Tape and disk volumes
Tape volumes
Format
filename.type;version
filename.;version (Version is optional.)
Length
39.39;
17.;
Valid Characters
A through Z; 0 through 9; ampersand (&), hyphen (-), underscore ( _ ), and dollar sign ($); wildcard characters asterisk (*) and percent sign (%)
ASCII "a" characters enclosed in quotation marks (" ").1 Note that within a file name, DCL interprets a double set of quotation marks ("") as a single set ("). If a name has fewer than 17 characters, the system pads the name on the right with spaces to arrive at the 17-character maximum length.
Examples
OPENVMS_FILENAME.DAT;23
"GENLABEL#123";2

Locating Standard-Labeled Tape Files  

Before accessing a particular file for a read or write operation, you might want to search the magnetic tape volume for that file. Use the DCL command DIRECTORY to locate a file or group of files on a tape volume.

When you specify a file name for a file residing on tape, the tape file system performs the following tasks:

  1. Compares the file name with the file header labels of each file until it finds a match in the file identifier field of the file header labels.
  2. The system selects the first file on the magnetic tape whose file name in the file identifier field matches the specified file name.

    The operating system supports neither the directory nor the latest version number concept for magnetic tape volumes. The system does not search for or list the latest version of a specified file. The magnetic tape file system cannot increment version numbers of files written to tape; therefore, two or more files in the same volume set can have the same file name and version number.

    Because the tape file system selects the first matching file name and version number (if specified), the position of the magnetic tape within the volume set determines which file is returned on a search operation. A search operation begins at the current position, so you might want to rewind the volume set before accessing a file.
  3. The search for a matching file and version number (if specified) continues at the beginning of the header-label set of the next file. The search ends when the magnetic tape is positioned at the file where the search began.

    If the system does not find the requested file on the current volume, it searches the remaining volumes in the volume set sequentially and then searches from the beginning of the first volume of the volume set. If the system still does not find the file name, it reports an error.

Using Wildcard Characters with Tape Volumes  

The OpenVMS operating system supports a limited use of wildcard characters in file specifications for tape volumes.

Wildcard Character Support with Tape Volumes explains the use of wildcard characters with OpenVMS extended names and with standard names.

Table 10   Wildcard Character Support with Tape Volumes
Wildcard Character OpenVMS Extended Names Standard Names Description
Asterisk (*)
X
X
In OpenVMS extended names, you can use an asterisk anywhere in the file name and file type field to match a field or portion of a field. You can also use the asterisk in the version number field.

In standard names, you can use only a single asterisk in a field.
Percent sign (%)
X

In OpenVMS extended names, you can use a percent sign in a file specification only to match character positions within a field. You cannot use the percent sign in the version number field.

Unlike OpenVMS extended names, which can consist of up to 39 characters each for the file name and file type, standard names can have a maximum of 17 characters.

The following examples show how to use wildcard characters in file specifications to search for files on tape volumes. These examples also show how you can use the DIRECTORY command with tapes. Note that the DIRECTORY command does not work the same with tape files as with disk files.

Examples

  1. $ DIRECTORY MFA1:*.*;*
    This command instructs the system to search a volume set. Because asterisks are used in the file specification and the asterisk is a valid wildcard character for both standard and OpenVMS extended names, the system returns both OpenVMS extended names and standard names. Note that the system returns tape file names within quotation marks.
  2. In these two commands, the search can match only with OpenVMS extended names because the percent sign is not valid for standard names. In the second command, the file type field must contain at least one character. Files with no file type are not returned.
    $ DIRECTORY MTA1:%*.*;*
    $ DIRECTORY MTA0:*.%*;*
  3. $ DIRECTORY MTA0:*.;*
    In this example, the DIRECTORY command instructs the system to search for files with both standard names and OpenVMS extended names that do not have a file type.

Reading Files on Tape Volumes  

When you access a tape file for a read operation, the tape is positioned at the beginning of the file section after the file header labels. When you access a file residing on a tape volume only to read the attributes in the header labels (rather than the data in the file section), the tape file system returns the RMS attributes to your process. For example, when you specify the DIRECTORY/FULL command for a volume, file, or list of files, the tape file system performs the following tasks:

  1. Selects the file identifiers from the header labels
  2. Returns the file attributes to your process
  3. Positions the tape after the header labels of the last file accessed

A tape file opened for read access is closed in either of the following ways:

Method Description
Implicitly
The file is closed implicitly when the drive encounters a tape mark while the system reads a file. The tape file system then reads the trailer labels, closes the file, and positions the tape at the next file.
Explicitly
The file is closed explicitly when you finish accessing the file before all the data in the file is read. The tape file system then closes the file without reading the trailer labels, and the tape remains at the current position.

Example

Use the DCL command TYPE to read a file or group of files on the tape volume and to display the contents of the file on your terminal. For example, if you want to read the contents of a file named TESTFILE.DOC;1 (which you know from your directory searches is an OpenVMS file residing on the tape volume MTA1:), enter the following command:

$ TYPE MTA1:TEST*.%*;*
You then receive the following display on your terminal:
MTA1:TESTFILE.DOC;1
 
This is a test file.

Writing Files to Tape Volumes  

When you write files to a tape volume, the tape file system performs access checks, writes labels, and, if necessary, switches volumes.

Writing New Files That Overwrite Existing Files  

If a new file will overwrite an existing file, the tape file system performs the following tasks:

  1. Checks the expiration date and accessibility fields of the existing file.
  2. If overwriting is allowed, the tape file system performs the following task:

    1. Overwrites the header label set of the existing file
    2. Creates the file section
    3. Writes the trailer labels
    4. Writes two tape marks to denote the logical end-of-volume (EOV)

All files following the newly created file are lost.

To close a tape file that was opened for write access, the tape file system issues commands to the driver to write the labels, followed by a double tape mark that indicates the logical EOV.

Appending or Updating Files  

When you use DCL to access an existing file for a write operation, either an append or an update operation is actually performed. The following table describes each operation.

Access Method Description
Append
When you access a file for an append operation, the tape is positioned before the tape mark that precedes the trailer labels. After the file is appended and closed, all files beyond the appended file are lost. When the positioning is complete, the processing is handled as if the file had been created.
Update
When you access a file for an update operation, the tape is positioned after the tape mark that follows the header labels. After the file is written to and closed, all files beyond the updated file are lost. The processing is handled as if the file had been created.

Note that you can update or append tape files only when the header label contains a value of 0 for the buffer offset length. For more information about how to update and append tape files, see Copying and Transferring Files.

If you do not specify the /OVERRIDE=EXPIRATION qualifier when you update a file, the tape file system checks the expiration date field on the file before it allows you to write to that file.

In addition, before you append a file, the tape file system checks the expiration dates of both the file being appended and the file immediately following it. If the expiration date of either file has not been reached, the magnetic tape file system does not allow you to append the file.

Example

You can use the CREATE command to access a volume for a write operation. The following CREATE command writes a new file to the tape volume:

$ CREATE MTA0:MYFILE
After entering a command similar to the one in this example, follow these steps:
  1. Enter the contents of the file.
  2. Press Ctrl/Z to close the file and write it to the tape volume without leaving the DCL command level.

Footnotes
1The ASCII "a" character set is defined in Clause 7.4.1 of the ISO 9660 Standard.

( Number takes you back )


go to previous page: Accessing Disk Files Accessing Disk Files
go to next page: Copying and Transferring FilesCopying and Transferring Files