diff options
author | Colin Cross <ccross@android.com> | 2012-05-24 18:24:53 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2012-07-09 22:16:57 -0700 |
commit | 80f2d036a9dff894df27961c4aed300f1a5ebbc4 (patch) | |
tree | 823455015e1c5350b70fc39f05e61dec15f1eb77 | |
parent | 8879f988bac8d4cb46fb82e3d82ad69a9ed89b16 (diff) | |
download | system_core-80f2d036a9dff894df27961c4aed300f1a5ebbc4.zip system_core-80f2d036a9dff894df27961c4aed300f1a5ebbc4.tar.gz system_core-80f2d036a9dff894df27961c4aed300f1a5ebbc4.tar.bz2 |
fastboot: add fb_getvar
Add an fb_getvar helper that can be used to get values from the
target.
Change-Id: I0da088fcbc8d40076c7bf5ef6e5bbd97fae61471
-rw-r--r-- | fastboot/engine.c | 22 | ||||
-rw-r--r-- | fastboot/fastboot.h | 1 |
2 files changed, 17 insertions, 6 deletions
diff --git a/fastboot/engine.c b/fastboot/engine.c index 46b0828..7dc29e4 100644 --- a/fastboot/engine.c +++ b/fastboot/engine.c @@ -111,6 +111,20 @@ struct image_data { void generate_ext4_image(struct image_data *image); void cleanup_image(struct image_data *image); +int fb_getvar(struct usb_handle *usb, char *response, const char *fmt, ...) +{ + char cmd[CMD_SIZE] = "getvar:"; + int getvar_len = strlen(cmd); + va_list args; + + response[FB_RESPONSE_SZ] = '\0'; + va_start(args, fmt); + vsnprintf(cmd + getvar_len, sizeof(cmd) - getvar_len, fmt, args); + va_end(args); + cmd[CMD_SIZE - 1] = '\0'; + return fb_command_response(usb, cmd, response); +} + struct generator { char *fs_type; @@ -278,9 +292,7 @@ int fb_format(Action *a, usb_handle *usb, int skip_if_not_supported) unsigned i; char cmd[CMD_SIZE]; - response[FB_RESPONSE_SZ] = '\0'; - snprintf(cmd, sizeof(cmd), "getvar:partition-type:%s", partition); - status = fb_command_response(usb, cmd, response); + status = fb_getvar(usb, response, "partition-type:%s", partition); if (status) { if (skip_if_not_supported) { fprintf(stderr, @@ -312,9 +324,7 @@ int fb_format(Action *a, usb_handle *usb, int skip_if_not_supported) return -1; } - response[FB_RESPONSE_SZ] = '\0'; - snprintf(cmd, sizeof(cmd), "getvar:partition-size:%s", partition); - status = fb_command_response(usb, cmd, response); + status = fb_getvar(usb, response, "partition-size:%s", partition); if (status) { if (skip_if_not_supported) { fprintf(stderr, diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h index 1d3e2b8..a84b0be 100644 --- a/fastboot/fastboot.h +++ b/fastboot/fastboot.h @@ -41,6 +41,7 @@ char *fb_get_error(void); #define FB_RESPONSE_SZ 64 /* engine.c - high level command queue engine */ +int fb_getvar(struct usb_handle *usb, char *response, const char *fmt, ...); 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, int skip_if_not_supported); |