summaryrefslogtreecommitdiffstats
path: root/bootloader.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2011-04-22 18:26:44 +0200
committerDoug Zongker <dougz@android.com>2011-04-22 18:33:14 +0200
commitcfd256a3328aac1199a35825b5daf04f5f4fc112 (patch)
tree1b3e4ea2cb7907c9d5d7a2d390e9566ed54d2ea7 /bootloader.c
parentmake write_raw_image able to take a blob (diff)
downloadandroid_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.tar
android_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.tar.gz
android_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.tar.bz2
android_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.tar.lz
android_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.tar.xz
android_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.tar.zst
android_bootable_recovery-cfd256a3328aac1199a35825b5daf04f5f4fc112.zip
Diffstat (limited to '')
-rw-r--r--bootloader.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/bootloader.c b/bootloader.c
index b690c5582..709656602 100644
--- a/bootloader.c
+++ b/bootloader.c
@@ -22,6 +22,8 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
static int get_bootloader_message_mtd(struct bootloader_message *out, const Volume* v);
static int set_bootloader_message_mtd(const struct bootloader_message *in, const Volume* v);
@@ -132,8 +134,26 @@ static int set_bootloader_message_mtd(const struct bootloader_message *in,
// for misc partitions on block devices
// ------------------------------------
+static void wait_for_device(const char* fn) {
+ int tries = 0;
+ int ret;
+ struct stat buf;
+ do {
+ ++tries;
+ ret = stat(fn, &buf);
+ if (ret) {
+ printf("stat %s try %d: %s\n", fn, tries, strerror(errno));
+ sleep(1);
+ }
+ } while (ret && tries < 10);
+ if (ret) {
+ printf("failed to stat %s\n", fn);
+ }
+}
+
static int get_bootloader_message_block(struct bootloader_message *out,
const Volume* v) {
+ wait_for_device(v->device);
FILE* f = fopen(v->device, "rb");
if (f == NULL) {
LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno));
@@ -155,6 +175,7 @@ static int get_bootloader_message_block(struct bootloader_message *out,
static int set_bootloader_message_block(const struct bootloader_message *in,
const Volume* v) {
+ wait_for_device(v->device);
FILE* f = fopen(v->device, "wb");
if (f == NULL) {
LOGE("Can't open %s\n(%s)\n", v->device, strerror(errno));