All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: fat: do not mangle short filenames
@ 2023-03-17 12:04 Stefan Herbrechtsmeier
  2023-03-20 17:01 ` Tom Rini
  2023-03-31 14:15 ` Tom Rini
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Herbrechtsmeier @ 2023-03-17 12:04 UTC (permalink / raw)
  To: u-boot; +Cc: Stefan Herbrechtsmeier, Simon Glass

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Do not mangle lower or mixed case filenames which fit into the upper
case 8.3 short filename. This ensures FAT standard compatible short
filenames (SFN) to support systems without long filename (LFN) support
like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
boot.bin).

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

 fs/fat/fat_write.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 00541ebc3a..413fc432eb 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -141,6 +141,8 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
 	if (!strcmp(buf, filename)) {
 		ret = 1;
 		goto out;
+	} else if (!strcasecmp(buf, filename)) {
+		goto out_ret;
 	}
 
 	/* Construct an indexed short name */
@@ -177,12 +179,13 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
 		if (find_directory_entry(itr, buf))
 			continue;
 
-		debug("chosen short name: %s\n", buf);
-		/* Each long name directory entry takes 13 characters. */
-		ret = (strlen(filename) + 25) / 13;
-		goto out;
+		goto out_ret;
 	}
 	return -EIO;
+out_ret:
+	debug("chosen short name: %s\n", buf);
+	/* Each long name directory entry takes 13 characters. */
+	ret = (strlen(filename) + 25) / 13;
 out:
 	memcpy(shortname, &dirent, SHORT_NAME_SIZE);
 	return ret;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-17 12:04 [PATCH] fs: fat: do not mangle short filenames Stefan Herbrechtsmeier
@ 2023-03-20 17:01 ` Tom Rini
  2023-03-21  7:43   ` Stefan Herbrechtsmeier
  2023-03-31 14:15 ` Tom Rini
  1 sibling, 1 reply; 9+ messages in thread
From: Tom Rini @ 2023-03-20 17:01 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:

> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Do not mangle lower or mixed case filenames which fit into the upper
> case 8.3 short filename. This ensures FAT standard compatible short
> filenames (SFN) to support systems without long filename (LFN) support
> like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
> boot.bin).
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> ---
> 
>  fs/fat/fat_write.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)

Can we update test/py/tests/test_fs/ somewhere to have a test for this
case? Thanks.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-20 17:01 ` Tom Rini
@ 2023-03-21  7:43   ` Stefan Herbrechtsmeier
  2023-03-21 15:35     ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Herbrechtsmeier @ 2023-03-21  7:43 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

Am 20.03.2023 um 18:01 schrieb Tom Rini:
> On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:
>
>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> Do not mangle lower or mixed case filenames which fit into the upper
>> case 8.3 short filename. This ensures FAT standard compatible short
>> filenames (SFN) to support systems without long filename (LFN) support
>> like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
>> boot.bin).
>>
>> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> ---
>>
>>   fs/fat/fat_write.c | 11 +++++++----
>>   1 file changed, 7 insertions(+), 4 deletions(-)
> Can we update test/py/tests/test_fs/ somewhere to have a test for this
> case? Thanks.

What is the recommended approach to test internal behavior? The short 
name isn't avialable at the terminal because u-boot support VFAT.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-21  7:43   ` Stefan Herbrechtsmeier
@ 2023-03-21 15:35     ` Tom Rini
  2023-03-21 15:53       ` Stefan Herbrechtsmeier
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2023-03-21 15:35 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]

On Tue, Mar 21, 2023 at 08:43:07AM +0100, Stefan Herbrechtsmeier wrote:
> Am 20.03.2023 um 18:01 schrieb Tom Rini:
> > On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:
> > 
> > > From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> > > 
> > > Do not mangle lower or mixed case filenames which fit into the upper
> > > case 8.3 short filename. This ensures FAT standard compatible short
> > > filenames (SFN) to support systems without long filename (LFN) support
> > > like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
> > > boot.bin).
> > > 
> > > Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> > > 
> > > ---
> > > 
> > >   fs/fat/fat_write.c | 11 +++++++----
> > >   1 file changed, 7 insertions(+), 4 deletions(-)
> > Can we update test/py/tests/test_fs/ somewhere to have a test for this
> > case? Thanks.
> 
> What is the recommended approach to test internal behavior? The short name
> isn't avialable at the terminal because u-boot support VFAT.

