How the File System Opens a File [ Accessing Files Programmer's Guide ] MPE/iX 5.0 Documentation
Accessing Files Programmer's Guide
How the File System Opens a File
When you open a file, HPFOPEN/FOPEN establishes a communication link
between the file and your program by
* Determining the device on which the file resides.
* Allocating to your process the device on which the file resides.
Disk files generally can be shared concurrently among jobs and
sessions. Magnetic tape and unit-record devices are generally
allocated exclusively to the requesting job or session.
If the file resides on a nonshareable device (such as magnetic
tape) and you have nonshareable device (ND) capability,
HPFOPEN/FOPEN determines whether the system operator must approve
allocation of the device (such as an unlabeled magnetic tape) or
provide a particular media (such as a specific volume for a
labeled magnetic tape request or special forms for a line
printer). If so, HPFOPEN/FOPEN requests the system operator to
respond appropriately.
Different processes within the same job may open and have
concurrent access to a file on the same magnetic tape or
unit-record device if the file has been opened with multiaccess
option set; however, this device cannot be accessed by another job
until all accessing processes in this job have issued a
corresponding FCLOSE call.
* Verifying your right to access the file under the security
provisions existing at the account, group, and file levels.
* Determining that the file has not been allocated exclusively to
another process (by the exclusive option in an HPFOPEN/FOPEN call
issued by that process).
* Processing user labels (for files on disk). For new files on
disk, HPFOPEN/FOPEN specifies the number of user labels to be
written.
* Constructing the control blocks required by MPE/iX for this
particular access of the file. The information in these blocks is
derived by merging specifications from four sources, listed below
in descending order of precedence (and illustrated in Figure 5-1
):
1. The file label, obtainable only if the file is an old file
on disk; otherwise, device-dependent characteristics
applicable to the nonshareable device. This information
overrides information from any other source.
2. The parameter list of a previous FILE command referencing
the same formal file designator named in this HPFOPEN/FOPEN
call, if such a command was issued in this job or session.
This is only true, if file equations were not disallowed.
3. The parameter list of this HPFOPEN/FOPEN intrinsic call.
4. System default values provided by MPE/iX (when values are
not obtainable from the above sources).
When information from one of these four sources conflicts with that from
another, preempting takes place according to the order of precedence
illustrated in Figure 5-1 . To determine the specifications actually
taking effect, you can call the FFILEINFO intrinsic. Certain sources do
not always apply or convey all types of information. For example, no
file label exists when a new file is opened, and so all information must
come from the last four sources above.
Figure 5-1. File System Hierarchy of Overrides
Since the physical characteristics of a disk file cannot be changed after
it has been created, it makes sense that the file label would take
precedence over information from any other source. Likewise, when a
device file is opened, device-dependent characteristics override
information from any other source.
When the HPFOPEN/FOPEN intrinsic is executed, it returns to your program
a file number. If the file is opened successfully, the file number
returned is a positive integer. At this point, the file is ready to be
accessed with system intrinsics (for example, FREAD or FWRITE). If the
file cannot be opened, the file number returned is zero, and the
intrinsic returns an error condition.
If your process issues more than one HPFOPEN/FOPEN call for the same file
before it is closed, this results in multiple, logically separate
accesses of that file, and MPE/iX returns a unique file number for each
such access. Also, MPE/iX maintains a separate logical record pointer
(indicating the next sequential record to be accessed) for each access
where you did not request or permit the multiaccess option at
HPFOPEN/FOPEN time.
MPE/iX 5.0 Documentation