HP OpenVMS Systems Documentation
On Alpha and I64 systems, HP COBOL offers two methods of controlling potential conflicts of multi-user file access between simultaneously running processes:
Both effectively control potential conflicts of file access between simultaneously running COBOL processes. Both offer locking for all file types: sequential, relative, and indexed.
If you choose X/Open standard file sharing and record locking for a file connector, you must not use HP standard syntax anywhere in your program for the same file connector. The two are mutually exclusive.
The HP COBOL compiler determines whether to apply X/Open standard behavior or HP standard behavior for any file connector on the basis of the syntax used for that file connector. The following syntax identifies X/Open standard:
LOCK MODE (SELECT statement)
WITH LOCK (OPEN statement)
WITH [NO] LOCK (READ statement)
The following syntax identifies Hewlett-Packard standard:
For any given file connector, any subsequent I-O locking syntax in your program must be consistent: X/Open standard and HP standard file sharing/record locking (implicit or explicit) cannot be mixed for the same file connector.
If a program includes any ambiguous semantics for I-O verbs (that is, no locking syntax for verbs for which the two standards provide different default behavior) and the previous code does not use HP or X/Open standard-specific syntax for that file connector, the compiler determines which standard to use by applying the specification (or default) from your compile command line, as follows:
If you do not specify the flag or qualifier, the default is noxopen (HP standard) file sharing and record locking.
If you want X/Open file sharing and record locking and have not used the LOCK MODE clause, therefore, you should specify /STANDARD=XOPEN or -std xopen to ensure X/Open standard behavior in instances of conflicting default semantics. Note, however, that the qualifier/flag comes into effect only when the explicit syntax has not determined the usage. <>
1 Some exceptions exist on Tru64 UNIX. Refer to the HP COBOL Reference Manual for details.
The remainder of this section describes these requirements in more
8.3.1 Providing Disk Residency
Only files that reside on a disk can be shared. In HP COBOL you
can share sequential, relative, and indexed files.
8.3.2 Using File Protection
By applying the appropriate file permissions at the operating system level, the owner of a file determines how other users can access the file. An owner can permit different types of file access for different users or groups.
The following OpenVMS operating system file protection access types are not a part of HP COBOL syntax.
The four types of file access are as follows:
In the OpenVMS file protection facility, four different categories of users exist with respect to data structures and devices. A file owner determines which of the following user categories can share the file:
The OpenVMS operating system applies a default protection to each newly created file unless the owner specifically requests modified protection.
For more information on file protection, refer to the OpenVMS User's Manual. <>
The following Tru64 UNIX operating system file access types are not a part of HP COBOL syntax.
On Tru64 UNIX systems, the three types of file access are as follows:
There are three categories of users:
HP COBOL determines the access permission for newly created files in the following manner:
Additional information on file permission can be found in the
Tru64 UNIX man pages for
chmod, ls, open,
8.3.3 Determining the Intended Access Mode to a File
The HP COBOL open modes are INPUT, OUTPUT, EXTEND, and I-O. The HP COBOL access modes are SEQUENTIAL, RANDOM, and DYNAMIC. The combination of open and access modes determines the operations intended on the file.
You must validate your HP COBOL intention against the file protection assigned by the file owner. For example, to use an OPEN INPUT clause requires that the file owner has granted read access privileges to the file. To use an OPEN OUTPUT or EXTEND clause requires write access privileges to the file. To use an OPEN I-O clause requires both read and write access privileges.
The following chart shows the relationship between open and access modes and intended HP COBOL operations. The word ANY indicates that all three access methods result in the same intentions.
|Open Mode||Access Mode||Intended COBOL Operations|
|I-O||SEQUENTIAL||READ, START, REWRITE, DELETE|
|RANDOM/DYNAMIC||READ, START, REWRITE, DELETE, WRITE|
If the file protection does not permit the intended operations, file access is not granted, even if open and access modes are compatible.
File protection and open mode access apply to both the unshared and shared (multiple access stream) file environments. A file protection and intent check is made when the first access stream opens a file (in the unshared file environment), and again when the second and subsequent access streams open the file (in the shared file environment).