[PATCH 14/20] fastboot: Add fastboot_abort()
Sascha Hauer
s.hauer at pengutronix.de
Thu Aug 13 09:42:51 EDT 2020
Add fastboot_abort() to allow aborting the current session.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
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.28.0
More information about the barebox
mailing list