Jails on NFS: locks on file

Valerio Daelli vdaelli at hotmail.com
Thu Jun 9 09:12:33 GMT 2005

Hi all,
we are using FreeBSD 5.4 with some jails.
One of this jail is on a NFS directory - I mean: the whole filesystem of 
this jail is on a remote directory, exported by a FreeBSD 5.4 server with 
NFS, and the 'host' system (the one that started and stopped the jail) 
mounts it via NFS. In this jail we can't perform a 'flock' operation, even 
if the NFS server has rpc.lockd and rpc.statd. We built a little executable 
in C like this (let's call it myflock):

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>

int main() {
  int lockfd;
  char* tempfile="tempfile";

  if (flock(lockfd, LOCK_SH|LOCK_NB)==-1) {
    printf("ERROR shared lock:  %d",errno);
  if (flock(lockfd, LOCK_EX|LOCK_NB)==-1) {
    printf("ERROR exclusive lock:  %d",errno);

We executed on a local directory and it gets the flock.
We executed on the mounted NFS partition (with rpc.lockd and rpc.statd) and 
it works.
We executed in the jail-NFS and it fails! Errno 45 (from 
'/usr/include/errno.h': #define EOPNOTSUPP      45              /* Operation 
not supported */). The directory where we launch myflock is the same as the 
previous command (no permission problems).
We executed in a jail contained in a md mounted on a NFS directory and it 
Could it be a rpcbind issue (the jail can't get the flock since it can't 
rpc-contact the NFS server)?
Thanks a lot

Valerio Daelli

More information about the freebsd-questions mailing list