From patchwork Fri Sep 2 23:09:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 1123022 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p82N9r13011429 for ; Fri, 2 Sep 2011 23:09:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756464Ab1IBXJw (ORCPT ); Fri, 2 Sep 2011 19:09:52 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39258 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756517Ab1IBXJv (ORCPT ); Fri, 2 Sep 2011 19:09:51 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id D4C248B013; Sat, 3 Sep 2011 01:09:50 +0200 (CEST) Received: by quack.suse.cz (Postfix, from userid 1000) id F209120588; Sat, 3 Sep 2011 01:09:49 +0200 (CEST) From: Jan Kara To: Trond Myklebust Cc: linux-nfs@vger.kernel.org, Jan Kara , Josh Boyer , Trond Myklebust Subject: [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount Date: Sat, 3 Sep 2011 01:09:43 +0200 Message-Id: <1315004983-10271-1-git-send-email-jack@suse.cz> X-Mailer: git-send-email 1.7.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 02 Sep 2011 23:09:55 +0000 (UTC) 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 --- 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 b961cea..42b74f8 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2694,11 +2694,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;