From patchwork Fri Mar 17 12:04:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1758246 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-weidmueller-onmicrosoft-com header.b=Vc1vt+Sh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PdN9M0zSpz1yWp for ; Fri, 17 Mar 2023 23:04:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E7AA885B84; Fri, 17 Mar 2023 13:04:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.b="Vc1vt+Sh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EC3A885B84; Fri, 17 Mar 2023 13:04:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20604.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::604]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E19E68596B for ; Fri, 17 Mar 2023 13:04:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan.herbrechtsmeier-oss@weidmueller.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHHI+4TTD2Y5/pLmgl8qPS3BOE5KZxoKPdAl9nC9WUuKEBADqzAiK33TJ7uqon5t4tC+/f6ebZwrQwD/MoU4NHRBCgNvOArrdFRXvvh+cwxPjZ8Vtt5jP2y2OTbKEnqCwcmSKXlz/O1Yas8cXeWta66Bq3Pv9iT2Q2fT9OjRBt1XbOTHz9cXGFfLpH8wAVaCk0i79X4BeP/y0KZciWXMKfgMdDPrDkUeYCxhcR/pbP7bdu4wjSPaoC0nOM5zitBz9B1KVYf1rL1fJKBhg785iArvIchiHusAuhl8iTWPg4108TQJMFOplmRkWY9DVM5X9vtjXm3gJxMC/ZQT2Ro44g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zcr5XPCk29tB8sK494jA2Cgr+bjcmH+u8bUxxEKe/BY=; b=AToVTCfbvuxEnHkVZ1jbCoZR09Cp/bcdcg3AhgfMGGseq0laV/H/MoWGVYOKkRcMs+eOPmrrL45TPsiYcToYbx5e43qMSIvCgEG7K0/KS2voIxztvwKLqdvQPjOKSQecSzm4Vc2gaRWDt8rBDXYWquO5El30lfsZQG5Iprzqdwx4U/x3dOC8detYtbAs61vAwOpEMyt4CdQOVqz9XKzsOVSGvdw7lisUVWcbQah9cy8pH1sCwVS0j09V+p3sXgDLiOIFuJhUBjC4mpvL7SCrPKW7Rx+u+SBnJpgbjLuz8sLRhv4qTpz5Snq7Jo7kpokt21k8u8BbDNFFBOgM7NhTRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zcr5XPCk29tB8sK494jA2Cgr+bjcmH+u8bUxxEKe/BY=; b=Vc1vt+ShEDBn4/FRU0bDr1zgFGt7d/HlF1Hju+iuIH1ueLIziLEqqe0lAX7kDXeZ9tpggWx6DjWesHgm2HZO4LgcCbtdm9mwmD8ft5QXe0kfgTQBPPPoLRiifLM7kX4BeHmC201/HjlnlB1gio6NJQN3DE5+7jb60k299WoYh6I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by AM8PR08MB6452.eurprd08.prod.outlook.com (2603:10a6:20b:360::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.35; Fri, 17 Mar 2023 12:04:32 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::bb7b:6a6:db8c:e8e3]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::bb7b:6a6:db8c:e8e3%4]) with mapi id 15.20.6178.031; Fri, 17 Mar 2023 12:04:31 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Simon Glass Subject: [PATCH] fs: fat: do not mangle short filenames Date: Fri, 17 Mar 2023 13:04:13 +0100 Message-Id: <20230317120413.11066-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: FR0P281CA0069.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::22) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR08MB6969:EE_|AM8PR08MB6452:EE_ X-MS-Office365-Filtering-Correlation-Id: 030072a6-cba4-4238-2356-08db26dfc443 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ChHeWEiVytAEAB8nGopA8ApiGm4nJZGL2lw5R7kQmfOBSl2j8PpQRgoDa8l+99yW/vhghrOPgGMDcQZQq6Z7PvBjuH0YOXDG5Wbbe6bK27LcYKbHsL1Kk+/49yhY2eVDRrFBYe2EDascplTueFpQr6GJWJYSMiUGrDQc62pb71PfwNn8QKUS1L6sGXrPDbTJYv/5CPtou6215Z1G4m4SoHldO5tlK0rlmr2bOM5Zcrt/ITQuM6cu6xB9p5LK+8ZpnSvYZroBtR/1N6+TRCwpcDjhNMufNDGOXYDQluhOai5lOoHLA7UR2wgPyCf0LX9MjHmrUdb5PTqIvLpAH9VoBNi5BU2nNLHTTkOFdj2pLh/lKTXg71gxqWFWTbWmpoZ8lO9PDtPGSDm8mX5DJrukAl5TjuvvNNveEh662ex+YcRCLfB57Y3d7hDg1NhbOX10k69TvHPL52L0AygbNc2QWFkjbDFFskyf6Kn0Bpz6eJXZwy7dWotPrriSUdqwJDhuQrJ82qKTUyGbMgtpMJzGMPGreuWd2ZxkhTWXVYhQFf+GQ9N+6qD1x0Lr3Usnecb2DfU2G5H6uh7tejOez/lnj8UclpF6DU3mb9axdhaf18qksNzObryilNN8jhe0Gnf4jaANDTMjR1iSrqVzAVrUDbH9Ozrh2eHtcB50+BLVng19Rd838WH++Ff77dU1dQd20baGoOuCFBAci69K3L+7lQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB6969.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(39860400002)(366004)(346002)(396003)(136003)(451199018)(8936002)(5660300002)(41300700001)(6916009)(4326008)(86362001)(36756003)(38100700002)(38350700002)(2906002)(6486002)(6666004)(83380400001)(478600001)(186003)(52116002)(2616005)(26005)(6512007)(1076003)(6506007)(66556008)(66476007)(66946007)(54906003)(8676002)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ca+3EC7AXacvRlI6WIPAcj27OJEqvUK1BFoMiCJFv6FRr1WBsbVqoPcCUeyAvbyqv4eAMm1ajqnCu9rXrFWlwJ6hvfx/1Q7H66UU6VeH38DPwzZ+HMWnLsMP6wqLZUDDyGhuT97QurFk+8pzqIEsLhzVk+X4hIKgRxINDIMFyz4LWo8tti1+ERKnccTJDfvkjGCbRk1j9rlXnxvHqA6vzuldeQm0fWtTIbxycE8iOUBiDSWpRNiYgMYcdbvYuvR+a/m2hWlKNBDHv/b8u+5P4+ckFPG8V2gnj3lFrqyirORuKUzXPr+UtU/X87RWYj9WFsLkUHYNFx+CFK9upCzXXTAweEsJK/mfJ1S0Q9u4F9vm3K1OHv5cdUdtFHPGHFoGIqG3bevN7nhbWFb5udqaBa58Qy3We/c+qe4JJllpM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9MofHXxZ7Zv1MIabK6s8T356PDV2bEG6UZJDdyhTIW6HINhCDJuLlr9QUuqT9Wt6ku/4elHXJDWIIX+byv5bchtwNFdJyYXqak356fQNQ== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 030072a6-cba4-4238-2356-08db26dfc443 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 12:04:31.7385 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g3t6JHhgtU4GPnSYJwv+MMsUKVa7Xg/ov6BXSmgWN9T9wIRXgWGgHs60ia7r8Ddliapeg0qXvjGxpgMzVcZ4ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6452 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Stefan Herbrechtsmeier 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 --- 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;