diff options
author | Jan Kara <jack@suse.cz> | 2011-09-02 19:09:43 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-04-20 17:59:01 -0400 |
commit | 98a2139f4f4d7b5fcc3a54c7fddbe88612abed20 (patch) | |
tree | 99f94d7fabedefbae0a6e40a1c8f485171616565 /fs/nfs/super.c | |
parent | 8ccd271f7a3a846ce6f85ead0760d9d12994a611 (diff) |
nfs: Enclose hostname in brackets when needed in nfs_do_root_mount
When hostname contains colon (e.g. when it is an IPv6 address) it needs
to be enclosed in brackets to make parsing of NFS device string possible.
Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS code
actually does not need this as it does not parse the string passed by
nfs_do_root_mount() but the device string is exposed to userspace in
/proc/mounts.
CC: Josh Boyer <jwboyer@redhat.com>
CC: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 37412f706b32..1e6715f0616c 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2767,11 +2767,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type, | |||
2767 | char *root_devname; | 2767 | char *root_devname; |
2768 | size_t len; | 2768 | size_t len; |
2769 | 2769 | ||
2770 | len = strlen(hostname) + 3; | 2770 | len = strlen(hostname) + 5; |
2771 | root_devname = kmalloc(len, GFP_KERNEL); | 2771 | root_devname = kmalloc(len, GFP_KERNEL); |
2772 | if (root_devname == NULL) | 2772 | if (root_devname == NULL) |
2773 | return ERR_PTR(-ENOMEM); | 2773 | return ERR_PTR(-ENOMEM); |
2774 | snprintf(root_devname, len, "%s:/", hostname); | 2774 | /* Does hostname needs to be enclosed in brackets? */ |
2775 | if (strchr(hostname, ':')) | ||
2776 | snprintf(root_devname, len, "[%s]:/", hostname); | ||
2777 | else | ||
2778 | snprintf(root_devname, len, "%s:/", hostname); | ||
2775 | root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); | 2779 | root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); |
2776 | kfree(root_devname); | 2780 | kfree(root_devname); |
2777 | return root_mnt; | 2781 | return root_mnt; |