@@ -115,6 +115,7 @@ struct nfs_parsed_mount_data {
struct security_mnt_opts lsm_opts;
struct net *net;
+ struct vfsmount *root_mnt;
};
/* mount_clnt.c */
@@ -373,6 +374,7 @@ extern struct file_system_type nfs_xdev_fs_type;
extern struct file_system_type nfs4_xdev_fs_type;
extern struct file_system_type nfs4_referral_fs_type;
#endif
+extern struct vfsmount *nfs_get_root_mnt(int vers, char *raw_data);
bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t);
struct dentry *nfs_try_mount(int, const char *, struct nfs_mount_info *,
struct nfs_subversion *);
@@ -252,6 +252,8 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name,
res = nfs_follow_remote_path(root_mnt, export_path);
+ data->root_mnt = root_mnt;
+
dfprintk(MOUNT, "<-- nfs4_try_mount() = %d%s\n",
PTR_ERR_OR_ZERO(res),
IS_ERR(res) ? " [error]" : "");
@@ -2608,6 +2608,32 @@ error_splat_super:
}
EXPORT_SYMBOL_GPL(nfs_fs_mount_common);
+static void nfs_set_root_mnt(struct file_system_type *fs_type, void *raw_data,
+ struct nfs_parsed_mount_data *pdata)
+{
+ if (fs_type == &nfs4_fs_type) {
+ struct nfs4_mount_data *data =
+ (struct nfs4_mount_data *)raw_data;
+ dprintk("%s pdata->root_mnt %p\n", __func__, pdata->root_mnt);
+ data->root_mnt = pdata->root_mnt;
+ }
+}
+
+struct vfsmount *nfs_get_root_mnt(int vers, char *raw_data)
+{
+ struct vfsmount *mnt = ERR_PTR(-EINVAL);
+
+ if (vers == 4) {
+ struct nfs4_mount_data *data =
+ (struct nfs4_mount_data *)raw_data;
+
+ dprintk("%s data->root_mnt %p\n", __func__, data->root_mnt);
+ mnt = data->root_mnt;
+ }
+ return mnt;
+}
+EXPORT_SYMBOL_GPL(nfs_get_root_mnt);
+
struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *raw_data)
{
@@ -2640,6 +2666,7 @@ struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
}
mntroot = nfs_mod->rpc_ops->try_mount(flags, dev_name, &mount_info, nfs_mod);
+ nfs_set_root_mnt(nfs_mod->nfs_fs, raw_data, mount_info.parsed);
put_nfs_version(nfs_mod);
out:
@@ -53,6 +53,7 @@ struct nfs4_mount_data {
/* Pseudo-flavours to use for authentication. See RFC2623 */
int auth_flavourlen; /* 1 */
int __user *auth_flavours; /* 1 */
+ struct vfsmount *root_mnt; /* 2 */
};
/* bits in the flags field */