diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2010-08-10 05:41:40 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-11 00:28:21 -0400 |
commit | ffd1f4ed5bddccf2277e3d8525bcedf1983319f8 (patch) | |
tree | 2a1b08b204820ba0e9ecb7397ee7a08daff01594 | |
parent | f2eb6575d5beba1e98d400463007d77555d1fc35 (diff) |
vfs: only add " (deleted)" where necessary
__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>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/dcache.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index d09d93819b4d..7fccb00f498d 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1979,8 +1979,7 @@ global_root: | |||
1979 | * @buffer: buffer to return value in | 1979 | * @buffer: buffer to return value in |
1980 | * @buflen: buffer length | 1980 | * @buflen: buffer length |
1981 | * | 1981 | * |
1982 | * Convert a dentry into an ASCII path name. If the entry has been deleted | 1982 | * Convert a dentry into an ASCII path name. |
1983 | * the string " (deleted)" is appended. Note that this is ambiguous. | ||
1984 | * | 1983 | * |
1985 | * Returns a pointer into the buffer or an error code if the | 1984 | * Returns a pointer into the buffer or an error code if the |
1986 | * path was too long. | 1985 | * path was too long. |
@@ -1997,12 +1996,6 @@ char *__d_path(const struct path *path, struct path *root, | |||
1997 | int error; | 1996 | int error; |
1998 | 1997 | ||
1999 | prepend(&res, &buflen, "\0", 1); | 1998 | prepend(&res, &buflen, "\0", 1); |
2000 | if (d_unlinked(path->dentry)) { | ||
2001 | error = prepend(&res, &buflen, " (deleted)", 10); | ||
2002 | if (error) | ||
2003 | return ERR_PTR(error); | ||
2004 | } | ||
2005 | |||
2006 | error = prepend_path(path, root, &res, &buflen); | 1999 | error = prepend_path(path, root, &res, &buflen); |
2007 | if (error) | 2000 | if (error) |
2008 | return ERR_PTR(error); | 2001 | return ERR_PTR(error); |
@@ -2010,6 +2003,22 @@ char *__d_path(const struct path *path, struct path *root, | |||
2010 | return res; | 2003 | return res; |
2011 | } | 2004 | } |
2012 | 2005 | ||
2006 | /* | ||
2007 | * same as __d_path but appends "(deleted)" for unlinked files. | ||
2008 | */ | ||
2009 | static int path_with_deleted(const struct path *path, struct path *root, | ||
2010 | char **buf, int *buflen) | ||
2011 | { | ||
2012 | prepend(buf, buflen, "\0", 1); | ||
2013 | if (d_unlinked(path->dentry)) { | ||
2014 | int error = prepend(buf, buflen, " (deleted)", 10); | ||
2015 | if (error) | ||
2016 | return error; | ||
2017 | } | ||
2018 | |||
2019 | return prepend_path(path, root, buf, buflen); | ||
2020 | } | ||
2021 | |||
2013 | /** | 2022 | /** |
2014 | * d_path - return the path of a dentry | 2023 | * d_path - return the path of a dentry |
2015 | * @path: path to report | 2024 | * @path: path to report |
@@ -2028,9 +2037,10 @@ char *__d_path(const struct path *path, struct path *root, | |||
2028 | */ | 2037 | */ |
2029 | char *d_path(const struct path *path, char *buf, int buflen) | 2038 | char *d_path(const struct path *path, char *buf, int buflen) |
2030 | { | 2039 | { |
2031 | char *res; | 2040 | char *res = buf + buflen; |
2032 | struct path root; | 2041 | struct path root; |
2033 | struct path tmp; | 2042 | struct path tmp; |
2043 | int error; | ||
2034 | 2044 | ||
2035 | /* | 2045 | /* |
2036 | * We have various synthetic filesystems that never get mounted. On | 2046 | * We have various synthetic filesystems that never get mounted. On |
@@ -2045,7 +2055,9 @@ char *d_path(const struct path *path, char *buf, int buflen) | |||
2045 | get_fs_root(current->fs, &root); | 2055 | get_fs_root(current->fs, &root); |
2046 | spin_lock(&dcache_lock); | 2056 | spin_lock(&dcache_lock); |
2047 | tmp = root; | 2057 | tmp = root; |
2048 | res = __d_path(path, &tmp, buf, buflen); | 2058 | error = path_with_deleted(path, &tmp, &res, &buflen); |
2059 | if (error) | ||
2060 | res = ERR_PTR(error); | ||
2049 | spin_unlock(&dcache_lock); | 2061 | spin_unlock(&dcache_lock); |
2050 | path_put(&root); | 2062 | path_put(&root); |
2051 | return res; | 2063 | return res; |