diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-06-18 13:30:29 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-08-19 07:36:15 +0200 |
commit | fea78c974579883a6cadea546fb8742f6fdb8a83 (patch) | |
tree | 9e6ff23cecea8984dfccdff72cc82c73ff3b8195 /common | |
parent | 38d7ba55da264ddfbb310b28d633a44aa41982ea (diff) | |
download | barebox-fea78c974579883a6cadea546fb8742f6fdb8a83.tar.gz barebox-fea78c974579883a6cadea546fb8742f6fdb8a83.tar.xz |
fastboot: Warn when cb_download is called with file still open
Warn when we are about to open a new download file without having
closed the old one.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/fastboot.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/fastboot.c b/common/fastboot.c index d06581a314..7eb10ac177 100644 --- a/common/fastboot.c +++ b/common/fastboot.c @@ -337,6 +337,7 @@ int fastboot_handle_download_data(struct fastboot *fb, const void *buffer, void fastboot_download_finished(struct fastboot *fb) { close(fb->download_fd); + fb->download_fd = 0; printf("\n"); @@ -356,6 +357,11 @@ static void cb_download(struct fastboot *fb, const char *cmd) init_progression_bar(fb->download_size); + if (fb->download_fd > 0) { + pr_err("%s called and %s is still opened\n", __func__, fb->tempname); + close(fb->download_fd); + } + fb->download_fd = open(fb->tempname, O_WRONLY | O_CREAT | O_TRUNC); if (fb->download_fd < 0) { fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "internal error"); |