From patchwork Sun Oct 21 18:23:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 1623011 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id AEB61DFFF1 for ; Sun, 21 Oct 2012 18:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932132Ab2JUSYP (ORCPT ); Sun, 21 Oct 2012 14:24:15 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:58291 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932353Ab2JUSYO (ORCPT ); Sun, 21 Oct 2012 14:24:14 -0400 Received: from [2001:470:1f08:1539:21c:bfff:fe03:f805] (helo=deadeye.wl.decadent.org.uk) by shadbolt.decadent.org.uk with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TQ0Bs-0004lr-Pf; Sun, 21 Oct 2012 19:24:00 +0100 Received: from ben by deadeye.wl.decadent.org.uk with local (Exim 4.80) (envelope-from ) id 1TQ0Bq-0006U0-PQ; Sun, 21 Oct 2012 19:23:58 +0100 Message-ID: <1350843832.22276.34.camel@deadeye.wl.decadent.org.uk> Subject: [PATCH] nfs: Show original device name verbatim in /proc/*/mount{s,info} From: Ben Hutchings To: Trond Myklebust Cc: 669314@bugs.debian.org, viro@zeniv.linux.org.uk, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Micheal Waltz , Gabriel Evanoff , Jonathan Nieder Date: Sun, 21 Oct 2012 19:23:52 +0100 In-Reply-To: <7941E5E1-488D-4D0B-A21A-4E389EF6EBBA@salk.edu> References: <7941E5E1-488D-4D0B-A21A-4E389EF6EBBA@salk.edu> X-Mailer: Evolution 3.4.3-1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 2001:470:1f08:1539:21c:bfff:fe03:f805 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Since commit c7f404b ('vfs: new superblock methods to override /proc/*/mount{s,info}'), nfs_path() is used to generate the mounted device name reported back to userland. nfs_path() always generates a trailing slash when the given dentry is the root of an NFS mount, but userland may expect the original device name to be returned verbatim (as it used to be). Make this canonicalisation optional and change the callers accordingly. Reported-and-tested-by: Chris Hiestand Reference: http://bugs.debian.org/669314 Signed-off-by: Ben Hutchings Cc: # v2.6.39+ --- fs/nfs/internal.h | 4 ++-- fs/nfs/namespace.c | 15 ++++++++++----- fs/nfs/nfs4namespace.c | 2 +- fs/nfs/super.c | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 31fdb03..5eaf902 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -354,7 +354,7 @@ extern void nfs_sb_deactive(struct super_block *sb); /* namespace.c */ extern char *nfs_path(char **p, struct dentry *dentry, - char *buffer, ssize_t buflen); + char *buffer, ssize_t buflen, bool canonical); extern struct vfsmount *nfs_d_automount(struct path *path); struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *, struct nfs_fh *, struct nfs_fattr *); @@ -491,7 +491,7 @@ static inline char *nfs_devname(struct dentry *dentry, char *buffer, ssize_t buflen) { char *dummy; - return nfs_path(&dummy, dentry, buffer, buflen); + return nfs_path(&dummy, dentry, buffer, buflen, true); } /* diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c index 6559253..059975e 100644 --- a/fs/nfs/namespace.c +++ b/fs/nfs/namespace.c @@ -33,6 +33,8 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; * @dentry - pointer to dentry * @buffer - result buffer * @buflen - length of buffer + * @canonical - ensure there is exactly one slash after the original + * device (export) name; if false, return it verbatim * * Helper function for constructing the server pathname * by arbitrary hashed dentry. @@ -41,7 +43,8 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; * server side when automounting on top of an existing partition * and in generating /proc/mounts and friends. */ -char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen) +char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen, + bool canonical) { char *end; int namelen; @@ -74,7 +77,7 @@ rename_retry: rcu_read_unlock(); goto rename_retry; } - if (*end != '/') { + if (canonical && *end != '/') { if (--buflen < 0) { spin_unlock(&dentry->d_lock); rcu_read_unlock(); @@ -91,9 +94,11 @@ rename_retry: return end; } namelen = strlen(base); - /* Strip off excess slashes in base string */ - while (namelen > 0 && base[namelen - 1] == '/') - namelen--; + if (canonical) { + /* Strip off excess slashes in base string */ + while (namelen > 0 && base[namelen - 1] == '/') + namelen--; + } buflen -= namelen; if (buflen < 0) { spin_unlock(&dentry->d_lock); diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c index 017b4b0..94e8652 100644 --- a/fs/nfs/nfs4namespace.c +++ b/fs/nfs/nfs4namespace.c @@ -81,7 +81,7 @@ static char *nfs_path_component(const char *nfspath, const char *end) static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen) { char *limit; - char *path = nfs_path(&limit, dentry, buffer, buflen); + char *path = nfs_path(&limit, dentry, buffer, buflen, true); if (!IS_ERR(path)) { char *path_component = nfs_path_component(path, limit); if (path_component) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index ac6a3c5..6087ed0 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -730,7 +730,7 @@ int nfs_show_devname(struct seq_file *m, struct dentry *root) int err = 0; if (!page) return -ENOMEM; - devname = nfs_path(&dummy, root, page, PAGE_SIZE); + devname = nfs_path(&dummy, root, page, PAGE_SIZE, false); if (IS_ERR(devname)) err = PTR_ERR(devname); else