diff options
author | Doug Zongker <dougz@android.com> | 2010-10-24 14:02:04 -0700 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2010-10-24 14:02:04 -0700 |
commit | c0fc1501d9b808d957265d60a5afaf47a190375d (patch) | |
tree | be22c874e32e0099bd54a6a4164492986b48d275 /recovery | |
parent | 3fda02d334845a570b9de76006741be42280f544 (diff) | |
download | device_samsung_crespo-c0fc1501d9b808d957265d60a5afaf47a190375d.zip device_samsung_crespo-c0fc1501d9b808d957265d60a5afaf47a190375d.tar.gz device_samsung_crespo-c0fc1501d9b808d957265d60a5afaf47a190375d.tar.bz2 |
delay recovery startup until emmc block devices exist
recovery can get started before the kernel has created the EMMC
devices, which will make the wipe_data operation fail (trying
to open a device that doesn't exist). Hold up the start of
recovery for up to 5 seconds waiting for the userdata partition
block device to exist.
Bug: 3126195
Change-Id: I2b3d74cc3ffdc69372cdba00d3ffdc5251d8c6b3
Diffstat (limited to 'recovery')
-rw-r--r-- | recovery/recovery_ui.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/recovery/recovery_ui.c b/recovery/recovery_ui.c index 3474832..d26bff8 100644 --- a/recovery/recovery_ui.c +++ b/recovery/recovery_ui.c @@ -15,6 +15,9 @@ */ #include <linux/input.h> +#include <sys/stat.h> +#include <errno.h> +#include <string.h> #include "recovery_ui.h" #include "common.h" @@ -31,6 +34,34 @@ char* MENU_ITEMS[] = { "reboot system now", NULL }; int device_recovery_start() { + // recovery can get started before the kernel has created the EMMC + // devices, which will make the wipe_data operation fail (trying + // to open a device that doesn't exist). Hold up the start of + // recovery for up to 5 seconds waiting for the userdata partition + // block device to exist. + + const char* fn = "/dev/block/platform/s3c-sdhci.0/by-name/userdata"; + + int tries = 0; + int ret; + struct stat buf; + do { + ++tries; + ret = stat(fn, &buf); + if (ret) { + printf("try %d: %s\n", tries, strerror(errno)); + sleep(1); + } + } while (ret && tries < 5); + if (!ret) { + printf("stat() of %s succeeded on try %d\n", fn, tries); + } else { + printf("failed to stat %s\n", fn); + } + + // We let recovery attempt to carry on even if the stat never + // succeeded. + return 0; } |