Project

General

Profile

Actions

Bug #13879

open

flock(3C) on NFS files should fail with EOPNOTSUPP

Added by Joshua M. Clulow about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
filesystems (not ZFS)
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Our flock(3C) support does not presently support locking files on remote file systems like NFS (see F_REMOTELOCK, and comments in fs_frlock()). In the event that one tries to lock an NFS-backed file, flock() presently fails with EINVAL. This is probably not quite right; e.g., in the manual page:

       EINVAL
                           The operation argument does not contain one of
                           LOCK_SH, LOCK_EX, or LOCK_UN; or the operation
                           argument contains LOCK_UN and LOCK_NB; or the
                           operation argument contains any bits other than
                           those set by LOCK_SH, LOCK_EX, LOCK_NB, and
                           LOCK_UN.
...
       EOPNOTSUPP
                           The locking of files of the type indicated by
                           the fildes argument is not supported.

The latter seems more appropriate here.

As an aside, a brief survey of the documentation of other platforms shows:

  • FreeBSD and OpenBSD appear to use EOPNOTSUPP for this condition
  • Mac OS X appears to use ENOTSUP
  • Linux does not appear to document the possibility of a failure of this kind, but explicitly says EINVAL is for an invalid operation argument

It does not seem that flock() has been standardised.

No data to display

Actions

Also available in: Atom PDF