Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63e4cc1d authored by Johan Harvyl's avatar Johan Harvyl Committed by android-build-merger
Browse files

Merge "Format formattable partitions if mount fails" am: cb768571 am: 2f5cfdbb

am: d7865e81

Change-Id: I391ec86730d409d0d6c51e003d57f4f3f0a4a3e3
parents 30f1ad11 d7865e81
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -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;
        }