From: "Thomas Weißschuh" <thomas@t-8ch.de>
To: tjcw@cantab.net
Cc: linux-kernel@vger.kernel.org
Subject: Re: vfat file system does not allow a space at the end of a directory name
Date: Mon, 31 Jul 2023 07:55:39 +0200 [thread overview]
Message-ID: <196f7191-5820-4480-99d3-e7ffc66e9c98@t-8ch.de> (raw)
In-Reply-To: <CAC=wTOim6VZM7gKGQ8KuvbVSdmjyg=4G5sFbr+xY89ujPVOq8g@mail.gmail.com>
Hi Chris,
On 2023-07-30 23:33:03+0100, Chris Ward wrote:
> I had a zip file (from downloading pictures from Google Photos) where
> some of the directory names had a space at the end. This unzipped fine
> on an ext4 file system, but gave errors when unpacking onto a USB key
> which had a FAT file system.
>
> On further investigation, file names have the same problem. On my USB key, I get
>
> tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ touch 'aab '
> touch: setting times of 'aab ': No such file or directory
> tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ echo ok >'aab '
> bash: aab : Invalid argument
> tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ touch 'aab'
> tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ echo ok >'aab'
> tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$
>
> Is this as expected, or is it a bug in the kernel's handling of FAT
> file systems ? Probably the next step is to check the behaviour under
> Microsoft Windows.
AFAIK this is a limitation in the FAT filesystem itself.
The problem is that FAT stores filenames in fixed width fields.
Unused space in these fields is filled with ' '.
This means that storing "foo", "foo " or "foo ". would all result in the
exact same result and it will be impossible to figure out the correct
one afterwards.
From Wikipedia [0]:
trailing spaces in either the base name or the extension are
considered to be padding and not a part of the file name
From fs/fat/namei_vfat.c vfat_is_used_badchars():
last character cannot be space
[0] https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system
next prev parent reply other threads:[~2023-07-31 5:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-30 22:33 Chris Ward
2023-07-31 5:55 ` Thomas Weißschuh [this message]
2023-07-31 14:26 ` Theodore Ts'o
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=196f7191-5820-4480-99d3-e7ffc66e9c98@t-8ch.de \
--to=thomas@t-8ch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tjcw@cantab.net \
/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®