mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@ftp.linux.org.uk, akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] vfs: only add " (deleted)" where necessary
Date: Tue, 06 Jul 2010 19:40:34 +0200	[thread overview]
Message-ID: <20100706174100.239755003@szeredi.hu> (raw)
In-Reply-To: <20100706174028.287568350@szeredi.hu>

[-- Attachment #1: vfs-d_path-move-deleted-into-callers.patch --]
[-- Type: text/plain, Size: 2786 bytes --]

__d_path() has 4 callers:

  d_path()
  sys_getcwd()
  seq_path_root()
  tomoyo_realpath_from_path2()

Of these the only one which needs the " (deleted)" ending is d_path().

sys_getcwd() checks for existence before calling __d_path().

seq_path_root() is used to show the mountpoint path in
/proc/PID/mountinfo, which is always a positive.

And tomoyo doesn't want the deleted ending.

Create a helper "path_with_deleted()" as subsequent patches will need
this in multiple places.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/dcache.c |   32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

Index: linux-2.6/fs/dcache.c
===================================================================
--- linux-2.6.orig/fs/dcache.c	2010-07-06 18:08:16.000000000 +0200
+++ linux-2.6/fs/dcache.c	2010-07-06 18:08:19.000000000 +0200
@@ -1977,8 +1977,7 @@ global_root:
  * @buffer: buffer to return value in
  * @buflen: buffer length
  *
- * Convert a dentry into an ASCII path name. If the entry has been deleted
- * the string " (deleted)" is appended. Note that this is ambiguous.
+ * Convert a dentry into an ASCII path name.
  *
  * Returns a pointer into the buffer or an error code if the
  * path was too long.
@@ -1995,12 +1994,6 @@ char *__d_path(const struct path *path,
 	int error;
 
 	prepend(&res, &buflen, "\0", 1);
-	if (d_unlinked(path->dentry)) {
-		error = prepend(&res, &buflen, " (deleted)", 10);
-		if (error)
-			return ERR_PTR(error);
-	}
-
 	error = prepend_path(path, root, &res, &buflen);
 	if (error)
 		return ERR_PTR(error);
@@ -2008,6 +2001,22 @@ char *__d_path(const struct path *path,
 	return res;
 }
 
+/*
+ * same as __d_path but appends "(deleted)" for unlinked files.
+ */
+static int path_with_deleted(const struct path *path, struct path *root,
+				 char **buf, int *buflen)
+{
+	prepend(buf, buflen, "\0", 1);
+	if (d_unlinked(path->dentry)) {
+		int error = prepend(buf, buflen, " (deleted)", 10);
+		if (error)
+			return error;
+	}
+
+	return prepend_path(path, root, buf, buflen);
+}
+
 /**
  * d_path - return the path of a dentry
  * @path: path to report
@@ -2026,9 +2035,10 @@ char *__d_path(const struct path *path,
  */
 char *d_path(const struct path *path, char *buf, int buflen)
 {
-	char *res;
+	char *res = buf + buflen;
 	struct path root;
 	struct path tmp;
+	int error;
 
 	/*
 	 * We have various synthetic filesystems that never get mounted.  On
@@ -2043,7 +2053,9 @@ char *d_path(const struct path *path, ch
 	get_fs_root(current->fs, &root);
 	spin_lock(&dcache_lock);
 	tmp = root;
-	res = __d_path(path, &tmp, buf, buflen);
+	error = path_with_deleted(path, &tmp, &res, &buflen);
+	if (error)
+		res = ERR_PTR(error);
 	spin_unlock(&dcache_lock);
 	path_put(&root);
 	return res;

-- 

  parent reply	other threads:[~2010-07-06 17:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 17:40 [PATCH 0/7] dcache fixes and cleanups Miklos Szeredi
2010-07-06 17:40 ` [PATCH 1/7] cachefiles: use path_get instead of lone dget Miklos Szeredi
2010-07-06 17:40 ` [PATCH 2/7] vfs: add helpers to get root and pwd Miklos Szeredi
2010-07-06 17:40 ` [PATCH 3/7] ia64: perfmon: add d_dname method Miklos Szeredi
2010-07-06 17:40 ` [PATCH 4/7] vfs: __d_path: dont prepend the name of the root dentry Miklos Szeredi
2010-07-06 17:40 ` [PATCH 5/7] vfs: add prepend_path() helper Miklos Szeredi
2010-07-06 17:40 ` Miklos Szeredi [this message]
2010-07-06 17:40 ` [PATCH 7/7] vfs: show unreachable paths in getcwd and proc Miklos Szeredi
2010-08-02 11:19 [PATCH 0/7] dcache fixes and cleanups Miklos Szeredi
2010-08-02 11:20 ` [PATCH 6/7] vfs: only add " (deleted)" where necessary Miklos Szeredi
2010-08-02 13:00   ` Valdis.Kletnieks
2010-08-02 13:21     ` Bastien ROUCARIES
2010-08-02 13:37       ` Miklos Szeredi
2010-08-02 13:35     ` Miklos Szeredi
2010-08-02 15:11       ` Valdis.Kletnieks
2010-08-10  9:41 [PATCH 0/7] dcache fixes and cleanups Miklos Szeredi
2010-08-10  9:41 ` [PATCH 6/7] vfs: only add " (deleted)" where necessary Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100706174100.239755003@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®