[ale] fcntl F_SETLK
Lex Spoon
sspoon at clemson.edu
Fri Aug 15 03:16:57 EDT 1997
> When I set this lock, I can still access the file with other programs. Is
> there a way to lock the file so that no other program can access it.
>
Reasonably recente kernels have a mandantory locking option.
Look at /usr/src/linux/Documentation/mandantory.txt.
By the way, mandantory locking has its own hazards. To get a
taste of the possibilities, this is found at the end of the above
document:
Warning!
--------
Not even root can override a mandatory lock, so runaway process can wreak
havoc if they lock crucial files. The way around it is to change the file
permissions (remove the setgid bit) before trying to read or write to it.
Of course, that might be a bit tricky if the system is hung :-(
Specific cases I've heard mentioned are problems with backup software,
and problems with NFS servers. What do these kinds of software do
when they run into a mandantory-locked file?
My inclination is to just make do with advisory locking; Unix
filesystems and VM systems are complex enough as is, and even
"mandantory" locks aren't really. They are simply more of
a nuisance when something screws up.
lex
More information about the Ale
mailing list