FROMLIST: unicode: Add utf8_casefold_hash
This adds a case insensitive hash function to allow taking the hash without needing to allocate a casefolded copy of the string. Signed-off-by: Daniel Rosenberg <drosen@google.com> Test: Boots, /data/media is case insensitive Bug: 138322712 Link: https://lore.kernel.org/linux-f2fs-devel/20200208013552.241832-1-drosen@google.com/T/#t Change-Id: I43c7d38a8e22f4479397f35e6343bd326901cdba
This commit is contained in:
parent
09681dec6e
commit
5f7ec28844
@ -6,6 +6,7 @@
|
|||||||
#include <linux/parser.h>
|
#include <linux/parser.h>
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/unicode.h>
|
#include <linux/unicode.h>
|
||||||
|
#include <linux/stringhash.h>
|
||||||
|
|
||||||
#include "utf8n.h"
|
#include "utf8n.h"
|
||||||
|
|
||||||
@ -122,9 +123,29 @@ int utf8_casefold(const struct unicode_map *um, const struct qstr *str,
|
|||||||
}
|
}
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(utf8_casefold);
|
EXPORT_SYMBOL(utf8_casefold);
|
||||||
|
|
||||||
|
int utf8_casefold_hash(const struct unicode_map *um, const void *salt,
|
||||||
|
struct qstr *str)
|
||||||
|
{
|
||||||
|
const struct utf8data *data = utf8nfdicf(um->version);
|
||||||
|
struct utf8cursor cur;
|
||||||
|
int c;
|
||||||
|
unsigned long hash = init_name_hash(salt);
|
||||||
|
|
||||||
|
if (utf8ncursor(&cur, data, str->name, str->len) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
while ((c = utf8byte(&cur))) {
|
||||||
|
if (c < 0)
|
||||||
|
return c;
|
||||||
|
hash = partial_name_hash((unsigned char)c, hash);
|
||||||
|
}
|
||||||
|
str->hash = end_name_hash(hash);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(utf8_casefold_hash);
|
||||||
|
|
||||||
int utf8_normalize(const struct unicode_map *um, const struct qstr *str,
|
int utf8_normalize(const struct unicode_map *um, const struct qstr *str,
|
||||||
unsigned char *dest, size_t dlen)
|
unsigned char *dest, size_t dlen)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,9 @@ int utf8_normalize(const struct unicode_map *um, const struct qstr *str,
|
|||||||
int utf8_casefold(const struct unicode_map *um, const struct qstr *str,
|
int utf8_casefold(const struct unicode_map *um, const struct qstr *str,
|
||||||
unsigned char *dest, size_t dlen);
|
unsigned char *dest, size_t dlen);
|
||||||
|
|
||||||
|
int utf8_casefold_hash(const struct unicode_map *um, const void *salt,
|
||||||
|
struct qstr *str);
|
||||||
|
|
||||||
struct unicode_map *utf8_load(const char *version);
|
struct unicode_map *utf8_load(const char *version);
|
||||||
void utf8_unload(struct unicode_map *um);
|
void utf8_unload(struct unicode_map *um);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user