Multiple users having access to the same data usually requires some sort of mecanism to give exclusive access to all or part of the data for some period of time. Locking is an extensive subject, which would need far more space than we have here, but overall there are two basic concepts: advisory locking (enforced by cooperating processes) and mandatory locking (enforced by the kernel).
Advisory locking does involve the kernel: the lockf() and fcntl() system calls are really the same function ;early BSD had a more limited flock(). But the kernel only restricts processes that specifically use the lockf() or fcntl() calls: any other process can read or write at will.
Mandatory locking is interesting because it is enabled by a hack of setting a file's set-group-id on and turning group execute off:
[root@mail root]# chmod 2760 t
[root@mail root]# ls -l t
-rwxrwS--- 1 root root 550 Dec 5 09:12
That odd "S" is the result of this otherwise senseless combination,
Mandatory locking can be surprising though: Stevens points out that it can be circumvented by unlinking and then opening a new version of the file.
Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)
| Views for this page | ||||
|---|---|---|---|---|
| Today | This Week | This Month | This Year | Overall |
| 1 | 5 | 8 | 223 | 1,310 |
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Add your comments