Wait for device to disappear after reboot-bootloader.
(Linux only for now) With fastboot reading serial numbers from sysfs, it had
become possible for a fastboot command issued immediately after rebooting
the bootloader to fail, because sysfs still thought the device was online.
To prevent this, after reboot-bootloader we wait for the device to disconnect.
Also made usb_read and usb_write fail immediately if the descriptor has been
closed; this prevents an incorrect error message ("Bad file descriptor")
when errors from fb_getvar are ignored (e.g., by fb_format_supported).
Also removed unused fd param from filter_usb_device, and simplified logic
in usb_write by using do/while instead of a special case for len == 0.
Change-Id: I799b857eab411fd8ad25f5777fc61c685152ea86
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 447b257..70b838f 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
@@ -82,17 +81,6 @@
unsigned tags_offset = 0x00000100;
-void die(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- fprintf(stderr,"error: ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr,"\n");
- va_end(ap);
- exit(1);
-}
-
void get_my_path(char *path);
char *find_item(const char *item, const char *product)
@@ -1031,6 +1019,7 @@
fb_queue_reboot();
} else if (wants_reboot_bootloader) {
fb_queue_command("reboot-bootloader", "rebooting into bootloader");
+ fb_queue_wait_for_disconnect();
}
if (fb_queue_is_empty())