Subject: Re: bug in NFS_V2_ONLY option
To: Ben Harris <>
From: Christian Groessler <>
List: current-users
Date: 04/28/2001 13:31:11
On 04/24/2001 12:18:41 AM CET Ben Harris wrote:
>>It generates a v3 mount even if the kernel doesn't understand v3
>>(NFS_V2_ONLY). One thing that then fails seems to be the getcwd()
>Ah.  I'd hoped I could get away without having to teach mount_nfs about
>NFS_V2_ONLY.  Clearly I was wrong.  I suspect this means that either mount()
>needs to fail if mount_nfs passes a version the kernel doesn't support, or
>there needs to be a way for mount_nfs to ask the kernel what version it
>prefers (or probably both).
>If anyone wants to sort out a fix for this, I'd be grateful.  I'm rather
>busy with ARM stuff at the moment.


I think the mount syscall should fail if it requests v3, but the
kernel understands v2 only. This is better than silently mounting v2.
This is the change to the kernel code:

diff -u -p -r1.101 nfs_vfsops.c
--- nfs_vfsops.c        2001/02/12 20:02:30     1.101
+++ nfs_vfsops.c        2001/04/25 21:01:32
@@ -564,7 +564,9 @@ nfs_mount(mp, path, data, ndp, p)
        if (args.version != NFS_ARGSVERSION)
                return (EPROGMISMATCH);
 #ifdef NFS_V2_ONLY
-       args.flags &= ~(NFSMNT_NFSV3 | NFSMNT_NQNFS);
+       if (args.flags & (NFSMNT_NFSV3 | NFSMNT_NQNFS)) {
+               return (EPROTONOSUPPORT);
+       }
        if (mp->mnt_flag & MNT_UPDATE) {
                struct nfsmount *nmp = VFSTONFS(mp);

I now tried to change mount_nfs to use v2 if the mount syscall failed,
but it didn't work. Probably because of my ignorance of rpc calls and
nfs protocol.
Anyway, I think the cleaner approach would be if mount_nfs asks the
kernel what nfs it understands before contacting the nfs server.
How should this query be implemented? Additional syscall?