diff options
| author | Szymon Starzycki <sstar@google.com> | 2013-10-03 11:06:45 -0700 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2013-12-04 15:00:52 -0800 |
| commit | 55b61f4c9bac7f53289c79f22b4ad0ac80ecfb02 (patch) | |
| tree | ce3b6ec3267889606170dc1c27ee51c1c154b716 /fastbootd | |
| parent | 4662a114a416e636de805fbd875f8b90fc5965b9 (diff) | |
| download | system_core-55b61f4c9bac7f53289c79f22b4ad0ac80ecfb02.tar.gz system_core-55b61f4c9bac7f53289c79f22b4ad0ac80ecfb02.tar.bz2 system_core-55b61f4c9bac7f53289c79f22b4ad0ac80ecfb02.zip | |
Fastbootd: General fixes and changes
read data once bug fix
ability to run fastbootd without network and named socket configuration in init.rc
vendortrigger name changed to fastbootd
deleted unused function from default implementation of OEM library
Change-Id: Ib957fae8172530f20d51bb51b5e07bccab07e555
Diffstat (limited to 'fastbootd')
| -rw-r--r-- | fastbootd/commands.c | 1 | ||||
| -rw-r--r-- | fastbootd/commands/flash.h | 11 | ||||
| -rw-r--r-- | fastbootd/fastbootd.c | 20 | ||||
| -rw-r--r-- | fastbootd/include/vendor_trigger.h | 4 | ||||
| -rw-r--r-- | fastbootd/other/vendor_trigger.c | 19 | ||||
| -rw-r--r-- | fastbootd/secure.c | 3 | ||||
| -rw-r--r-- | fastbootd/transport_socket.c | 5 |
7 files changed, 32 insertions, 31 deletions
diff --git a/fastbootd/commands.c b/fastbootd/commands.c index 2f6e86a76..5c283a8a6 100644 --- a/fastbootd/commands.c +++ b/fastbootd/commands.c @@ -228,6 +228,7 @@ static void cmd_gpt_layout(struct protocol_handle *phandle, const char *arg) { return; } + //TODO: add same verification as in cmd_flash if (phandle->download_fd < 0) { fastboot_fail(phandle, "no layout file"); return; diff --git a/fastbootd/commands/flash.h b/fastbootd/commands/flash.h index 86dc8117e..5a64cabbc 100644 --- a/fastbootd/commands/flash.h +++ b/fastbootd/commands/flash.h @@ -32,6 +32,11 @@ #ifndef _FASTBOOTD_ERASE_H #define _FASTBOOTD_ERASE_H +#include <unistd.h> +#include <errno.h> +#include <string.h> +#include "debug.h" + int flash_find_entry(const char *, char *, size_t); int flash_erase(int fd); @@ -50,10 +55,12 @@ static inline ssize_t read_data_once(int fd, char *buffer, ssize_t size) { ssize_t len; while ((len = TEMP_FAILURE_RETRY(read(fd, (void *) &buffer[readcount], size - readcount))) > 0) { - readcount -= len; + readcount += len; } - if (len < 0) + if (len < 0) { + D(ERR, "Read error:%s", strerror(errno)); return len; + } return readcount; } diff --git a/fastbootd/fastbootd.c b/fastbootd/fastbootd.c index 9318c9928..2b51b330e 100644 --- a/fastbootd/fastbootd.c +++ b/fastbootd/fastbootd.c @@ -38,17 +38,19 @@ int main(int argc, char **argv) { int socket_client = 0; int c; + int network = 1; klog_init(); klog_set_level(6); const struct option longopts[] = { {"socket", no_argument, 0, 'S'}, + {"nonetwork", no_argument, 0, 'n'}, {0, 0, 0, 0} }; while (1) { - c = getopt_long(argc, argv, "S", longopts, NULL); + c = getopt_long(argc, argv, "Sn", longopts, NULL); /* Alphabetical cases */ if (c < 0) break; @@ -56,6 +58,9 @@ int main(int argc, char **argv) case 'S': socket_client = 1; break; + case 'n': + network = 0; + break; case '?': return 1; default: @@ -70,6 +75,7 @@ int main(int argc, char **argv) klog_set_level(6); if (socket_client) { + //TODO: Shouldn't we change current tty into raw mode? run_socket_client(); } else { @@ -78,10 +84,14 @@ int main(int argc, char **argv) load_trigger(); commands_init(); usb_init(); - if (!transport_socket_init()) - exit(1); - ssh_server_start(); - network_discovery_init(); + + if (network) { + if (!transport_socket_init()) + exit(1); + ssh_server_start(); + network_discovery_init(); + } + while (1) { sleep(1); } diff --git a/fastbootd/include/vendor_trigger.h b/fastbootd/include/vendor_trigger.h index 66f65c43f..51204fabe 100644 --- a/fastbootd/include/vendor_trigger.h +++ b/fastbootd/include/vendor_trigger.h @@ -32,7 +32,7 @@ #ifndef __VENDOR_TRIGGER_H_ #define __VENDOR_TRIGGER_H_ -#define TRIGGER_MODULE_ID "vendortrigger" +#define TRIGGER_MODULE_ID "fastbootd" #include <hardware/hardware.h> __BEGIN_DECLS @@ -59,7 +59,7 @@ struct vendor_trigger_t { /* - * Return value 1 forbid the action from the vendor site and sets errno + * Return value -1 forbid the action from the vendor site and sets errno */ int (* gpt_layout)(struct GPT_content *); int (* oem_cmd)(const char *arg, const char **response); diff --git a/fastbootd/other/vendor_trigger.c b/fastbootd/other/vendor_trigger.c index 9b7562c1c..101959bda 100644 --- a/fastbootd/other/vendor_trigger.c +++ b/fastbootd/other/vendor_trigger.c @@ -38,30 +38,11 @@ unsigned int debug_level = DEBUG; static const int version = 1; -int delete_partition(struct GPT_entry_raw *); -int add_partition(struct GPT_entry_raw *); -int modify_partition(struct GPT_entry_raw *, struct GPT_entry_raw *); - int check_version(const int fastboot_version, int *libversion) { *libversion = version; return !(fastboot_version == version); } -int delete_partition(struct GPT_entry_raw *entry) { - D(DEBUG, "message from libvendor"); - return 0; -} - -int add_partition(struct GPT_entry_raw *entry) { - D(DEBUG, "message from libvendor"); - return 0; -} - -int modify_partition(struct GPT_entry_raw *oldentry, struct GPT_entry_raw *newentry) { - D(DEBUG, "message from libvendor"); - return 0; -} - int gpt_layout(struct GPT_content *table) { D(DEBUG, "message from libvendor"); return 0; diff --git a/fastbootd/secure.c b/fastbootd/secure.c index 75a6f3c25..a657ad4da 100644 --- a/fastbootd/secure.c +++ b/fastbootd/secure.c @@ -108,6 +108,9 @@ int cert_read(int fd, CMS_ContentInfo **content, BIO **output) { goto error; } + //TODO: + // read with d2i_CMS_bio to support DER + // with java or just encode data with base64 *content = SMIME_read_CMS(input, output); if (*content == NULL) { unsigned long err = ERR_peek_last_error(); diff --git a/fastbootd/transport_socket.c b/fastbootd/transport_socket.c index 801b8d6f6..ff0f3bdc8 100644 --- a/fastbootd/transport_socket.c +++ b/fastbootd/transport_socket.c @@ -136,13 +136,12 @@ static int listen_socket_init(struct socket_transport *socket_transport) int transport_socket_init() { struct socket_transport *socket_transport = malloc(sizeof(struct socket_transport)); - + socket_transport->transport.connect = socket_connect; socket_transport->transport.close = socket_close; socket_transport->transport.read = socket_read; socket_transport->transport.write = socket_write; - // TODO: create sshd key pair if necessary - + if (!listen_socket_init(socket_transport)) { D(ERR, "socket transport init failed"); free(socket_transport); |
