Commit cdd16d02 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro

[patch 2/3] vfs: dcache cleanups

Comment from Al Viro: add prepend_name() wrapper.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 31f3e0b3
...@@ -1747,8 +1747,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) ...@@ -1747,8 +1747,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
BUG(); BUG();
} }
static int prepend(char **buffer, int *buflen, const char *str, static int prepend(char **buffer, int *buflen, const char *str, int namelen)
int namelen)
{ {
*buflen -= namelen; *buflen -= namelen;
if (*buflen < 0) if (*buflen < 0)
...@@ -1758,6 +1757,11 @@ static int prepend(char **buffer, int *buflen, const char *str, ...@@ -1758,6 +1757,11 @@ static int prepend(char **buffer, int *buflen, const char *str,
return 0; return 0;
} }
static int prepend_name(char **buffer, int *buflen, struct qstr *name)
{
return prepend(buffer, buflen, name->name, name->len);
}
/** /**
* __d_path - return the path of a dentry * __d_path - return the path of a dentry
* @path: the dentry/vfsmount to report * @path: the dentry/vfsmount to report
...@@ -1780,8 +1784,8 @@ char *__d_path(const struct path *path, struct path *root, ...@@ -1780,8 +1784,8 @@ char *__d_path(const struct path *path, struct path *root,
{ {
struct dentry *dentry = path->dentry; struct dentry *dentry = path->dentry;
struct vfsmount *vfsmnt = path->mnt; struct vfsmount *vfsmnt = path->mnt;
char * end = buffer+buflen; char *end = buffer + buflen;
char * retval; char *retval;
spin_lock(&vfsmount_lock); spin_lock(&vfsmount_lock);
prepend(&end, &buflen, "\0", 1); prepend(&end, &buflen, "\0", 1);
...@@ -1811,8 +1815,7 @@ char *__d_path(const struct path *path, struct path *root, ...@@ -1811,8 +1815,7 @@ char *__d_path(const struct path *path, struct path *root,
} }
parent = dentry->d_parent; parent = dentry->d_parent;
prefetch(parent); prefetch(parent);
if ((prepend(&end, &buflen, dentry->d_name.name, if ((prepend_name(&end, &buflen, &dentry->d_name) != 0) ||
dentry->d_name.len) != 0) ||
(prepend(&end, &buflen, "/", 1) != 0)) (prepend(&end, &buflen, "/", 1) != 0))
goto Elong; goto Elong;
retval = end; retval = end;
...@@ -1825,8 +1828,7 @@ char *__d_path(const struct path *path, struct path *root, ...@@ -1825,8 +1828,7 @@ char *__d_path(const struct path *path, struct path *root,
global_root: global_root:
retval += 1; /* hit the slash */ retval += 1; /* hit the slash */
if (prepend(&retval, &buflen, dentry->d_name.name, if (prepend_name(&retval, &buflen, &dentry->d_name) != 0)
dentry->d_name.len) != 0)
goto Elong; goto Elong;
root->mnt = vfsmnt; root->mnt = vfsmnt;
root->dentry = dentry; root->dentry = dentry;
...@@ -1918,16 +1920,11 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen) ...@@ -1918,16 +1920,11 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen)
retval = end-1; retval = end-1;
*retval = '/'; *retval = '/';
for (;;) { while (!IS_ROOT(dentry)) {
struct dentry *parent; struct dentry *parent = dentry->d_parent;
if (IS_ROOT(dentry))
break;
parent = dentry->d_parent;
prefetch(parent); prefetch(parent);
if ((prepend_name(&end, &buflen, &dentry->d_name) != 0) ||
if ((prepend(&end, &buflen, dentry->d_name.name,
dentry->d_name.len) != 0) ||
(prepend(&end, &buflen, "/", 1) != 0)) (prepend(&end, &buflen, "/", 1) != 0))
goto Elong; goto Elong;
...@@ -1978,7 +1975,7 @@ asmlinkage long sys_getcwd(char __user *buf, unsigned long size) ...@@ -1978,7 +1975,7 @@ asmlinkage long sys_getcwd(char __user *buf, unsigned long size)
error = -ENOENT; error = -ENOENT;
/* Has the current directory has been unlinked? */ /* Has the current directory has been unlinked? */
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (pwd.dentry->d_parent == pwd.dentry || !d_unhashed(pwd.dentry)) { if (IS_ROOT(pwd.dentry) || !d_unhashed(pwd.dentry)) {
unsigned long len; unsigned long len;
struct path tmp = root; struct path tmp = root;
char * cwd; char * cwd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment