From: Jan Kara Date: Fri, 2 Sep 2011 23:09:43 +0000 (+0200) Subject: nfs: Enclose hostname in brackets when needed in nfs_do_root_mount X-Git-Tag: v3.2.17~80 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=bcd008fcd3c3d6e50ffc4eb5cf6b7f25f3d1d1dd nfs: Enclose hostname in brackets when needed in nfs_do_root_mount commit 98a2139f4f4d7b5fcc3a54c7fddbe88612abed20 upstream. 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 CC: Trond Myklebust Signed-off-by: Jan Kara Signed-off-by: Trond Myklebust Signed-off-by: Ben Hutchings --- diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 3ada13c9986a..376cd65e0ed4 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2708,11 +2708,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type, char *root_devname; size_t len; - len = strlen(hostname) + 3; + len = strlen(hostname) + 5; root_devname = kmalloc(len, GFP_KERNEL); if (root_devname == NULL) return ERR_PTR(-ENOMEM); - snprintf(root_devname, len, "%s:/", hostname); + /* Does hostname needs to be enclosed in brackets? */ + if (strchr(hostname, ':')) + snprintf(root_devname, len, "[%s]:/", hostname); + else + snprintf(root_devname, len, "%s:/", hostname); root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); kfree(root_devname); return root_mnt;