[LTP] [PATCH v2] statvfs01: Convert to new LTP API
Petr Vorel
pvorel@suse.cz
Wed Nov 30 10:50:37 CET 2022
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?
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
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
More information about the ltp
mailing list