summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-11-02 23:45:55 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-11-02 23:45:55 +0000
commitd0f45aa24c09c0802784263fe2dccd38e226e23a (patch)
tree76f2bf1391ec984a38a13d29877a158c05b89ae4 /fastboot/fastboot.cpp
parent36d7af4cf635816ecbcb9bd300f4c9d60cb012d4 (diff)
parent8ab9a32323cee1f23c5ccbfeabd2cb2253f693d2 (diff)
Merge "Clarify and fix the intent of the partition-type checking code."
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r--fastboot/fastboot.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 6b845a013..5745fb0a4 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -614,8 +614,12 @@ static int64_t get_sparse_limit(usb_handle* usb, int64_t size) {
// Until we get lazy inode table init working in make_ext4fs, we need to
// erase partitions of type ext4 before flashing a filesystem so no stale
// inodes are left lying around. Otherwise, e2fsck gets very upset.
-static bool needs_erase(usb_handle* usb, const char* part) {
- return !fb_format_supported(usb, part, nullptr);
+static bool needs_erase(usb_handle* usb, const char* partition) {
+ std::string partition_type;
+ if (!fb_getvar(usb, std::string("partition-type:") + partition, &partition_type)) {
+ return false;
+ }
+ return partition_type == "ext4";
}
static int load_buf_fd(usb_handle* usb, int fd, struct fastboot_buffer* buf) {
@@ -889,7 +893,7 @@ static void fb_perform_format(usb_handle* usb,
partition_size = size_override;
}
- gen = fs_get_generator(partition_type.c_str());
+ gen = fs_get_generator(partition_type);
if (!gen) {
if (skip_if_not_supported) {
fprintf(stderr, "Erase successful, but not automatically formatting.\n");
@@ -1059,8 +1063,11 @@ int main(int argc, char **argv)
} else if(!strcmp(*argv, "erase")) {
require(2);
- if (!fb_format_supported(usb, argv[1], nullptr)) {
- fprintf(stderr, "******** Did you mean to fastboot format this partition?\n");
+ std::string partition_type;
+ if (fb_getvar(usb, std::string("partition-type:") + argv[1], &partition_type) &&
+ fs_get_generator(partition_type) != nullptr) {
+ fprintf(stderr, "******** Did you mean to fastboot format this %s partition?\n",
+ partition_type.c_str());
}
fb_queue_erase(argv[1]);