Well, you triggered this problem with a filesystem that had contents
that were "just so" and then didn't work as expected, yes?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-21 15:35     ` Tom Rini
@ 2023-03-21 15:53       ` Stefan Herbrechtsmeier
  2023-03-21 15:54         ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Herbrechtsmeier @ 2023-03-21 15:53 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass


Am 21.03.2023 um 16:35 schrieb Tom Rini:
> On Tue, Mar 21, 2023 at 08:43:07AM +0100, Stefan Herbrechtsmeier wrote:
>> Am 20.03.2023 um 18:01 schrieb Tom Rini:
>>> On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:
>>>
>>>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>>>
>>>> Do not mangle lower or mixed case filenames which fit into the upper
>>>> case 8.3 short filename. This ensures FAT standard compatible short
>>>> filenames (SFN) to support systems without long filename (LFN) support
>>>> like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
>>>> boot.bin).
>>>>
>>>> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>>>
>>>> ---
>>>>
>>>>    fs/fat/fat_write.c | 11 +++++++----
>>>>    1 file changed, 7 insertions(+), 4 deletions(-)
>>> Can we update test/py/tests/test_fs/ somewhere to have a test for this
>>> case? Thanks.
>> What is the recommended approach to test internal behavior? The short name
>> isn't avialable at the terminal because u-boot support VFAT.
> Well, you triggered this problem with a filesystem that had contents
> that were "just so" and then didn't work as expected, yes?


No, I write a file to a file system and the boot rom do not find the 
file because the name was wrong (BOOT~1.BIN instead of BOOT.BIN).

The mdir command shows the short and long file name. I will add a 
test_fat.py with a test.

Regards
   Stefan


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-21 15:53       ` Stefan Herbrechtsmeier
@ 2023-03-21 15:54         ` Tom Rini
  2023-03-22  8:51           ` Stefan Herbrechtsmeier
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2023-03-21 15:54 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]

On Tue, Mar 21, 2023 at 04:53:22PM +0100, Stefan Herbrechtsmeier wrote:
> 
> Am 21.03.2023 um 16:35 schrieb Tom Rini:
> > On Tue, Mar 21, 2023 at 08:43:07AM +0100, Stefan Herbrechtsmeier wrote:
> > > Am 20.03.2023 um 18:01 schrieb Tom Rini:
> > > > On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:
> > > > 
> > > > > From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> > > > > 
> > > > > Do not mangle lower or mixed case filenames which fit into the upper
> > > > > case 8.3 short filename. This ensures FAT standard compatible short
> > > > > filenames (SFN) to support systems without long filename (LFN) support
> > > > > like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
> > > > > boot.bin).
> > > > > 
> > > > > Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> > > > > 
> > > > > ---
> > > > > 
> > > > >    fs/fat/fat_write.c | 11 +++++++----
> > > > >    1 file changed, 7 insertions(+), 4 deletions(-)
> > > > Can we update test/py/tests/test_fs/ somewhere to have a test for this
> > > > case? Thanks.
> > > What is the recommended approach to test internal behavior? The short name
> > > isn't avialable at the terminal because u-boot support VFAT.
> > Well, you triggered this problem with a filesystem that had contents
> > that were "just so" and then didn't work as expected, yes?
> 
> 
> No, I write a file to a file system and the boot rom do not find the file
> because the name was wrong (BOOT~1.BIN instead of BOOT.BIN).
> 
> The mdir command shows the short and long file name. I will add a
> test_fat.py with a test.

Ah, ok, and great, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-21 15:54         ` Tom Rini
@ 2023-03-22  8:51           ` Stefan Herbrechtsmeier
  2023-03-22 13:20             ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Herbrechtsmeier @ 2023-03-22  8:51 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

Am 21.03.2023 um 16:54 schrieb Tom Rini:
> On Tue, Mar 21, 2023 at 04:53:22PM +0100, Stefan Herbrechtsmeier wrote:
>> Am 21.03.2023 um 16:35 schrieb Tom Rini:
>>> On Tue, Mar 21, 2023 at 08:43:07AM +0100, Stefan Herbrechtsmeier wrote:
>>>> Am 20.03.2023 um 18:01 schrieb Tom Rini:
>>>>> On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:
>>>>>
>>>>>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>>>>>
>>>>>> Do not mangle lower or mixed case filenames which fit into the upper
>>>>>> case 8.3 short filename. This ensures FAT standard compatible short
>>>>>> filenames (SFN) to support systems without long filename (LFN) support
>>>>>> like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
>>>>>> boot.bin).
>>>>>>
>>>>>> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>>>>>
>>>>>> ---
>>>>>>
>>>>>>     fs/fat/fat_write.c | 11 +++++++----
>>>>>>     1 file changed, 7 insertions(+), 4 deletions(-)
>>>>> Can we update test/py/tests/test_fs/ somewhere to have a test for this
>>>>> case? Thanks.
>>>> What is the recommended approach to test internal behavior? The short name
>>>> isn't avialable at the terminal because u-boot support VFAT.
>>> Well, you triggered this problem with a filesystem that had contents
>>> that were "just so" and then didn't work as expected, yes?
>>
>> No, I write a file to a file system and the boot rom do not find the file
>> because the name was wrong (BOOT~1.BIN instead of BOOT.BIN).
>>
>> The mdir command shows the short and long file name. I will add a
>> test_fat.py with a test.
> Ah, ok, and great, thanks!


