// SPDX-License-Identifier: GPL-2.0-only
/*
* linux/fs/nfs/fs_context.c
*
* Copyright (C) 1992 Rick Sladkey
* Conversion to new mount api Copyright (C) David Howells
*
* NFS mount handling.
*
* Split from fs/nfs/super.c by David Howells <dhowells@redhat.com>
*/
#include <linux/compat.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/nfs_fs.h>
#include <linux/nfs_mount.h>
#include <linux/nfs4_mount.h>
#include "nfs.h"
#include "internal.h"
#include "nfstrace.h"
#define NFSDBG_FACILITY NFSDBG_MOUNT
#if IS_ENABLED(CONFIG_NFS_V3)
#define NFS_DEFAULT_VERSION 3
#else
#define NFS_DEFAULT_VERSION 2
#endif
#define NFS_MAX_CONNECTIONS 16
enum nfs_param {
Opt_ac,
Opt_acdirmax,
Opt_acdirmin,
Opt_acl,
Opt_acregmax,
Opt_acregmin,
Opt_actimeo,
Opt_addr,
Opt_bg,
Opt_bsize,
Opt_clientaddr,
Opt_cto,
Opt_fg,
Opt_fscache,
Opt_fscache_flag,
Opt_hard,
Opt_intr,
Opt_local_lock,
Opt_lock,
Opt_lookupcache,
Opt_migration,
Opt_minorversion,
Opt_mountaddr,
Opt_mounthost,
Opt_mountport,
Opt_mountproto,
Opt_mountvers,
Opt_namelen,
Opt_nconnect,
Opt_max_connect,
Opt_port,
Opt_posix,
Opt_proto,
Opt_rdirplus,
Opt_rdma,
Opt_resvport,
Opt_retrans,
Opt_retry,
Opt_rsize,
Opt_sec,
Opt_sharecache,
Opt_sloppy,
Opt_soft,
Opt_softerr,
Opt_softreval,
Opt_source,
Opt_tcp,
Opt_timeo,
Opt_trunkdiscovery,
Opt_udp,
Opt_v,
Opt_vers,
Opt_wsize,
Opt_write,
};
enum {
Opt_local_lock_all,
Opt_local_lock_flock,
Opt_local_lock_none,
Opt_local_lock_posix,
};
static const struct constant_table nfs_param_enums_local_lock[] = {
{ "all", Opt_local_lock_all },
{ "flock", Opt_local_lock_flock },
{ "posix", Opt_local_lock_posix },
{ "none", Opt_local_lock_none },
{}
};
enum {
Opt_lookupcache_all,
Opt_lookupcache_none,
Opt_lookupcache_positive,
};
static const struct constant_table nfs_param_enums_lookupcache[] = {
{ "all", Opt_lookupcache_all },
{ "none", Opt_lookupcache_none },
{ "pos", Opt_lookupcache_positive },
{ "positive", Opt_lookupcache_positive },
{}
};
enum {
Opt_write_lazy,
Opt_write_eager,
Opt_write_wait,
};
static const struct constant_table nfs_param_enums_write[] = {
{ "lazy", Opt_write_lazy },
{ "eager", Opt_write_eager },
{ "wait", Opt_write_wait },
{}
};
static const struct fs_parameter_spec nfs_fs_parameters[] = {
fsparam_flag_no("ac", Opt_ac),
fsparam_u32 ("acdirmax", Opt_acdirmax),
fsparam_u32 ("acdirmin", Opt_acdirmin),
fsparam_flag_no("acl", Opt_acl),
fsparam_u32 ("acregmax", Opt_acregmax),
fsparam_u32 ("acregmin", Opt_acregmin),
fsparam_u32 ("actimeo", Opt_actimeo),
fsparam_string("addr", Opt_addr),
fsparam_flag ("bg", Opt_bg),
fsparam_u32 ("bsize", Opt_bsize),
fsparam_string("clientaddr", Opt_clientaddr),
fsparam_flag_no("cto", Opt_cto),
fsparam_flag ("fg", Opt_fg),
fsparam_flag_no("fsc", Opt_fscache_flag),
fsparam_string("fsc", Opt_fscache),
fsparam_flag ("hard", Opt_hard),
__fsparam(NULL, "intr", Opt_intr,
fs_param_neg_with_no|fs_param_deprecated, NULL),
fsparam_enum ("local_lock", Opt_local_lock, nfs_param_enums_local_lock),
fsparam_flag_no("lock", Opt_lock),
fsparam_enum ("lookupcache", Opt_lookupcache, nfs_param_enums_lookupcache),
fsparam_flag_no("migration", Opt_migration),
fsparam_u32 ("minorversion", Opt_minorversion),
fsparam_string("mountaddr", Opt_mountaddr),
fsparam_string("mounthost", Opt_mounthost),
fsparam_u32 ("mountport", Opt_mountport),
fsparam_string("mountproto", Opt_mountproto),
fsparam_u32 ("mountvers", Opt_mountvers),
fsparam_u32 ("namlen", Opt_namelen),
fsparam_u32 ("nconnect", Opt_nconnect),
fsparam_u32 ("max_connect", Opt_max_connect),
fsparam_string("nfsvers", Opt_vers),
fsparam_u32 ("port", Opt_port),
fsparam_flag_no("posix", Opt_posix),
fsparam_string("proto", Opt_proto),
fsparam_flag_no("rdirplus", Opt_rdirplus),
fsparam_flag ("rdma", Opt_rdma),
fsparam_flag_no("resvport", Opt_resvport),
fsparam_u32 ("retrans", Opt_retrans),
fsparam_string("retry", Opt_retry),
fsparam_u32 ("rsize", Opt_rsize),
fsparam_string("sec", Opt_sec),
fsparam_flag_no("sharecache", Opt_sharecache),
fsparam_flag ("sloppy", Opt_sloppy),
fsparam_flag ("soft", Opt_soft),
fsparam_flag ("softerr", Opt_softerr),
fsparam_flag ("softreval", Opt_softreval),
fsparam_string("source", Opt_source),
fsparam_flag ("tcp", Opt_tcp),
fsparam_u32 ("timeo", Opt_timeo),
fsparam_flag_no("trunkdiscovery", Opt_trunkdiscovery),
fsparam_flag ("udp", Opt_udp),
fsparam_flag ("v2", Opt_v),
fsparam_flag ("v3", Opt_v),
fsparam_flag ("v4", Opt_v),
fsparam_flag ("v4.0", Opt_v),
fsparam_flag ("v4.1", Opt_v),
fsparam_flag ("v4.2", Opt_v),
fsparam_string("vers", Opt_vers),
fsparam_enum ("write", Opt_write, nfs_param_enums_write),
fsparam_u32 ("wsize", Opt_wsize),
{}
};
enum {
Opt_vers_2,
Opt_vers_3,
Opt_vers_4,
Opt_vers_4_0,
Opt_vers_4_1,
Opt_vers_4_2,
};
static const struct constant_table nfs_vers_tokens[] = {
{ "2", Opt_vers_2 },
{ "3", Opt_vers_3 },
{ "4", Opt_vers_4 },
{ "4.0", Opt_vers_4_0 },
{ "4.1", Opt_vers_4_1 },
{ "4.2", Opt_vers_4_2 },
{}
};
enum {
Opt_xprt_rdma,
Opt_xp
|