diff options
author | Johan Harvyl <johan.harvyl@sonymobile.com> | 2016-08-15 18:03:37 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-08-15 18:03:37 +0000 |
commit | 2f5cfdbb9d337cec54eb7cccafb4b5e20457c013 (patch) | |
tree | 14476be673a6c40ed07f3590213f1e09c0e1dcd4 /roots.cpp | |
parent | c687a72d9f6f6255cb60ce2acd68b9f9acec1b61 (diff) | |
parent | cb76857147522402a1202ea84c63da3c7452fcd6 (diff) | |
download | android_bootable_recovery-2f5cfdbb9d337cec54eb7cccafb4b5e20457c013.tar.gz android_bootable_recovery-2f5cfdbb9d337cec54eb7cccafb4b5e20457c013.tar.bz2 android_bootable_recovery-2f5cfdbb9d337cec54eb7cccafb4b5e20457c013.zip |
Merge "Format formattable partitions if mount fails"
am: cb76857147
Change-Id: I50c2045f56693e445922d30af72867e7ac55b61f
Diffstat (limited to 'roots.cpp')
-rw-r--r-- | roots.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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; } |