I have send a separate patch `test: fs: Check fat short file name` or 
should I send a new series with both patches?

Regards
   Stefan


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-22  8:51           ` Stefan Herbrechtsmeier
@ 2023-03-22 13:20             ` Tom Rini
  0 siblings, 0 replies; 9+ messages in thread
From: Tom Rini @ 2023-03-22 13:20 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 2098 bytes --]

On Wed, Mar 22, 2023 at 09:51:32AM +0100, Stefan Herbrechtsmeier wrote:
> Am 21.03.2023 um 16:54 schrieb Tom Rini:
> > On Tue, Mar 21, 2023 at 04:53:22PM +0100, Stefan Herbrechtsmeier wrote:
> > > Am 21.03.2023 um 16:35 schrieb Tom Rini:
> > > > On Tue, Mar 21, 2023 at 08:43:07AM +0100, Stefan Herbrechtsmeier wrote:
> > > > > Am 20.03.2023 um 18:01 schrieb Tom Rini:
> > > > > > On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:
> > > > > > 
> > > > > > > From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> > > > > > > 
> > > > > > > Do not mangle lower or mixed case filenames which fit into the upper
> > > > > > > case 8.3 short filename. This ensures FAT standard compatible short
> > > > > > > filenames (SFN) to support systems without long filename (LFN) support
> > > > > > > like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
> > > > > > > boot.bin).
> > > > > > > 
> > > > > > > Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> > > > > > > 
> > > > > > > ---
> > > > > > > 
> > > > > > >     fs/fat/fat_write.c | 11 +++++++----
> > > > > > >     1 file changed, 7 insertions(+), 4 deletions(-)
> > > > > > Can we update test/py/tests/test_fs/ somewhere to have a test for this
> > > > > > case? Thanks.
> > > > > What is the recommended approach to test internal behavior? The short name
> > > > > isn't avialable at the terminal because u-boot support VFAT.
> > > > Well, you triggered this problem with a filesystem that had contents
> > > > that were "just so" and then didn't work as expected, yes?
> > > 
> > > No, I write a file to a file system and the boot rom do not find the file
> > > because the name was wrong (BOOT~1.BIN instead of BOOT.BIN).
> > > 
> > > The mdir command shows the short and long file name. I will add a
> > > test_fat.py with a test.
> > Ah, ok, and great, thanks!
> 
> 
> I have send a separate patch `test: fs: Check fat short file name` or should
> I send a new series with both patches?

A follow-up is fine.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] fs: fat: do not mangle short filenames
  2023-03-17 12:04 [PATCH] fs: fat: do not mangle short filenames Stefan Herbrechtsmeier
  2023-03-20 17:01 ` Tom Rini
@ 2023-03-31 14:15 ` Tom Rini
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Rini @ 2023-03-31 14:15 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: u-boot, Stefan Herbrechtsmeier, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

On Fri, Mar 17, 2023 at 01:04:13PM +0100, Stefan Herbrechtsmeier wrote:

> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Do not mangle lower or mixed case filenames which fit into the upper
> case 8.3 short filename. This ensures FAT standard compatible short
> filenames (SFN) to support systems without long filename (LFN) support
> like boot roms (ex. SFN BOOT.BIN instead of BOOT~1.BIN for LFN
> boot.bin).
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-31 14:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 12:04 [PATCH] fs: fat: do not mangle short filenames Stefan Herbrechtsmeier
2023-03-20 17:01 ` Tom Rini
2023-03-21  7:43   ` Stefan Herbrechtsmeier
2023-03-21 15:35     ` Tom Rini
2023-03-21 15:53       ` Stefan Herbrechtsmeier
2023-03-21 15:54         ` Tom Rini
2023-03-22  8:51           ` Stefan Herbrechtsmeier
2023-03-22 13:20             ` Tom Rini
2023-03-31 14:15 ` Tom Rini

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.