]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/ubifs/key.h
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / fs / ubifs / key.h
index c0a95e393347c4199dbc2057cb838a3b4a4a4ef3..7547be512db2632153ce20822dd0063dcdc5cddd 100644 (file)
@@ -69,7 +69,7 @@ static inline uint32_t key_r5_hash(const char *s, int len)
        uint32_t a = 0;
        const signed char *str = (const signed char *)s;
 
-       while (*str) {
+       while (len--) {
                a += *str << 4;
                a += *str >> 4;
                a *= 11;
@@ -153,13 +153,13 @@ static inline void highest_ino_key(const struct ubifs_info *c,
  * @c: UBIFS file-system description object
  * @key: key to initialize
  * @inum: parent inode number
- * @nm: direntry name and length
+ * @nm: direntry name and length. Not a string when encrypted!
  */
 static inline void dent_key_init(const struct ubifs_info *c,
                                 union ubifs_key *key, ino_t inum,
-                                const struct qstr *nm)
+                                const struct fscrypt_name *nm)
 {
-       uint32_t hash = c->key_hash(nm->name, nm->len);
+       uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));
 
        ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
        key->u32[0] = inum;
@@ -191,10 +191,11 @@ static inline void dent_key_init_hash(const struct ubifs_info *c,
  * @nm: direntry name and length
  */
 static inline void dent_key_init_flash(const struct ubifs_info *c, void *k,
-                                      ino_t inum, const struct qstr *nm)
+                                      ino_t inum,
+                                      const struct fscrypt_name *nm)
 {
        union ubifs_key *key = k;
-       uint32_t hash = c->key_hash(nm->name, nm->len);
+       uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));
 
        ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
        key->j32[0] = cpu_to_le32(inum);
@@ -225,9 +226,9 @@ static inline void lowest_dent_key(const struct ubifs_info *c,
  */
 static inline void xent_key_init(const struct ubifs_info *c,
                                 union ubifs_key *key, ino_t inum,
-                                const struct qstr *nm)
+                                const struct fscrypt_name *nm)
 {
-       uint32_t hash = c->key_hash(nm->name, nm->len);
+       uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));
 
        ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
        key->u32[0] = inum;
@@ -242,10 +243,10 @@ static inline void xent_key_init(const struct ubifs_info *c,
  * @nm: extended attribute entry name and length
  */
 static inline void xent_key_init_flash(const struct ubifs_info *c, void *k,
-                                      ino_t inum, const struct qstr *nm)
+                                      ino_t inum, const struct fscrypt_name *nm)
 {
        union ubifs_key *key = k;
-       uint32_t hash = c->key_hash(nm->name, nm->len);
+       uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm));
 
        ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
        key->j32[0] = cpu_to_le32(inum);