diff options
author | Baptiste Jonglez <baptiste.jonglez@imag.fr> | 2017-09-14 09:22:21 -0700 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-01-02 03:08:04 +0000 |
commit | c4b811a1e4647224ddc717fac59900d16d0e9d4d (patch) | |
tree | faf0ff22df1302ed587ca9a0ca8ffe5db1e5174e | |
parent | 6b621b8705ce5901dcf49607c8a3523c9e521901 (diff) | |
download | klibc-c4b811a1e4647224ddc717fac59900d16d0e9d4d.tar.gz |
[klibc] 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@imag.fr>
Link: https://www.zytor.com/pipermail/klibc/2017-September/003959.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/kinit/nfsmount/main.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr/kinit/nfsmount/main.c b/usr/kinit/nfsmount/main.c index 36b29a5f9805f9..cca9e4ec582ad9 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) |