summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Harvyl <johan.harvyl@sonymobile.com>2016-08-15 20:12:05 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-08-15 20:12:05 +0200
commit63e4cc1d1613ba958fe0b550d0392b6d46058f26 (patch)
tree79e60e3da79d62fd0355b6cb029fbce1cc0a4e24
parentAdd inttypes.h for PRIu64. am: 53c107f068 (diff)
parentMerge "Format formattable partitions if mount fails" am: cb76857147 (diff)
downloadandroid_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.tar
android_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.tar.gz
android_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.tar.bz2
android_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.tar.lz
android_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.tar.xz
android_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.tar.zst
android_bootable_recovery-63e4cc1d1613ba958fe0b550d0392b6d46058f26.zip
-rw-r--r--roots.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/roots.cpp b/roots.cpp
index 2fec9ae9d..49369475b 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -102,7 +102,20 @@ int ensure_path_mounted_at(const char* path, const char* mount_point) {
if (strcmp(v->fs_type, "ext4") == 0 ||
strcmp(v->fs_type, "squashfs") == 0 ||
strcmp(v->fs_type, "vfat") == 0) {
- if (mount(v->blk_device, mount_point, v->fs_type, v->flags, v->fs_options) == -1) {
+ int result = mount(v->blk_device, mount_point, v->fs_type, v->flags, v->fs_options);
+ if (result == -1 && fs_mgr_is_formattable(v)) {
+ LOGE("failed to mount %s (%s), formatting ...\n",
+ mount_point, strerror(errno));
+ bool crypt_footer = fs_mgr_is_encryptable(v) && !strcmp(v->key_loc, "footer");
+ if (fs_mgr_do_format(v, crypt_footer) == 0) {
+ result = mount(v->blk_device, mount_point, v->fs_type, v->flags, v->fs_options);
+ } else {
+ LOGE("failed to format %s (%s)\n", mount_point, strerror(errno));
+ return -1;
+ }
+ }
+
+ if (result == -1) {
LOGE("failed to mount %s (%s)\n", mount_point, strerror(errno));
return -1;
}