fastboot: add fb_getvar

Add an fb_getvar helper that can be used to get values from the
target.

Change-Id: I0da088fcbc8d40076c7bf5ef6e5bbd97fae61471
This commit is contained in:
Colin Cross 2012-05-24 18:24:53 -07:00
parent 8879f988ba
commit 80f2d036a9
2 changed files with 17 additions and 6 deletions

View File

@ -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,

View File

@ -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);