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
This commit is contained in:
Szymon Starzycki 2013-10-03 11:06:45 -07:00
parent 781f9fc4af
commit 8fa2f34fd5
7 changed files with 32 additions and 31 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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