d694e46afb
Fix the following allmodconfig "make W=1" issues: WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-celtic.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-centeuro.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-croatian.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-cyrillic.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-gaelic.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-greek.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-iceland.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-inuit.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-romanian.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-roman.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-turkish.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ascii.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1250.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1251.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1255.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp437.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp737.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp775.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp850.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp852.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp855.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp857.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp860.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp861.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp862.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp863.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp864.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp865.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp866.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp869.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp874.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp932.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp936.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp949.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp950.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_euc-jp.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-13.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-14.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-15.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-1.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-2.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-3.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-4.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-5.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-6.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-7.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-9.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-r.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-ru.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-u.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ucs2_utils.o WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_utf8.o Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> Link: https://lore.kernel.org/r/20240516-md-fs-nls-v1-1-ed540d8239bf@quicinc.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
84 lines
1.7 KiB
C
84 lines
1.7 KiB
C
/*
|
|
* linux/fs/nls/nls_koi8-ru.c
|
|
*
|
|
* Charset koi8-ru translation based on charset koi8-u.
|
|
* The Unicode to charset table has only exact mappings.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/string.h>
|
|
#include <linux/nls.h>
|
|
#include <linux/errno.h>
|
|
|
|
static struct nls_table *p_nls;
|
|
|
|
static int uni2char(const wchar_t uni,
|
|
unsigned char *out, int boundlen)
|
|
{
|
|
if (boundlen <= 0)
|
|
return -ENAMETOOLONG;
|
|
|
|
if ((uni & 0xffaf) == 0x040e || (uni & 0xffce) == 0x254c) {
|
|
/* koi8-ru and koi8-u differ only on two characters */
|
|
if (uni == 0x040e)
|
|
out[0] = 0xbe;
|
|
else if (uni == 0x045e)
|
|
out[0] = 0xae;
|
|
else if (uni == 0x255d || uni == 0x256c)
|
|
return 0;
|
|
else
|
|
return p_nls->uni2char(uni, out, boundlen);
|
|
return 1;
|
|
}
|
|
else
|
|
/* fast path */
|
|
return p_nls->uni2char(uni, out, boundlen);
|
|
}
|
|
|
|
static int char2uni(const unsigned char *rawstring, int boundlen,
|
|
wchar_t *uni)
|
|
{
|
|
int n;
|
|
|
|
if ((*rawstring & 0xef) != 0xae) {
|
|
/* koi8-ru and koi8-u differ only on two characters */
|
|
*uni = (*rawstring & 0x10) ? 0x040e : 0x045e;
|
|
return 1;
|
|
}
|
|
|
|
n = p_nls->char2uni(rawstring, boundlen, uni);
|
|
return n;
|
|
}
|
|
|
|
static struct nls_table table = {
|
|
.charset = "koi8-ru",
|
|
.uni2char = uni2char,
|
|
.char2uni = char2uni,
|
|
};
|
|
|
|
static int __init init_nls_koi8_ru(void)
|
|
{
|
|
p_nls = load_nls("koi8-u");
|
|
|
|
if (p_nls) {
|
|
table.charset2upper = p_nls->charset2upper;
|
|
table.charset2lower = p_nls->charset2lower;
|
|
return register_nls(&table);
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
static void __exit exit_nls_koi8_ru(void)
|
|
{
|
|
unregister_nls(&table);
|
|
unload_nls(p_nls);
|
|
}
|
|
|
|
module_init(init_nls_koi8_ru)
|
|
module_exit(exit_nls_koi8_ru)
|
|
|
|
MODULE_DESCRIPTION("NLS KOI8-RU (Belarusian)");
|
|
MODULE_LICENSE("Dual BSD/GPL");
|