aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/dcache.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index e4b2b9436b32..6068c25b393c 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1747,8 +1747,7 @@ shouldnt_be_hashed:
1747 BUG(); 1747 BUG();
1748} 1748}
1749 1749
1750static int prepend(char **buffer, int *buflen, const char *str, 1750static int prepend(char **buffer, int *buflen, const char *str, int namelen)
1751 int namelen)
1752{ 1751{
1753 *buflen -= namelen; 1752 *buflen -= namelen;
1754 if (*buflen < 0) 1753 if (*buflen < 0)
@@ -1758,6 +1757,11 @@ static int prepend(char **buffer, int *buflen, const char *str,
1758 return 0; 1757 return 0;
1759} 1758}
1760 1759
1760static int prepend_name(char **buffer, int *buflen, struct qstr *name)
1761{
1762 return prepend(buffer, buflen, name->name, name->len);
1763}
1764
1761/** 1765/**
1762 * __d_path - return the path of a dentry 1766 * __d_path - return the path of a dentry
1763 * @path: the dentry/vfsmount to report 1767 * @path: the dentry/vfsmount to report
@@ -1780,8 +1784,8 @@ char *__d_path(const struct path *path, struct path *root,
1780{ 1784{
1781 struct dentry *dentry = path->dentry; 1785 struct dentry *dentry = path->dentry;
1782 struct vfsmount *vfsmnt = path->mnt; 1786 struct vfsmount *vfsmnt = path->mnt;
1783 char * end = buffer+buflen; 1787 char *end = buffer + buflen;
1784 char * retval; 1788 char *retval;
1785 1789
1786 spin_lock(&vfsmount_lock); 1790 spin_lock(&vfsmount_lock);
1787 prepend(&end, &buflen, "\0", 1); 1791 prepend(&end, &buflen, "\0", 1);
@@ -1811,8 +1815,7 @@ char *__d_path(const struct path *path, struct path *root,
1811 } 1815 }
1812 parent = dentry->d_parent; 1816 parent = dentry->d_parent;
1813 prefetch(parent); 1817 prefetch(parent);
1814 if ((prepend(&end, &buflen, dentry->d_name.name, 1818 if ((prepend_name(&end, &buflen, &dentry->d_name) != 0) ||
1815 dentry->d_name.len) != 0) ||
1816 (prepend(&end, &buflen, "/", 1) != 0)) 1819 (prepend(&end, &buflen, "/", 1) != 0))
1817 goto Elong; 1820 goto Elong;
1818 retval = end; 1821 retval = end;
@@ -1825,8 +1828,7 @@ out:
1825 1828
1826global_root: 1829global_root:
1827 retval += 1; /* hit the slash */ 1830 retval += 1; /* hit the slash */
1828 if (prepend(&retval, &buflen, dentry->d_name.name, 1831 if (prepend_name(&retval, &buflen, &dentry->d_name) != 0)
1829 dentry->d_name.len) != 0)
1830 goto Elong; 1832 goto Elong;
1831 root->mnt = vfsmnt; 1833 root->mnt = vfsmnt;
1832 root->dentry = dentry; 1834 root->dentry = dentry;
@@ -1918,16 +1920,11 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen)
1918 retval = end-1; 1920 retval = end-1;
1919 *retval = '/'; 1921 *retval = '/';
1920 1922
1921 for (;;) { 1923 while (!IS_ROOT(dentry)) {
1922 struct dentry *parent; 1924 struct dentry *parent = dentry->d_parent;
1923 if (IS_ROOT(dentry))
1924 break;
1925 1925
1926 parent = dentry->d_parent;
1927 prefetch(parent); 1926 prefetch(parent);
1928 1927 if ((prepend_name(&end, &buflen, &dentry->d_name) != 0) ||
1929 if ((prepend(&end, &buflen, dentry->d_name.name,
1930 dentry->d_name.len) != 0) ||
1931 (prepend(&end, &buflen, "/", 1) != 0)) 1928 (prepend(&end, &buflen, "/", 1) != 0))
1932 goto Elong; 1929 goto Elong;
1933 1930
@@ -1978,7 +1975,7 @@ asmlinkage long sys_getcwd(char __user *buf, unsigned long size)
1978 error = -ENOENT; 1975 error = -ENOENT;
1979 /* Has the current directory has been unlinked? */ 1976 /* Has the current directory has been unlinked? */
1980 spin_lock(&dcache_lock); 1977 spin_lock(&dcache_lock);
1981 if (pwd.dentry->d_parent == pwd.dentry || !d_unhashed(pwd.dentry)) { 1978 if (IS_ROOT(pwd.dentry) || !d_unhashed(pwd.dentry)) {
1982 unsigned long len; 1979 unsigned long len;
1983 struct path tmp = root; 1980 struct path tmp = root;
1984 char * cwd; 1981 char * cwd;