From patchwork Tue Nov 4 16:25:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 406674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 169B6140079 for ; Wed, 5 Nov 2014 03:26:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 81C174B7E8; Tue, 4 Nov 2014 17:26:04 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wEK5AGEpwhda; Tue, 4 Nov 2014 17:26:04 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DE0F14B80E; Tue, 4 Nov 2014 17:26:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E61EC4B80E for ; Tue, 4 Nov 2014 17:25:58 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 95bDmzcBTDs0 for ; Tue, 4 Nov 2014 17:25:58 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by theia.denx.de (Postfix) with ESMTPS id 7E24B4B7E8 for ; Tue, 4 Nov 2014 17:25:55 +0100 (CET) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEI00IWMWB38GA0@mailout2.samsung.com> for u-boot@lists.denx.de; Wed, 05 Nov 2014 01:25:51 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-56-5458fe0f5d0d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EA.B3.20081.F0EF8545; Wed, 05 Nov 2014 01:25:51 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEI00IHOWAXS020@mmp1.samsung.com>; Wed, 05 Nov 2014 01:25:51 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Tue, 04 Nov 2014 17:25:43 +0100 Message-id: <1415118343-26724-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKJMWRmVeSWpSXmKPExsVy+t9jAV3+fxEhBn+vyFlc3q9tsevvfUaL N4+4Ld483AxktDUyWuy4fIPF4u3eTnYHdo95s06weJy9s4PRY920t8wefVtWMQawRHHZpKTm ZJalFunbJXBlPOzYyFwwl69i+uSbbA2MLdxdjJwcEgImEo/WT2aGsMUkLtxbz9bFyMUhJLCI UeL5/CdgCSGBLiaJ1kYfEJtNQE/i892nTCC2iICExK/+q4wgDcwCHxgl5kzoAUpwcAgLREmc WacLUsMioCox58lBsDm8Am4Sb56vYYdYpijR/WwC2wRG7gWMDKsYRVMLkguKk9JzDfWKE3OL S/PS9ZLzczcxggPjmdQOxpUNFocYBTgYlXh4IyQjQoRYE8uKK3MPMUpwMCuJ8Ko/BgrxpiRW VqUW5ccXleakFh9ilOZgURLnPdBqHSgkkJ5YkpqdmlqQWgSTZeLglGpg9MrNOfiqxFzgpnBM /vKXyd/TVqvPZUlOk+PPq88N0qxvVjjTwXKu/an1t4anNQcTT6uuexVuKNb8f1lazuP61ue2 vrwJi0LqEkIvGayxPdKZfcDl720BRdXekpUifeFfpfgXeS/pM5I5trOxJEJ5RoLDjdTXexcc 2xw9uTfb97CG1/4ZqfOVWIozEg21mIuKEwGv47frCAIAAA== Cc: Marek Vasut , Przemyslaw Marczak Subject: [U-Boot] [PATCH] dfu: thor: fix: Modify dfu_get_alt() function to support absolute paths X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Recently the ext4 file system imposed passing absolute path with its file name parameter. As a result dfu_alt_info env variable has been modified to provide absolute path when ext4 file system is accessed (e.g. /uImage ext4 0 2;). Unfortunately, lthor flashing program provides plain file name (like uImage) and hence those two file names do not match anymore. Presented commit also allows lthor to write files to sub directories (like /boot/bin/uImage). Signed-off-by: Lukasz Majewski --- drivers/dfu/dfu.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 55e6a83..1e9ccdc 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -544,10 +544,35 @@ struct dfu_entity *dfu_get_entity(int alt) int dfu_get_alt(char *name) { struct dfu_entity *dfu; + char *str; list_for_each_entry(dfu, &dfu_list, list) { - if (!strncmp(dfu->name, name, strlen(dfu->name))) - return dfu->alt; + if (dfu->name[0] != '/') { + if (!strncmp(dfu->name, name, strlen(dfu->name))) + return dfu->alt; + } else { + /* + * One must also consider absolute path + * (/boot/bin/uImage) available at dfu->name when + * compared "plain" file name (uImage) + * + * It is the case for e.g. thor gadget where lthor SW + * sends only the file name, so only the very last part + * of patch must be checked for equality + */ + + str = strstr(dfu->name, name); + if (!str) + continue; + + /* + * Check if matching substring is the last element of + * dfu->name (uImage) + */ + if (strlen(dfu->name) == + ((str - dfu->name) + strlen(name))) + return dfu->alt; + } } return -ENODEV;