Reputation: 11044
In Unix record locking is the technique used to lock the portion of a file for certain amount of time to maintain consistency of the data from concurrent access to the file. On this mechanism, Mandatory locking is the technique which is used to lock the portion of the file exclusively. If once mandatory locking is enabled to the file, no other process can read or write the data to the locked portion of the file. So, to enable mandatory lock to a file, the following is the procedure.
Turn ON the set group id bit and turn OFF the group execute bit for the file to be lock.
So, what is the need of this process which helds on these group ids and Why I want to do this particularly on group ids to enable mandatory locking. I saw many of the reference but all of them are tell only the rule instead of why they are implement the rule.
Upvotes: 1
Views: 881
Reputation: 36431
Mandatory does not lock exclusively... There are two kinds of locks : mandatory and advisory. For each kind you can obtain shared or exclusive locks. Mandatory means that locking policy is enforced to any process using the file in any way. Advisory means that locking is effective only for processes that play the game (use locks explicitly). It is not specified by the interface that locks are mandatory or advisory. In general, they are advisory; but some system lets you control the kind of lock are applicable to files. You just mentioned the way your system is able to active mandatory locking on a given file. Original access rights did not decided any useful purpose to executable bit for regular files nor setgid bit that are not executables or scripts, then implementors are free to use this for specific purposes.
Upvotes: 1