Creating a Lock on a File or Directory
When you lock a file, other users cannot make changes to it. When a directory is locked, no files within the directory can be changed by other users.
You can lock a file or directory by using the CREATE LOCK command.
CREate LOCk filename filetype dirid SHAre|EXClusive|UPDate SESsion|LAStingCREate LOCk dirid SHAre|EXClusive|UPDate SESsion|LAStingWhen you lock a file or directory, you must specify the duration of the lock. A SESSION lock is automatically unlocked at the end of your CMS session or when communication with your file pool is broken. A LASTING lock can only be removed with the DELETE LOCK command.
If you have read authority to a file or directory, you can only create a SHARE lock on that file or directory. If you have write authority, you can create any type of lock (SHARE, EXCLUSIVE, or UPDATE) on the file or directory.
The following table shows the meaning of each type of lock for a file or directory.
| Type | File | Directory |
|---|---|---|
| UPDATE | Other users may read the file while you are reading or updating it. They cannot change, rename, relocate, or erase the file. | The person who locked the directory can read from or write to any files for which that person is authorized. Other users may only read files in the directory; they cannot write to the files (even if they have write authority to them). Nor can they create, delete, rename, or relocate any base file, alias, or subdirectory in the directory. |
| EXCLUSIVE | Other users cannot read from or write to the file. | Other users cannot read from or write to any of the base files or aliases in the directory. Also, they cannot create, erase, rename, or relocate any base files or aliases until the directory is unlocked. |
| SHARE | Other users can read the file while you are reading it. No one, including the person who locked the file, can update the file until it is unlocked. Also, no users can rename, relocate, or erase the file. | Other users and the person who locked the directory can read from files in the directory (if they are authorized to do so). No users (including the person who created the lock) can update any files or subdirectories in the directory. Nor can they create, erase, rename, or relocate any base files, aliases, or subdirectories until the directory is unlocked. |
Except for UPDATE the above lock types apply only to file control directories and to files within file control directories. (Remember that, by default, the directories you create are file control directories.)