[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Readonly files



Steven Fullmer wrote:
Using chmod, chown and chgrp, a user can get permissions to modify files. Is there a way to 'lock' files in use as well? I know of a couple programs that create an entry into a .lock file where, when someone opens the same file, it is opened read-only. Is this a feature unique to this program, or is it a RH standard, so no two people can modify certain files? If there is, is there a command that is sent to lock and/or unlock the files/directories in question?

The creation of a lock file is unique to certain programs, and it's normally used to prevent two programs from trying to fight over a device (such as a modem or printer).

Record locking (where a program acquires a write lock on a file so that
only it can modify it) is and has always been a part of Linux.  The
programs using it must both adhere to the standard (called "cooperative
locking").  It's a part of the standard file I/O library and is accessed
via the fcntl() system call (see "man fcntl", specifically the parts
about "F_GETLK", "F_SETLK" and "F_SETLKW".
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens vitalstream com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-        Hard work has a future payoff. Laziness pays off now.       -
----------------------------------------------------------------------




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]