[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87tv56ifob.fsf@mail.parknet.co.jp>
Date: Wed, 08 Jan 2020 16:13:40 +0900
From: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
To: Pali Rohár <pali.rohar@...il.com>
Cc: "Theodore Y. Ts'o" <tytso@....edu>, Jan Kara <jack@...e.cz>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-ntfs-dev@...ts.sourceforge.net, linux-cifs@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Luis de Bethencourt <luisbg@...nel.org>,
Salah Triki <salah.triki@...il.com>,
Steve French <sfrench@...ba.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
David Sterba <dsterba@...e.com>,
Dave Kleikamp <shaggy@...nel.org>,
Anton Altaparmakov <anton@...era.com>,
Jan Kara <jack@...e.com>, Eric Sandeen <sandeen@...hat.com>,
Namjae Jeon <linkinjeon@...il.com>,
Pavel Machek <pavel@....cz>,
Christoph Hellwig <hch@...radead.org>
Subject: Re: Unification of filesystem encoding options
Pali Rohár <pali.rohar@...il.com> writes:
> On Tuesday 07 January 2020 15:03:01 Theodore Y. Ts'o wrote:
>> On Tue, Jan 07, 2020 at 06:38:42PM +0100, Pali Rohár wrote:
>
>> In contrast the fs/unicode functions
>> have support for full Unicode case folding and normalization, and
>> currently has the latest Unicode 12.1 tables (released May 2019).
>
> That is great!
>
> But for example even this is not enough for exfat. exfat has stored
> upcase table directly in on-disk FS, so ensure that every implementation
> of exfat driver would have same rules how to convert character (code
> point) to upper case or lower case (case folding). Upcase table is
> stored to FS itself when formatting. And in MS decided that for exfat
> would not be used any Unicode normalization. So this whole fs/unicode
> code is not usable for exfat.
>
>> What I'd suggest is to create a new API, enhancing the functions in
>> fs/unicode, to support those file systems that need to deal with
>> UTF-16 and UTF-32 for their on-disk directory format, and that we
>> assume that for the most part, userspace *will* be using a UTF-8
>> encoding for the user<->kernel interface.
>
> I do not see a use-case for such a new API. Kernel has already API
> functions:
>
> int utf8_to_utf32(const u8 *s, int len, unicode_t *pu);
> int utf32_to_utf8(unicode_t u, u8 *s, int maxlen);
> int utf8s_to_utf16s(const u8 *s, int len, enum utf16_endian endian, wchar_t *pwcs, int maxlen);
> int utf16s_to_utf8s(const wchar_t *pwcs, int len, enum utf16_endian endian, u8 *s, int maxlen);
>
> which are basically enough for all mentioned filesystems. Maybe in for
> some cases would be useful function utf16 to utf32 (and vice-versa), but
> that is all. fs/unicode does not bring a new value or simplification.
>
> Mentioned filesystems are in most cases either case-sensitive (UDF),
> having own case-folding (exfat), using own special normalization
> incompatible with anything (hfsplus) or do not enforce any normalization
> (cifs, vfat, ntfs, isofs+joliet). So result is that simple UTF-8 to
> UTF-16LE/BE conversion function is enough and then filesystem module
> implements own specific rules (special upcase table, incompatible
> normalization).
>
> And I do not thing that it make sense to extending fs/unicode for every
> one stupid functionality which those filesystems have and needs to
> handle. I see this as a unique filesystem specific code.
>
>> We can keep the existing
>> NLS interface and mount options for legacy support, but in my opinion
>> it's not worth the effort to try to do anything else.
>
> NLS interface is crucial part of VFAT. Reason is that in VFAT can be
> filenames stored either as UTF-16LE or as 8bit in some CP encoding.
> Linux kernel stores new non-7-bit-ASCII filenames as UTF-16LE, but it
> has to able to read 8-bit filenames which were not stored as UTF-16LE,
> but rather as 8bit in CP encoding. And therefore mount option codepage=
> which specify it is required needs to be implemented. It says how
> vfat.ko should handle on-disk structure, not which encoding is exported
> to userspace (those are two different things).
>
> And current vfat implementation uses NLS API for it. Via CONFIG_* is
> specified default codepage= mount option (CP473 or what it is -- if you
> do not specify one explicitly at mount time). And because FAT is
> required part of UEFI, Linux kernel would have to support this stuff
> forever (or at least until it support UEFI). I think this cannot be
> marked as "legacy". It is pity, but truth.
FWIW, what I imagined and but never try to implement in past is, iconv
(or such if you know better api). To support complete codepages, IIRC,
it has difference by OSes (e.g. mac, old windows, current windows,
unicode standard).
So the table is loaded from userspace like firmware data. (several codes
in kernel for special conversion cases are required though, table may be
able to share with glibc)
But this would be big work.
Thanks.
--
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
Powered by blists - more mailing lists