Baptiste Jonglez
2017-Sep-14 16:22 UTC
[klibc] [PATCH] nfsmount: support nfsvers= and vers= options
The standard mount option nowadays to specify NFS version is "nfsvers", as documented in nfs(5) on modern Linux systems. Up to now, nfsmount only supported the old "v2" or "v3" boolean options. Extend option parsing to support both "nfsvers=X" and "vers=X", with X being equal to either 2 or 3 (nfsmount does not support NFSv4 at present). If both the new option "nfsvers=X" and old option "vX" are passed, the version specified by "nfsvers" takes precedence. Tested with initramfs-tools on Debian stretch, it can now successfully mount the root on NFS using nfsmount, with the following kernel command line: root=/dev/nfs nfsroot=server:path,nfsvers=3 Without this patch, such a command line would cause Debian's initrd to loop with the following error message: Begin: Retrying nfs mount ... nfsmount: bad option 'nfsvers' Signed-off-by: Baptiste Jonglez <baptiste.jonglez at imag.fr> --- usr/kinit/nfsmount/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/usr/kinit/nfsmount/main.c b/usr/kinit/nfsmount/main.c index 36b29a5f..cca9e4ec 100644 --- a/usr/kinit/nfsmount/main.c +++ b/usr/kinit/nfsmount/main.c @@ -36,12 +36,15 @@ static struct nfs_mount_data mount_data = { }; int nfs_port; +int nfs_version; static struct int_opts { char *name; int *val; } int_opts[] = { {"port", &nfs_port}, + {"nfsvers", &nfs_version}, + {"vers", &nfs_version}, {"rsize", &mount_data.rsize}, {"wsize", &mount_data.wsize}, {"timeo", &mount_data.timeo}, @@ -129,6 +132,22 @@ static void parse_opts(char *opts) } } } + /* If new-style options "nfsvers=" or "vers=" are passed, override + old "v2" and "v3" options */ + if (nfs_version != 0) { + switch (nfs_version) { + case 2: + mount_data.flags &= ~NFS_MOUNT_VER3; + break; + case 3: + mount_data.flags |= NFS_MOUNT_VER3; + break; + default: + fprintf(stderr, "%s: bad NFS version '%d'\n", + progname, nfs_version); + longjmp(abort_buf, 1); + } + } } static uint32_t parse_addr(const char *ip) -- 2.11.0
Possibly Parallel Threads
- [klibc:master] nfsmount: support nfsvers= and vers= options
- [klibc:master] nfsmount: Use kernel client's default value for timeo option
- [klibc 14/43] Remove in-kernel nfsroot code
- [PATCH] use reliable nfs mount options per default
- [patch 11/12] Unpleasantness in linux/nfs_mount.h