From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jmBhQ-0006Rn-I8 for barebox@lists.infradead.org; Fri, 19 Jun 2020 07:44:40 +0000 From: Sascha Hauer Date: Fri, 19 Jun 2020 09:44:21 +0200 Message-Id: <20200619074427.17289-16-s.hauer@pengutronix.de> In-Reply-To: <20200619074427.17289-1-s.hauer@pengutronix.de> References: <20200619074427.17289-1-s.hauer@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 15/21] fastboot: Add fastboot_abort() To: Barebox List Cc: =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Add fastboot_abort() to allow aborting the current session. Signed-off-by: Sascha Hauer --- common/fastboot.c | 12 ++++++++++++ include/fastboot.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/common/fastboot.c b/common/fastboot.c index 7f5b8b6f03..10ebb8b2a9 100644 --- a/common/fastboot.c +++ b/common/fastboot.c @@ -347,6 +347,18 @@ void fastboot_download_finished(struct fastboot *fb) fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, ""); } +void fastboot_abort(struct fastboot *fb) +{ + if (fb->download_fd > 0) { + close(fb->download_fd); + fb->download_fd = 0; + } + + fb->active = false; + + unlink(fb->tempname); +} + static void cb_download(struct fastboot *fb, const char *cmd) { fb->download_size = simple_strtoul(cmd, NULL, 16); diff --git a/include/fastboot.h b/include/fastboot.h index 8619dcd34e..7718390ae5 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -66,4 +66,6 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type, void fastboot_start_download_generic(struct fastboot *fb); void fastboot_download_finished(struct fastboot *fb); void fastboot_exec_cmd(struct fastboot *fb, const char *cmdbuf); +void fastboot_abort(struct fastboot *fb); + #endif -- 2.27.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox