diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2016-08-15 19:53:54 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-08-15 19:53:54 +0200 |
commit | cb76857147522402a1202ea84c63da3c7452fcd6 (patch) | |
tree | 2221ab3c993d4c92a547439bba361a1c9d6cf4e8 | |
parent | Merge "adb headers now refer to openssl headers." (diff) | |
parent | Format formattable partitions if mount fails (diff) | |
download | android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.tar android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.tar.gz android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.tar.bz2 android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.tar.lz android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.tar.xz android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.tar.zst android_bootable_recovery-cb76857147522402a1202ea84c63da3c7452fcd6.zip |
-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; } |