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

Commit a30b6964 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

fastboot: propagate error for format command

If fastboot format command fails, return error.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ic4e1a1dea8861028f19ac7f9c834d26e8adba56c
parent cb2f6b67
Loading
Loading
Loading
Loading
+8 −10
Original line number Original line Diff line number Diff line
@@ -1466,15 +1466,13 @@ static void fb_perform_format(
            fprintf(stderr, "File system type %s not supported.\n", partition_type.c_str());
            fprintf(stderr, "File system type %s not supported.\n", partition_type.c_str());
            return;
            return;
        }
        }
        fprintf(stderr, "Formatting is not supported for file system with type '%s'.\n",
        die("Formatting is not supported for file system with type '%s'.",
            partition_type.c_str());
            partition_type.c_str());
        return;
    }
    }


    int64_t size;
    int64_t size;
    if (!android::base::ParseInt(partition_size, &size)) {
    if (!android::base::ParseInt(partition_size, &size)) {
        fprintf(stderr, "Couldn't parse partition size '%s'.\n", partition_size.c_str());
        die("Couldn't parse partition size '%s'.", partition_size.c_str());
        return;
    }
    }


    unsigned eraseBlkSize, logicalBlkSize;
    unsigned eraseBlkSize, logicalBlkSize;
@@ -1484,17 +1482,14 @@ static void fb_perform_format(
    if (fs_generator_generate(gen, output.path, size, initial_dir,
    if (fs_generator_generate(gen, output.path, size, initial_dir,
            eraseBlkSize, logicalBlkSize)) {
            eraseBlkSize, logicalBlkSize)) {
        die("Cannot generate image for %s", partition.c_str());
        die("Cannot generate image for %s", partition.c_str());
        return;
    }
    }


    fd.reset(open(output.path, O_RDONLY));
    fd.reset(open(output.path, O_RDONLY));
    if (fd == -1) {
    if (fd == -1) {
        fprintf(stderr, "Cannot open generated image: %s\n", strerror(errno));
        die("Cannot open generated image: %s", strerror(errno));
        return;
    }
    }
    if (!load_buf_fd(fd.release(), &buf)) {
    if (!load_buf_fd(fd.release(), &buf)) {
        fprintf(stderr, "Cannot read image: %s\n", strerror(errno));
        die("Cannot read image: %s", strerror(errno));
        return;
    }
    }
    flash_buf(partition, &buf);
    flash_buf(partition, &buf);
    return;
    return;
@@ -1505,6 +1500,9 @@ failed:
        if (errMsg) fprintf(stderr, "%s", errMsg);
        if (errMsg) fprintf(stderr, "%s", errMsg);
    }
    }
    fprintf(stderr, "FAILED (%s)\n", fb->Error().c_str());
    fprintf(stderr, "FAILED (%s)\n", fb->Error().c_str());
    if (!skip_if_not_supported) {
        die("Command failed");
    }
}
}


static bool should_flash_in_userspace(const std::string& partition_name) {
static bool should_flash_in_userspace(const std::string& partition_name) {
+3 −0
Original line number Original line Diff line number Diff line
@@ -390,6 +390,9 @@ fastboot_getvar partition-type:scratch raw &&
echo "${ORANGE}[     INFO ]${NORMAL} expect fastboot erase scratch to fail" >&2
echo "${ORANGE}[     INFO ]${NORMAL} expect fastboot erase scratch to fail" >&2
fastboot erase scratch &&
fastboot erase scratch &&
  die "fastbootd can erase scratch"
  die "fastbootd can erase scratch"
echo "${ORANGE}[     INFO ]${NORMAL} expect fastboot format scratch to fail" >&2
fastboot format scratch &&
  die "fastbootd can format scratch"
fastboot reboot ||
fastboot reboot ||
  die "can not reboot out of fastbootd"
  die "can not reboot out of fastbootd"
echo "${ORANGE}[  WARNING ]${NORMAL} adb after fastboot ... waiting 2 minutes"
echo "${ORANGE}[  WARNING ]${NORMAL} adb after fastboot ... waiting 2 minutes"