Multiple logical files can link to the same physical file only if the physical file has been entered into the disk directory. The concept of the disk directory is closely related to the concepts of permanent and temporary files. A permanent file appears in the disk directory, and by default is retained when it is closed. A temporary file does not appear in the disk directory, and by default is removed when it is closed.
A process can cause a file to be entered in the directory by any of the following methods, which are referred to as directory entrance operations:
-
Opening the file with the NEWFILE file attribute set to TRUE and the PROTECTION file attribute set to SAVE or PROTECTED. Of these two values, SAVE is preferable in most cases because PROTECTED adds overhead. Opening the file creates a permanent file, which is entered immediately in the directory. The file continues to exist after the process terminates, unless the process specifies the PURGE option in the statement that closes the file.
-
For a file that was opened with a PROTECTION value of TEMPORARY (the default), closing the file with either the LOCK or CRUNCH option specified in the close statement. In addition to closing the file, this action enters the file in the directory.
-
Opening the file with the NEWFILE file attribute and the SENSITIVEDATA file attribute both set to TRUE. The main purpose of using the SENSITIVEDATA attribute is to protect sensitive information, but it also has the side effect of entering a file in the directory.
If two files with the same title exist on the same family, they cannot both be permanent. An option called AUTORM specifies the action to be taken if a process attempts to enter a file in the directory, and a file with same title already exists. If the AUTORM option is set, the attempt to enter the file in the directory causes one of the following actions:
-
If the old file is not in use by any process, it is removed and the new file is entered in the directory.
-
If the old file is still in use by another process, the old file is removed from the directory and the new file is added to the directory. The old file remains open as a temporary file. Some unexpected effects can arise from this situation. For example, suppose the new file was opened as a temporary file by process B, and the old file was originally opened as a permanent file by process A. When process B closes the new file with LOCK, the new file is changed into a permanent file, and the old file is changed into a temporary file. If process A then closes the old file with LOCK, the old file becomes permanent again and the new file is changed back into a temporary file.
In general, the last file entered or reentered in the directory is the one that is saved permanently, regardless of whether the directory entry was caused by the file attribute values in force at file open time, or by the option used for the close operation.
If the AUTORM option is reset, and a permanent file with a particular title already exists, then a process that attempts to enter a file with the same title into the directory is suspended with a “DUPLICATE FILE” RSVP message. An operator can restart the process by entering the RM (Remove) system command, which deletes the existing duplicate file.
The system treats the AUTORM option as set for a particular process if either or both of the following are true:

