From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: zhoumin <teczm@foxmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fat: Optimized FAT bad char check
Date: Thu, 10 Apr 2025 03:52:58 +0900 [thread overview]
Message-ID: <87ecy16ub9.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <tencent_A8520B8C5C017A6C86DAD38B120D1B4D2905@qq.com>
zhoumin <teczm@foxmail.com> writes:
> 1. Add first-Character Validation based on FAT Spec 6.1 ->
> Note the following -> 2
> 2. Add check for 0x7F (DEL character) even though the specification
> does not explicitly mention it
Why do you need this change?
Thanks.
> Signed-off-by: zhoumin <teczm@foxmail.com>
> ---
> fs/fat/namei_vfat.c | 23 ++++++++++-------------
> 1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index dd910edd2404..d264057f32aa 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -195,16 +195,6 @@ static const struct dentry_operations vfat_dentry_ops = {
> .d_compare = vfat_cmp,
> };
>
> -/* Characters that are undesirable in an MS-DOS file name */
> -
> -static inline bool vfat_bad_char(wchar_t w)
> -{
> - return (w < 0x0020)
> - || (w == '*') || (w == '?') || (w == '<') || (w == '>')
> - || (w == '|') || (w == '"') || (w == ':') || (w == '/')
> - || (w == '\\');
> -}
> -
> static inline bool vfat_replace_char(wchar_t w)
> {
> return (w == '[') || (w == ']') || (w == ';') || (w == ',')
> @@ -220,10 +210,17 @@ static inline int vfat_is_used_badchars(const wchar_t *s, int len)
> {
> int i;
>
> - for (i = 0; i < len; i++)
> - if (vfat_bad_char(s[i]))
> - return -EINVAL;
> + for (i = 0; i < len; i++) {
> + if (i == 0 && s[0] == 0x05)
> + continue;
>
> + /* Characters that are undesirable in an MS-DOS file name */
> + if ((s[i] < 0x0020) || (s[i] == '*') || (s[i] == '?') ||
> + (s[i] == '<') || (s[i] == '>') || (s[i] == '|')
> + || (s[i] == '"') || (s[i] == ':') || (s[i] == '/')
> + || (s[i] == '\\') || (s[i] == 0x7f))
> + return -EINVAL;
> + }
> if (s[i - 1] == ' ') /* last character cannot be space */
> return -EINVAL;
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2025-04-09 18:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 17:27 zhoumin
2025-04-09 18:52 ` OGAWA Hirofumi [this message]
2025-04-10 13:07 ` zhoumin
2025-04-10 13:44 ` OGAWA Hirofumi
2025-04-10 14:28 ` zhoumin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ecy16ub9.fsf@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=teczm@foxmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®