From patchwork Tue Mar 19 22:57:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1058755 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44P7kg2l16z9sNd for ; Wed, 20 Mar 2019 09:58:19 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id AEC9AC21FB7; Tue, 19 Mar 2019 22:58:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2B9E8C21F99; Tue, 19 Mar 2019 22:58:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 36BE7C21F99; Tue, 19 Mar 2019 22:58:09 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id AC56FC21F8E for ; Tue, 19 Mar 2019 22:58:08 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id E10653C013A; Tue, 19 Mar 2019 23:58:04 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5Yo8-lZLxYzs; Tue, 19 Mar 2019 23:57:57 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 6B3973C00C5; Tue, 19 Mar 2019 23:57:57 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.435.0; Tue, 19 Mar 2019 23:57:56 +0100 From: Eugeniu Rosca To: Alex Kiernan , Simon Glass , Joe Hershberger , Jocelyn Bohr , Alex Deymo , Jassi Brar , Jens Wiklander , Patrick Delaunay , Tom Rini , Date: Tue, 19 Mar 2019 23:57:05 +0100 Message-ID: <20190319225706.27649-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 1/2] fastboot: getvar_partition_{type, size}: Sanitize arguments X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Correct usage of "fastboot getvar_partition_{type,size}" is: host $> fastboot getvar partition-size:misc partition-size:misc: 0x0000000000000400 Finished. Total time: 0.214s When the partition name is omitted, current behavior is: host $> fastboot getvar partition-size getvar:partition-size FAILED (remote: partition not found) finished. total time: 0.005s host $> fastboot getvar partition-size: getvar:partition-size: FAILED (remote: partition not found) finished. total time: 0.006s host $> fastboot getvar partition-type getvar:partition-type FAILED (remote: partition not found) finished. total time: 0.005s host $> fastboot getvar partition-type: getvar:partition-type: FAILED (remote: partition not found) finished. total time: 0.006s Tell the user the real cause of command failure: host $> fastboot getvar partition-size getvar:partition-size FAILED (remote: missing partition name) Finished. Total time: 0.003s host $> fastboot getvar partition-size: getvar:partition-size: FAILED (remote: missing partition name) Finished. Total time: 0.003s host $> fastboot getvar partition-type getvar:partition-type FAILED (remote: missing partition name) Finished. Total time: 0.003s host $> fastboot getvar partition-type: getvar:partition-type: FAILED (remote: missing partition name) Finished. Total time: 0.003s Fixes: f73a7df984a9 ("net: fastboot: Merge AOSP UDP fastboot") Signed-off-by: Eugeniu Rosca --- drivers/fastboot/fb_getvar.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c index 4d264c985d7e..28e3e2fa1619 100644 --- a/drivers/fastboot/fb_getvar.c +++ b/drivers/fastboot/fb_getvar.c @@ -144,6 +144,11 @@ static void getvar_partition_type(char *part_name, char *response) struct blk_desc *dev_desc; disk_partition_t part_info; + if (!part_name || !strcmp(part_name, "")) { + fastboot_fail("missing partition name", response); + return; + } + r = fastboot_mmc_get_part_info(part_name, &dev_desc, &part_info, response); if (r >= 0) { @@ -162,6 +167,11 @@ static void getvar_partition_size(char *part_name, char *response) int r; size_t size; + if (!part_name || !strcmp(part_name, "")) { + fastboot_fail("missing partition name", response); + return; + } + #if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) struct blk_desc *dev_desc; disk_partition_t part_info; From patchwork Tue Mar 19 22:57:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 1058756 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44P7lB5Wwcz9sNG for ; Wed, 20 Mar 2019 09:58:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5E3F9C22007; Tue, 19 Mar 2019 22:58:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B298DC2200C; Tue, 19 Mar 2019 22:58:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 97362C22007; Tue, 19 Mar 2019 22:58:17 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lists.denx.de (Postfix) with ESMTPS id B1074C21FFD for ; Tue, 19 Mar 2019 22:58:13 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 94F233C013A; Tue, 19 Mar 2019 23:58:13 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zRbknwTmxrQN; Tue, 19 Mar 2019 23:58:07 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 4A1383C00C5; Tue, 19 Mar 2019 23:58:07 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.435.0; Tue, 19 Mar 2019 23:58:06 +0100 From: Eugeniu Rosca To: Alex Kiernan , Simon Glass , Joe Hershberger , Jocelyn Bohr , Alex Deymo , Jassi Brar , Jens Wiklander , Patrick Delaunay , Tom Rini , Date: Tue, 19 Mar 2019 23:57:06 +0100 Message-ID: <20190319225706.27649-2-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190319225706.27649-1-erosca@de.adit-jv.com> References: <20190319225706.27649-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Cc: Eugeniu Rosca , Eugeniu Rosca Subject: [U-Boot] [PATCH 2/2] fastboot: getvar_partition_type: Return 'raw' when FS-unaware X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Only a handful of Android/fastboot partitions (e.g. /system, /vendor, /userdata) have filesystem: host $> fastboot getvar partition-type:userdata partition-type:userdata: ext4 Finished. Total time: 0.013s Most of them (/misc, /pstore, /vbmeta, /dtb{o}, /boot, etc) don't. And for the latter fastboot reports: host $> fastboot getvar partition-type:misc getvar:partition-type:misc FAILED (remote: failed to set partition) Finished. Total time: 0.219s Rather than creating pointless worries via error reporting, tell the users they are dealing with a 'raw' partition: host $> fastboot getvar partition-type:misc partition-type:misc: raw Finished. Total time: 0.017s Fixes: f73a7df984a9 ("net: fastboot: Merge AOSP UDP fastboot") Signed-off-by: Eugeniu Rosca --- drivers/fastboot/fb_getvar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c index 28e3e2fa1619..beadf7f98e5d 100644 --- a/drivers/fastboot/fb_getvar.c +++ b/drivers/fastboot/fb_getvar.c @@ -154,7 +154,7 @@ static void getvar_partition_type(char *part_name, char *response) if (r >= 0) { r = fs_set_blk_dev_with_part(dev_desc, r); if (r < 0) - fastboot_fail("failed to set partition", response); + fastboot_okay("raw", response); else fastboot_okay(fs_get_type_name(), response); }