aboutsummaryrefslogtreecommitdiffstats
path: root/fastboot
diff options
context:
space:
mode:
authorJP Abgrall <jpa@google.com>2012-05-14 08:35:13 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-14 08:35:13 -0700
commit3447b11d3e72bdc7409f63ec76ceba1babe06486 (patch)
tree86474ce61ba78ecf50005d550a36b3d1b40f60ff /fastboot
parentb8ad0f09d158d872693ed6208476fdb15fc515f9 (diff)
parent177a74aced971b89c319fb61ee12da0ca40f0c12 (diff)
downloadsystem_core-3447b11d3e72bdc7409f63ec76ceba1babe06486.tar.gz
system_core-3447b11d3e72bdc7409f63ec76ceba1babe06486.tar.bz2
system_core-3447b11d3e72bdc7409f63ec76ceba1babe06486.zip
am 177a74ac: am c1f88106: Merge "fastboot: Change -w to format after the erase of userdata & cache" into jb-dev
* commit '177a74aced971b89c319fb61ee12da0ca40f0c12': fastboot: Change -w to format after the erase of userdata & cache
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/engine.c28
-rw-r--r--fastboot/fastboot.c4
-rw-r--r--fastboot/fastboot.h2
3 files changed, 29 insertions, 5 deletions
diff --git a/fastboot/engine.c b/fastboot/engine.c
index a1b65391..f5215cfd 100644
--- a/fastboot/engine.c
+++ b/fastboot/engine.c
@@ -255,6 +255,7 @@ void generate_ext4_image(struct image_data *image)
#else
fd = fileno(tmpfile());
#endif
+ /* reset ext4fs info so we can be called multiple times */
reset_ext4fs_info();
info.len = image->partition_size;
make_ext4fs_internal(fd, NULL, NULL, NULL, 0, 1, 0, 0, 0, NULL);
@@ -266,7 +267,7 @@ void generate_ext4_image(struct image_data *image)
close(fd);
}
-int fb_format(Action *a, usb_handle *usb)
+int fb_format(Action *a, usb_handle *usb, int skip_if_not_supported)
{
const char *partition = a->cmd;
char response[FB_RESPONSE_SZ+1];
@@ -281,6 +282,13 @@ int fb_format(Action *a, usb_handle *usb)
snprintf(cmd, sizeof(cmd), "getvar:partition-type:%s", partition);
status = fb_command_response(usb, cmd, response);
if (status) {
+ if (skip_if_not_supported) {
+ fprintf(stderr,
+ "Erase successful, but not automatically formatting.\n");
+ fprintf(stderr,
+ "Can't determine partition type.\n");
+ return 0;
+ }
fprintf(stderr,"FAILED (%s)\n", fb_get_error());
return status;
}
@@ -292,6 +300,13 @@ int fb_format(Action *a, usb_handle *usb)
}
}
if (!generator) {
+ if (skip_if_not_supported) {
+ fprintf(stderr,
+ "Erase successful, but not automatically formatting.\n");
+ fprintf(stderr,
+ "File system type %s not supported.\n", response);
+ return 0;
+ }
fprintf(stderr,"Formatting is not supported for filesystem with type '%s'.\n",
response);
return -1;
@@ -301,6 +316,12 @@ int fb_format(Action *a, usb_handle *usb)
snprintf(cmd, sizeof(cmd), "getvar:partition-size:%s", partition);
status = fb_command_response(usb, cmd, response);
if (status) {
+ if (skip_if_not_supported) {
+ fprintf(stderr,
+ "Erase successful, but not automatically formatting.\n");
+ fprintf(stderr, "Unable to get partition size\n.");
+ return 0;
+ }
fprintf(stderr,"FAILED (%s)\n", fb_get_error());
return status;
}
@@ -329,11 +350,12 @@ cleanup:
return status;
}
-void fb_queue_format(const char *partition)
+void fb_queue_format(const char *partition, int skip_if_not_supported)
{
Action *a;
a = queue_action(OP_FORMAT, partition);
+ a->data = (void*)skip_if_not_supported;
a->msg = mkmsg("formatting '%s' partition", partition);
}
@@ -547,7 +569,7 @@ int fb_execute_queue(usb_handle *usb)
} else if (a->op == OP_NOTICE) {
fprintf(stderr,"%s\n",(char*)a->data);
} else if (a->op == OP_FORMAT) {
- status = fb_format(a, usb);
+ status = fb_format(a, usb, (int)a->data);
status = a->func(a, status, status ? fb_get_error() : "");
if (status) break;
} else {
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index b96d93b0..5858e233 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -654,7 +654,7 @@ int main(int argc, char **argv)
skip(2);
} else if(!strcmp(*argv, "format")) {
require(2);
- fb_queue_format(argv[1]);
+ fb_queue_format(argv[1], 0);
skip(2);
} else if(!strcmp(*argv, "signature")) {
require(2);
@@ -744,7 +744,9 @@ int main(int argc, char **argv)
if (wants_wipe) {
fb_queue_erase("userdata");
+ fb_queue_format("userdata", 1);
fb_queue_erase("cache");
+ fb_queue_format("cache", 1);
}
if (wants_reboot) {
fb_queue_reboot();
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index c249a8f5..90d8a6a8 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -43,7 +43,7 @@ char *fb_get_error(void);
/* engine.c - high level command queue engine */
void fb_queue_flash(const char *ptn, void *data, unsigned sz);;
void fb_queue_erase(const char *ptn);
-void fb_queue_format(const char *ptn);
+void fb_queue_format(const char *ptn, int skip_if_not_supported);
void fb_queue_require(const char *prod, const char *var, int invert,
unsigned nvalues, const char **value);
void fb_queue_display(const char *var, const char *prettyname);