HomeFreeBSD

Add -w option to lockf(1).

Description

Add -w option to lockf(1).

By default, lockf(1) opens its lock file O_RDONLY|O_EXLOCK. On NFS, if the
file already exists, this is split into opening the file read-only and then
requesting an exclusive lock -- and the second step fails because NFS does
not permit exclusive locking on files which are opened read-only.

The new -w option changes the open flags to O_WRONLY|O_EXLOCK, allowing it
to work on NFS -- at the cost of not working if the file cannot be opened
for writing.

(Whether the traditional BSD behaviour of allowing exclusive locks to be
obtained on a file which cannot be opened for writing is a good idea is
perhaps questionable since it may allow less-privileged users to perform
a local denial of service; however this behaviour has been present for a
long time and changing it now seems like it would cause problems.)

Reviewed by: rmacklem
Differential Revision: https://reviews.freebsd.org/D26005

Details

Provenance
cpercivaAuthored on
Reviewer
rmacklem
Differential Revision
D26005: Add -w option to lockf(1)
Parents
rS364830: Move zstd sources from libzfs to libzpool
Branches
Unknown
Tags
Unknown