Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp580018imm; Mon, 21 May 2018 10:39:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqeaptJNlCgeCXSF0FdtZ+mTqaPYwa5xFqp+9THSEYqSwYP3qfTQjw56zXQvGAqEP/DMOPz X-Received: by 2002:a17:902:8bc4:: with SMTP id r4-v6mr13323838plo.381.1526924383827; Mon, 21 May 2018 10:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526924383; cv=none; d=google.com; s=arc-20160816; b=pdLory+J3SHcj2lNxG1TweJKRBuTYG+0Ro2Pf6sU2TXI2x+lPweCGUC3II8tp8BQnb zGOTPlPsfA/VuE6LF4NI0fWh35hBIZKJ0qeQWC3ypko43EH+8L83FUvTL1IRKCxKW3Pm +EorrndFzUxuabeE8K+01JpgzTWEJmcttT4+I0Xkksd6uHIegGLRauMivhT2fOjpilks ngXr1lz90FRo2it3yYBHUaBvTTu6fDu6Tsd38JoxztkAp9Tqmx1XZjITPDzjClMLOFS3 539lsU4yNVRKTQ4wgI9auyjTdTQZn8dJTLXp9VRiRSl1et7RtXCTla3G7jBclo1bchu6 2/eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cYelJMBFLqgIU8hv7zcRJnWODxOW7EYbNQB4N49WB38=; b=lWIiHMVLCh06MJR2t3WcSKNQ/yn2jKuID9bm909IRDv01seNHUIa5sLTuCSs/P6DQ2 LxA8yNYufUL89+09nb1TPiKA/uL4mIbf1jIHtAmyT1PB2XcQIPXt64338mU3UpVMNYe5 9ImUEk3KOR7PVnA4Ue+kShm3xyy3BnFB2KnnjHAUBjR72rXGIwrG53xxw6ltZbJ63gVG WBNmHJl7HjHatsRnOiup6Y4LluCHiMqdB1bFtPzx16pgqr8tETwH84U4hsni9Eu5aTmA a1QY7LyP/7bjbtyYiHxgPGBxhh/Fdb8TRux01BkvmBcnItNSOFaapxOxNYTnUTieK1MV e6Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi12-v6si13981949plb.555.2018.05.21.10.39.29; Mon, 21 May 2018 10:39:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753438AbeEURjC (ORCPT + 99 others); Mon, 21 May 2018 13:39:02 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45402 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753722AbeEURg7 (ORCPT ); Mon, 21 May 2018 13:36:59 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 1D56628707E From: Gabriel Krisman Bertazi To: viro@ZenIV.linux.org.uk Cc: jra@google.com, tytso@mit.edu, olaf@sgi.com, darrick.wong@oracle.com, kernel@lists.collabora.co.uk, linux-fsdevel@vger.kernel.org, david@fromorbit.com, jack@suse.cz, linux-kernel@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 09/15] nls: Add optional normalization and casefold hooks Date: Mon, 21 May 2018 14:36:11 -0300 Message-Id: <20180521173617.31625-10-krisman@collabora.co.uk> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521173617.31625-1-krisman@collabora.co.uk> References: <20180521173617.31625-1-krisman@collabora.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Gabriel Krisman Bertazi --- include/linux/nls.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/linux/nls.h b/include/linux/nls.h index 72698d524b42..efd3712f0e81 100644 --- a/include/linux/nls.h +++ b/include/linux/nls.h @@ -4,6 +4,7 @@ #include #include +#include /* Unicode has changed over the years. Unicode code points no longer * fit into 16 bits; as of Unicode 5 valid code points range from 0 @@ -38,7 +39,12 @@ struct nls_ops { unsigned int c); unsigned char (*uppercase)(const struct nls_table *charset, unsigned int c); - + int (*casefold)(const struct nls_table *charset, + const unsigned char *str, size_t len, + unsigned char **folded); + int (*normalize)(const struct nls_table *charset, + const unsigned char *str, size_t len, + unsigned char **normalized); }; struct nls_table { @@ -156,6 +162,26 @@ static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1, return nls_strncasecmp(t, s1, len, s2, len); } +static inline int nls_casefold(const struct nls_table *charset, + const unsigned char *str, size_t len, + unsigned char **folded) +{ + if (charset->ops->casefold) + return charset->ops->casefold(charset, str, len, folded); + + return -ENOTSUPP; +} + +static inline int nls_normalize(const struct nls_table *charset, + const unsigned char *str, size_t len, + unsigned char **normalized) +{ + if (charset->ops->normalize) + return charset->ops->normalize(charset, str, len, normalized); + + return -ENOTSUPP; +} + /* * nls_nullsize - return length of null character for codepage * @codepage - codepage for which to return length of NULL terminator -- 2.17.0