0

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.

1

The Linux kernel documentation Mandatory File Locking For The Linux Operating System has some of the history:

The System V mandatory locking scheme was intended to have as little impact as possible on existing user code. The scheme is based on marking individual files as candidates for mandatory locking, and using the existing fcntl()/lockf() interface for applying locks just as if they were normal, advisory locks.

A file is marked as a candidate for mandatory locking by setting the group-id bit in its file mode but removing the group-execute bit. This is an otherwise meaningless combination, and was chosen by the System V implementors so as not to break existing user programs.

(More specifically, the Advanced Programming in the UNIX Environment book says it was done in System V Release 3.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.