file locking

Sergey Uvarov uvarovsl at
Wed Jul 27 23:45:37 GMT 2005

Hello hackers,

man page for flock(2) and fcntl(2) reads that a system call returns 
EOPNOTSUPP if file descriptor refers to an object that does not support 
file locking.

However, it seems that it is not always true. For example, if underlying 
object is a device or a fifo returned error code depends on type of lock.

When I look at sources of VOP_ADVLOCK for fifo 
(sys/fs/fifofs/fifo_vnops.c, fifo_advlock() function) I see
the following line:

return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL);

I.e. for freebsd locks EOPNOTSUPP error code is returned. It is correct.
But for posix locks EINVAL error code is returned. Is it correct?

Thanks you in advance,

More information about the freebsd-hackers mailing list