Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208888
b: refs/heads/master
c: ffd1f4e
h: refs/heads/master
v: v3
  • Loading branch information
Miklos Szeredi authored and Al Viro committed Aug 11, 2010
1 parent 6525baa commit 07dd9bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f2eb6575d5beba1e98d400463007d77555d1fc35
refs/heads/master: ffd1f4ed5bddccf2277e3d8525bcedf1983319f8
32 changes: 22 additions & 10 deletions trunk/fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1979,8 +1979,7 @@ static int prepend_path(const struct path *path, struct path *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.
Expand All @@ -1997,19 +1996,29 @@ char *__d_path(const struct path *path, struct path *root,
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);

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
Expand All @@ -2028,9 +2037,10 @@ char *__d_path(const struct path *path, struct path *root,
*/
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
Expand All @@ -2045,7 +2055,9 @@ char *d_path(const struct path *path, char *buf, int buflen)
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;
Expand Down

0 comments on commit 07dd9bd

Please sign in to comment.