All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] statvfs01: Convert to new LTP API
Date: Thu, 01 Dec 2022 09:34:07 +0000	[thread overview]
Message-ID: <87y1rrihjs.fsf@suse.de> (raw)
In-Reply-To: <CAEemH2dO+QXEteiEOqA5o_Axxxe9c4mdPrMB34Pj1FMPyDf9EQ@mail.gmail.com>

Hello,

Li Wang <liwang@redhat.com> writes:

> On Wed, Nov 30, 2022 at 5:50 PM Petr Vorel <pvorel@suse.cz> wrote:
>
>> Hi all,
>>
>> ...
>> > > +static struct tst_test test = {
>> > > +   .test_all = run,
>> > > +   .setup = setup,
>> > > +   .needs_root = 1,
>> > > +   .mount_device = 1,
>> > > +   .mntpoint = MNT_POINT,
>> > > +   .all_filesystems = 1,
>> > > +   .skip_filesystems = (const char *const[]) {
>> > > +           "vfat",
>> > > +           "exfat",
>> > I was looking what's wrong with vfat and exfat.
>> > statvfs.f_namemax returns 1530, which is obviously too long, thus
>> valid_fname
>> > obviously returns ENAMETOOLONG (36). Tested on
>> 6.1.0-rc6-1.g4c01546-default.
>> > I wonder why, isn't that a bug?

This is the kind of issue which made me think it should be a separate
patch. Because maybe it is a bug.

>>
>> To reply myself, both glibc and musl defines:
>> statvfs->f_namemax = statfs->f_namelen;
>>
>> TL;DR: 6 * 255 = 1530 due names being in UTF-8:
>>
>> Therefore looking into kernel sources for statfs->f_namelen:
>>
>> include/linux/nls.h
>> #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
>>
>> === exfat ===
>> exfat/exfat_raw.h
>> #define EXFAT_MAX_FILE_LEN 255
>>
>> exfat/super.c
>> static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf)
>> {
>>         ...
>>     /* Unicode utf16 255 characters */
>>     buf->f_namelen = EXFAT_MAX_FILE_LEN * NLS_MAX_CHARSET_SIZE;
>>
>> === vfat ===
>> include/uapi/linux/msdos_fs.h
>> #define FAT_LFN_LEN 255     /* maximum long name length */
>>
>> fat/inode.c
>> static int fat_statfs(struct dentry *dentry, struct kstatfs *buf)
>> {
>>         ...
>>     buf->f_namelen =
>>         (sbi->options.isvfat ? FAT_LFN_LEN : 12) * NLS_MAX_CHARSET_SIZE;
>>
>> => i.e. for vfat without long filename support it'd be 72.
>>
>> How about
>> 1) don't skip exfat and vfat but just skip creating file with valid name?
>> or
>>
>
> Sure, I think this method is better.

Is it supposed to return the length in bytes or unicode 'characters'? If
it's the later then things get really complicated so I guess it's bytes.

However BTRFS also supports unicode (and bigger file names in theory)
and just reports 255. If you look at the BTRFS code comments, it says
that they limited it to 255 because other things might break.

So will creating a file with > 255 chars ever work, even if we use
UTF-16 symbols?

In the meantime could we just read the data into a guarded buffer and
check it's not all zero's or all one's (for e.g.)?

>
>
>>
>> 2) Add #define NLS_MAX_CHARSET_SIZE 6 and for vfat and exfat calculate
>> length as: buf.f_namemax / NLS_MAX_CHARSET_SIZE - 1 ?
>>
>> Kind regards,
>> Petr
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
>>
>>


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-12-01  9:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 11:42 [LTP] [PATCH] statvfs01: Convert to new LTP API Avinesh Kumar
2022-11-25  2:18 ` Li Wang
2022-11-29 10:58   ` Richard Palethorpe
2022-11-30  7:05     ` [LTP] [PATCH v2] " Avinesh Kumar
2022-11-30  8:52       ` Petr Vorel
2022-11-30  9:50         ` Petr Vorel
2022-12-01  5:16           ` Li Wang
2022-12-01  9:34             ` Richard Palethorpe [this message]
2022-12-02  9:20               ` Petr Vorel
2022-12-01  8:51           ` Avinesh Kumar
2022-12-01  9:17             ` Li Wang
2022-12-01 10:45               ` Petr Vorel
2022-12-01 11:04                 ` Avinesh Kumar
2022-11-30  7:20     ` [LTP] [PATCH] " Li Wang
2022-12-01  6:00       ` Li Wang

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=87y1rrihjs.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.