Chapter 4 File Locking Implementations
File systems and pseudo file systems (like
Windows (CIFS),
UNIX (JFS, HFS, etc)
NFS,
4.1WINDOWS (CIFS)
The Windows file system (using CIFS) utilizes three different
Mandatory Locking,
Opportunistic Locking (Oplocks).
MANDATORY LOCKING is invoked at file open by the Windows Createfile API. Locking parameters supplied to Createfile include access mode and share mode.
Access mode defines how an application (caller of Createfile) wants to access the file:
Read: | Read access only |
Write: | Write access only |
Read and Write access |
Share mode defines how an application wants to limit or grant concurrent access while it has the file open, essentially comprising the locking scenario for MANDATORY LOCKS:
Concurrent read and write access allowed | |
No concurrent read or write access allowed | |
No concurrent read access allowed | |
No concurrent write access allowed |
These are Windows default file locking mechanisms. There are obscure ways to disable mandatory locks, but they should never be disabled (which is why they are obscure). Windows documentation uses the terms “mandatory” and “share mode”. However, it is helpful to think of mandatory share mode locking as “OPEN MODE LOCKING”, because it is initiated during a file open, so subsequent references will use “Mandatory Share Mode (Open Mode) Locking”.
8