Subject: Re: Is O_EXCL in open(2) broken over NFS ?
To: Aidan Cully <>
From: Manuel Bouyer <>
List: tech-userlevel
Date: 07/23/2000 22:26:32
On Sun, Jul 23, 2000 at 01:57:55PM -0400, Aidan Cully wrote:
> Interestingly enough, I just looked at NetBSD's implementation of
> O_EXCL over NFS, and saw the following:
>                 if (v3 && (fmode & O_EXCL) && error == NFSERR_NOTSUPP) {
>                         fmode &= ~O_EXCL;
>                         goto again;
>                 }
> So, if the server doesn't support the NFSV3CREATE_EXCLUSIVE operation,

It would be a lame server then :)

> NetBSD silently tries again without the O_EXCL bit set.  I don't know
> what the proper solution for NetBSD is, here...  I know that what we
> did at my old job was to call 'open' on a guaranteed unique filename,
> and then link()/unlink() it into place, since NFS couldn't guarantee
> O_EXCL processing, but could guarantee that link() would fail if the
> file already existed.  At the least, I'd hope that an #ifdef NFS_DIAG
> (or something) could do a
> printf("nfs_create: O_EXCL operation not supported by server.");
> to let the user know at some level that O_EXCL isn't doing what sie
> thinks it is.

Sure, or maybe the syscall should fail with EOPNOTSUPP. Dropping O_EXCL
silently isn't a good thing.

Manuel Bouyer <>