All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier-oss@weidmueller.com>
To: u-boot@lists.denx.de
Cc: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH] fs: fat: do not mangle short filenames
Date: Fri, 17 Mar 2023 13:04:13 +0100	[thread overview]
Message-ID: <20230317120413.11066-1-stefan.herbrechtsmeier-oss@weidmueller.com> (raw)

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


             reply	other threads:[~2023-03-17 12:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 12:04 Stefan Herbrechtsmeier [this message]
2023-03-20 17:01 ` [PATCH] fs: fat: do not mangle short filenames 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

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=20230317120413.11066-1-stefan.herbrechtsmeier-oss@weidmueller.com \
    --to=stefan.herbrechtsmeier-oss@weidmueller.com \
    --cc=sjg@chromium.org \
    --cc=stefan.herbrechtsmeier@weidmueller.com \
    --cc=u-boot@lists.denx.de \
    /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.