From b88f8a546f5dba213938fdfc11e66bc5c2421623 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Mon, 22 Jun 2009 15:09:14 -0400 Subject: [PATCH 5/5] NFS: Correct the NFS mount path when following a referral Signed-off-by: Trond Myklebust Signed-off-by: Linus Torvalds Acked-by: NeilBrown --- fs/nfs/super.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- linux-2.6.27-SLE11_BRANCH.orig/fs/nfs/super.c +++ linux-2.6.27-SLE11_BRANCH/fs/nfs/super.c @@ -2420,6 +2420,27 @@ static struct vfsmount *nfs_do_root_moun return root_mnt; } +static void nfs_fix_devname(const struct path *path, struct vfsmount *mnt) +{ + char *page = (char *) __get_free_page(GFP_KERNEL); + char *devname, *tmp; + + if (page == NULL) + return; + devname = nfs_path(path->mnt->mnt_devname, + path->mnt->mnt_root, path->dentry, + page, PAGE_SIZE); + if (devname == NULL) + goto out_freepage; + tmp = kstrdup(devname, GFP_KERNEL); + if (tmp == NULL) + goto out_freepage; + kfree(mnt->mnt_devname); + mnt->mnt_devname = tmp; +out_freepage: + free_page((unsigned long)page); +} + static int nfs_follow_remote_path(struct vfsmount *root_mnt, const char *export_path, struct vfsmount *mnt_target) { @@ -2446,6 +2467,9 @@ static int nfs_follow_remote_path(struct mnt_target->mnt_sb = s; mnt_target->mnt_root = dget(nd.path.dentry); + /* Correct the device pathname */ + nfs_fix_devname(&nd.path, mnt_target); + path_put(&nd.path); down_write(&s->s_umount); return 0;