diff options
-rw-r--r-- | fs/namei.c | 13 | ||||
-rw-r--r-- | include/linux/dcache.h | 9 |
2 files changed, 10 insertions, 12 deletions
diff --git a/fs/namei.c b/fs/namei.c index a780ea515c47..ec72fa1acb14 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1374,6 +1374,14 @@ static inline int can_lookup(struct inode *inode) | |||
1374 | return 1; | 1374 | return 1; |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | unsigned int full_name_hash(const unsigned char *name, unsigned int len) | ||
1378 | { | ||
1379 | unsigned long hash = init_name_hash(); | ||
1380 | while (len--) | ||
1381 | hash = partial_name_hash(*name++, hash); | ||
1382 | return end_name_hash(hash); | ||
1383 | } | ||
1384 | |||
1377 | /* | 1385 | /* |
1378 | * Name resolution. | 1386 | * Name resolution. |
1379 | * This is the basic name resolution function, turning a pathname into | 1387 | * This is the basic name resolution function, turning a pathname into |
@@ -1775,24 +1783,21 @@ static struct dentry *lookup_hash(struct nameidata *nd) | |||
1775 | struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) | 1783 | struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) |
1776 | { | 1784 | { |
1777 | struct qstr this; | 1785 | struct qstr this; |
1778 | unsigned long hash; | ||
1779 | unsigned int c; | 1786 | unsigned int c; |
1780 | 1787 | ||
1781 | WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex)); | 1788 | WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex)); |
1782 | 1789 | ||
1783 | this.name = name; | 1790 | this.name = name; |
1784 | this.len = len; | 1791 | this.len = len; |
1792 | this.hash = full_name_hash(name, len); | ||
1785 | if (!len) | 1793 | if (!len) |
1786 | return ERR_PTR(-EACCES); | 1794 | return ERR_PTR(-EACCES); |
1787 | 1795 | ||
1788 | hash = init_name_hash(); | ||
1789 | while (len--) { | 1796 | while (len--) { |
1790 | c = *(const unsigned char *)name++; | 1797 | c = *(const unsigned char *)name++; |
1791 | if (c == '/' || c == '\0') | 1798 | if (c == '/' || c == '\0') |
1792 | return ERR_PTR(-EACCES); | 1799 | return ERR_PTR(-EACCES); |
1793 | hash = partial_name_hash(c, hash); | ||
1794 | } | 1800 | } |
1795 | this.hash = end_name_hash(hash); | ||
1796 | /* | 1801 | /* |
1797 | * See if the low-level filesystem might want | 1802 | * See if the low-level filesystem might want |
1798 | * to use its own hash.. | 1803 | * to use its own hash.. |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 61b24261e07a..f1c7eb8461be 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -89,14 +89,7 @@ static inline unsigned long end_name_hash(unsigned long hash) | |||
89 | } | 89 | } |
90 | 90 | ||
91 | /* Compute the hash for a name string. */ | 91 | /* Compute the hash for a name string. */ |
92 | static inline unsigned int | 92 | extern unsigned int full_name_hash(const unsigned char *, unsigned int); |
93 | full_name_hash(const unsigned char *name, unsigned int len) | ||
94 | { | ||
95 | unsigned long hash = init_name_hash(); | ||
96 | while (len--) | ||
97 | hash = partial_name_hash(*name++, hash); | ||
98 | return end_name_hash(hash); | ||
99 | } | ||
100 | 93 | ||
101 | /* | 94 | /* |
102 | * Try to keep struct dentry aligned on 64 byte cachelines (this will | 95 | * Try to keep struct dentry aligned on 64 byte cachelines (this will |